Commit 023d7b42 authored by Michał Winiarski's avatar Michał Winiarski

lib: Kill drm_get_card()

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's avatarMichał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>
parent bdf280f8
......@@ -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, "");
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment