[igt-dev] [PATCH i-g-t v2 3/8] tests/i915_pm_rps: Use sysfs helpers

Michał Winiarski michal.winiarski at intel.com
Wed Mar 13 17:38:16 UTC 2019


Doing this lets us avoid drm_get_card, which we plan to remove
eventually.

Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
 tests/i915/i915_pm_rps.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/i915/i915_pm_rps.c b/tests/i915/i915_pm_rps.c
index d20cd2d8..41dc9bbb 100644
--- a/tests/i915/i915_pm_rps.c
+++ b/tests/i915/i915_pm_rps.c
@@ -38,12 +38,12 @@
 
 #include "igt.h"
 #include "igt_dummyload.h"
+#include "igt_sysfs.h"
 
 IGT_TEST_DESCRIPTION("Render P-States tests - verify GPU frequency changes");
 
 static int drm_fd;
 
-static const char sysfs_base_path[] = "/sys/class/drm/card%d/gt_%s_freq_mhz";
 enum {
 	CUR,
 	MIN,
@@ -629,20 +629,23 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
-		const int device = drm_get_card();
 		struct sysfs_file *sysfs_file = sysfs_files;
+		char sysfs_path[80];
 		int ret;
 
 		/* Use drm_open_driver to verify device existence */
 		drm_fd = drm_open_driver(DRIVER_INTEL);
 		igt_require_gem(drm_fd);
 		igt_require(gem_can_store_dword(drm_fd, 0));
+		igt_assert(igt_sysfs_path(drm_fd, sysfs_path,
+					  sizeof(sysfs_path), NULL));
 
 		do {
 			int val = -1;
 			char *path;
 
-			ret = asprintf(&path, sysfs_base_path, device, sysfs_file->name);
+			ret = asprintf(&path, "gt_%s_freq_mhz",
+				       sysfs_file->name);
 			igt_assert(ret != -1);
 			sysfs_file->filp = fopen(path, sysfs_file->mode);
 			igt_require(sysfs_file->filp);
-- 
2.20.1



More information about the igt-dev mailing list