From: Ashutosh Dixit <ashutosh.dixit@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 09/20] tests/i915/perf: Fix test_i915_ref_count for xe
Date: Mon, 7 Aug 2023 18:00:06 -0700 [thread overview]
Message-ID: <20230808010017.37819-10-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <20230808010017.37819-1-ashutosh.dixit@intel.com>
We need to tell read_i915_module_ref if we are using i915 or xe. Also the
module name in /proc/modules is different.
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
tests/i915/perf.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/tests/i915/perf.c b/tests/i915/perf.c
index 292afda9a434..ef2d56e319f8 100644
--- a/tests/i915/perf.c
+++ b/tests/i915/perf.c
@@ -5418,18 +5418,21 @@ test_whitelisted_registers_userspace_config(void)
}
static unsigned
-read_i915_module_ref(void)
+read_i915_module_ref(bool is_xe)
{
FILE *fp = fopen("/proc/modules", "r");
char *line = NULL;
size_t line_buf_size = 0;
int len = 0;
unsigned ref_count;
+ char mod[8];
+ int modn = is_xe ? 3 : 5;
igt_assert(fp);
+ strcpy(mod, is_xe ? "xe " : "i915 ");
while ((len = getline(&line, &line_buf_size, fp)) > 0) {
- if (strncmp(line, "i915 ", 5) == 0) {
+ if (strncmp(line, mod, modn) == 0) {
unsigned long mem;
int ret = sscanf(line + 5, "%lu %u", &mem, &ref_count);
igt_assert(ret == 2);
@@ -5484,17 +5487,26 @@ test_i915_ref_count(void)
unsigned baseline, ref_count0, ref_count1;
uint32_t oa_report0[64];
uint32_t oa_report1[64];
+ bool is_xe;
/* This should be the first test before the first fixture so no drm_fd
* should have been opened so far...
*/
igt_assert_eq(drm_fd, -1);
- baseline = read_i915_module_ref();
+ /* Tell read_i915_module_ref if we are on xe or i915 (because drm_fd is -1) */
+ drm_fd = __drm_open_driver(DRIVER_INTEL | DRIVER_XE);
+ is_xe = is_xe_device(drm_fd);
+ drm_close_driver(drm_fd);
+ close(sysfs);
+ drm_fd = -1;
+
+ baseline = read_i915_module_ref(is_xe);
igt_debug("baseline ref count (drm fd closed) = %u\n", baseline);
- drm_fd = __drm_open_driver(DRIVER_INTEL);
- igt_require_i915(drm_fd);
+ drm_fd = __drm_open_driver(DRIVER_INTEL | DRIVER_XE);
+ if (is_xe_device(drm_fd))
+ xe_device_get(drm_fd);
devid = intel_get_drm_devid(drm_fd);
sysfs = perf_sysfs_open(drm_fd);
@@ -5506,12 +5518,12 @@ test_i915_ref_count(void)
properties[5] = default_test_set->perf_oa_format;
properties[7] = oa_exp_1_millisec;
- ref_count0 = read_i915_module_ref();
+ ref_count0 = read_i915_module_ref(is_xe);
igt_debug("initial ref count with drm_fd open = %u\n", ref_count0);
igt_assert(ref_count0 > baseline);
stream_fd = __perf_open(drm_fd, ¶m, false);
- ref_count1 = read_i915_module_ref();
+ ref_count1 = read_i915_module_ref(is_xe);
igt_debug("ref count after opening i915 perf stream = %u\n", ref_count1);
igt_assert(ref_count1 > ref_count0);
@@ -5519,7 +5531,7 @@ test_i915_ref_count(void)
close(sysfs);
drm_fd = -1;
sysfs = -1;
- ref_count0 = read_i915_module_ref();
+ ref_count0 = read_i915_module_ref(is_xe);
igt_debug("ref count after closing drm fd = %u\n", ref_count0);
igt_assert(ref_count0 > baseline);
@@ -5531,7 +5543,7 @@ test_i915_ref_count(void)
false); /* not just timer reports */
__perf_close(stream_fd);
- ref_count0 = read_i915_module_ref();
+ ref_count0 = read_i915_module_ref(is_xe);
igt_debug("ref count after closing i915 perf stream fd = %u\n", ref_count0);
igt_assert_eq(ref_count0, baseline);
}
--
2.41.0
next prev parent reply other threads:[~2023-08-08 1:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 0:59 [igt-dev] [PATCH i-g-t 00/20] Extend i915/perf for testing Xe OA Ashutosh Dixit
2023-08-08 0:59 ` [igt-dev] [PATCH i-g-t 01/20] drm-uapi/xe_drm: OA changes Ashutosh Dixit
2023-08-08 0:59 ` [igt-dev] [PATCH i-g-t 02/20] lib/xe/xe_query: Add xe_gts interface Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 03/20] lib/i915/perf: Add xe_perf_for_fd Ashutosh Dixit
2023-08-08 6:20 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 04/20] lib/i915/perf: Derive topology info for xe devices Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 05/20] tests/i915/perf: Track variables across i915 and xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 06/20] tests/i915/perf: Skip not ready tests for xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 07/20] tests/i915/perf: Fix i915_perf_revision for use with xe Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 08/20] tests/i915/perf: Fix sysfs functions for xe Ashutosh Dixit
2023-08-08 1:00 ` Ashutosh Dixit [this message]
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 10/20] tests/i915/perf: Support only default_engine_group " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 11/20] tests/i915/perf: Only iterate over render engines " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 12/20] tests/i915/perf: Don't load module Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 13/20] tests/i915/perf: Move test_sysctl_defaults after the fixture Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 14/20] tests/i915/perf: Fix has_class_instance for xe Ashutosh Dixit
2023-08-08 6:35 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 15/20] tests/i915/perf: Temporarily skip render_copy " Ashutosh Dixit
2023-08-08 6:30 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 16/20] tests/i915/perf: Skip intel_ctx_create_all_physical " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 17/20] tests/i915/perf: Skip __for_each_render_engine " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 18/20] tests/i915/perf: Fix buf_map " Ashutosh Dixit
2023-08-08 6:26 ` Zbigniew Kempczyński
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 19/20] tests/i915/perf: Use engine_id in gen12_test_mi_rpc " Ashutosh Dixit
2023-08-08 1:00 ` [igt-dev] [PATCH i-g-t 20/20] HAX: Add OA tests to xe-fast-feedback.testlist Ashutosh Dixit
2023-08-08 2:00 ` [igt-dev] ✓ Fi.CI.BAT: success for Extend i915/perf for testing Xe OA (rev2) Patchwork
2023-08-08 2:02 ` [igt-dev] ○ CI.xeBAT: info " Patchwork
2023-08-08 9:12 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-07-20 23:17 [igt-dev] [PATCH i-g-t 00/20] Extend i915/perf for testing Xe OA Ashutosh Dixit
2023-07-20 23:17 ` [igt-dev] [PATCH i-g-t 09/20] tests/i915/perf: Fix test_i915_ref_count for xe Ashutosh Dixit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230808010017.37819-10-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox