[igt-dev] [PATCH i-g-t v2 5/8] lib: Kill drm_get_card()
Michał Winiarski
michal.winiarski at intel.com
Wed Mar 13 17:38:18 UTC 2019
It's not operating on FD, and we've provided a nice reimplementation
that does. Let's use it instead.
Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
---
lib/drmtest.c | 40 -------------------------------------
lib/drmtest.h | 1 -
tests/i915/i915_suspend.c | 17 ++++++++--------
tools/intel_gpu_frequency.c | 9 ++++++---
4 files changed, 15 insertions(+), 52 deletions(-)
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 6506791b..25eeab88 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -177,46 +177,6 @@ void gem_quiescent_gpu(int fd)
DROP_ACTIVE | DROP_RETIRE | DROP_IDLE | DROP_FREED);
}
-/**
- * drm_get_card:
- *
- * Get an i915 drm card index number for use in /dev or /sys. The minor index of
- * the legacy node is returned, not of the control or render node.
- *
- * Returns:
- * The i915 drm index or -1 on error
- */
-int drm_get_card(void)
-{
- char *name;
- int i, fd;
-
- for (i = 0; i < 16; i++) {
- int ret;
-
- ret = asprintf(&name, "/dev/dri/card%u", i);
- igt_assert(ret != -1);
-
- fd = open(name, O_RDWR);
- free(name);
-
- if (fd == -1)
- continue;
-
- if (!is_i915_device(fd) || !has_known_intel_chipset(fd)) {
- close(fd);
- continue;
- }
-
- close(fd);
- return i;
- }
-
- igt_skip("No intel gpu found\n");
-
- return -1;
-}
-
static int modprobe(const char *driver)
{
return igt_kmod_load(driver, "");
diff --git a/lib/drmtest.h b/lib/drmtest.h
index ca347a71..f4401ac9 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -71,7 +71,6 @@ void __set_forced_driver(const char *name);
*/
#define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1))
-int drm_get_card(void);
int drm_open_driver(int chipset);
int drm_open_driver_master(int chipset);
int drm_open_driver_render(int chipset);
diff --git a/tests/i915/i915_suspend.c b/tests/i915/i915_suspend.c
index cd7cf967..0d49fdcb 100644
--- a/tests/i915/i915_suspend.c
+++ b/tests/i915/i915_suspend.c
@@ -39,6 +39,7 @@
#include <drm.h>
+#include "igt_device.h"
#define OBJECT_SIZE (16*1024*1024)
@@ -101,7 +102,7 @@ test_fence_restore(int fd, bool tiled2untiled, bool hibernate)
}
static void
-test_debugfs_reader(bool hibernate)
+test_debugfs_reader(int fd, bool hibernate)
{
struct igt_helper_process reader = {};
reader.use_SIGKILL = true;
@@ -112,7 +113,7 @@ test_debugfs_reader(bool hibernate)
snprintf(tmp, sizeof(tmp) - 1,
"while true; do find %s/%i/ -type f ! -path \"*/crc/*\" | xargs cat > /dev/null 2>&1; done",
- dfs_base, drm_get_card());
+ dfs_base, igt_device_get_card_index(fd));
igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
}
@@ -131,7 +132,7 @@ test_debugfs_reader(bool hibernate)
}
static void
-test_sysfs_reader(bool hibernate)
+test_sysfs_reader(int fd, bool hibernate)
{
struct igt_helper_process reader = {};
reader.use_SIGKILL = true;
@@ -142,7 +143,7 @@ test_sysfs_reader(bool hibernate)
snprintf(tmp, sizeof(tmp) - 1,
"while true; do find %s%i*/ -type f | xargs cat > /dev/null 2>&1; done",
- dfs_base, drm_get_card());
+ dfs_base, igt_device_get_card_index(fd));
igt_assert(execl("/bin/sh", "sh", "-c", tmp, (char *) NULL) != -1);
}
@@ -212,10 +213,10 @@ igt_main
test_fence_restore(fd, false, false);
igt_subtest("debugfs-reader")
- test_debugfs_reader(false);
+ test_debugfs_reader(fd, false);
igt_subtest("sysfs-reader")
- test_sysfs_reader(false);
+ test_sysfs_reader(fd, false);
igt_subtest("shrink")
test_shrink(fd, SUSPEND_STATE_MEM);
@@ -230,10 +231,10 @@ igt_main
test_fence_restore(fd, false, true);
igt_subtest("debugfs-reader-hibernate")
- test_debugfs_reader(true);
+ test_debugfs_reader(fd, true);
igt_subtest("sysfs-reader-hibernate")
- test_sysfs_reader(true);
+ test_sysfs_reader(fd, true);
igt_subtest("forcewake-hibernate")
test_forcewake(fd, true);
diff --git a/tools/intel_gpu_frequency.c b/tools/intel_gpu_frequency.c
index 80786ad9..52b11a98 100644
--- a/tools/intel_gpu_frequency.c
+++ b/tools/intel_gpu_frequency.c
@@ -28,6 +28,7 @@
#include <unistd.h>
#include "drmtest.h"
+#include "igt_device.h"
#include "intel_chipset.h"
#define VERSION "1.0"
@@ -280,10 +281,12 @@ int main(int argc, char *argv[])
{
bool write, fail, targets[MAX+1] = {false};
- int i, try = 1, set_freq[MAX+1] = {0};
+ int i, fd, try = 1, set_freq[MAX+1] = {0};
- devid = intel_get_drm_devid(drm_open_driver(DRIVER_INTEL));
- device = drm_get_card();
+ fd = drm_open_driver(DRIVER_INTEL);
+ devid = intel_get_drm_devid(fd);
+ device = igt_device_get_card_index(fd);
+ close(fd);
write = parse(argc, argv, targets, ARRAY_SIZE(targets), set_freq);
fail = write;
--
2.20.1
More information about the igt-dev
mailing list