From eaa7e6183cedee10acfa321ac3c66bfe58c0ed5a Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 18 Feb 2015 15:58:06 +0000 Subject: lib: Cache DRM device id to reduce number of ioctls The DRM device id for the igfx is fixed, since there can only be one in the system. So once we query it for the first time we can safely report that value on every subsequent request, cutting out a lot of noisy ioctls from inside tests. Signed-off-by: Chris Wilson --- lib/drmtest.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/drmtest.c') diff --git a/lib/drmtest.c b/lib/drmtest.c index 1d6e882c..ee5c1232 100644 --- a/lib/drmtest.c +++ b/lib/drmtest.c @@ -73,6 +73,8 @@ * and [batchbuffer](intel-gpu-tools-intel-batchbuffer.html) libraries as dependencies. */ +uint16_t __drm_device_id; + static int is_i915_device(int fd) { drm_version_t version; @@ -101,7 +103,11 @@ is_intel(int fd) if (ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp))) return 0; - return IS_INTEL(devid); + if (!IS_INTEL(devid)) + return 0; + + __drm_device_id = devid; + return 1; } static void check_stop_rings(void) -- cgit v1.2.3