diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-08-31 13:14:42 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-08-31 14:24:11 +0100 |
commit | 46c35f25d777f7992d87ea44f038035a6eaec2c2 (patch) | |
tree | 6b0528556a35516b93c5e2468817a0d2091d2f1d /lib/intel_chipset.c | |
parent | c7a0b451a9680d8ff1ea13b748f8295937d41399 (diff) |
lib: Stop caching __drm_device_id
In a multi-device system there is no guarantee that the fd being probed
in intel_get_drm_devid() is the same as was opened earlier. Any cache
may outlive the fd, so is frought with lifetime issues. The primary
reason for caching the devid was to avoid extra ioctls in the
dmesg/strace, but hopefully all users now grab the id in their fixture
and not inside every function.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Katarzyna Dec <katarzyna.dec@intel.com>
Reviewed-by: Katarzyna Dec <katarzyna.dec@intel.com>
Diffstat (limited to 'lib/intel_chipset.c')
-rw-r--r-- | lib/intel_chipset.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/intel_chipset.c b/lib/intel_chipset.c index ab35fa70..4748a3fb 100644 --- a/lib/intel_chipset.c +++ b/lib/intel_chipset.c @@ -112,8 +112,6 @@ intel_get_pci_device(void) return pci_dev; } -extern uint16_t __drm_device_id; - /** * intel_get_drm_devid: * @fd: open i915 drm file descriptor @@ -127,16 +125,22 @@ extern uint16_t __drm_device_id; uint32_t intel_get_drm_devid(int fd) { + struct drm_i915_getparam gp; const char *override; + int devid = 0; igt_assert(is_i915_device(fd)); - igt_assert(__drm_device_id); override = getenv("INTEL_DEVID_OVERRIDE"); if (override) return strtol(override, NULL, 0); - else - return __drm_device_id; + + memset(&gp, 0, sizeof(gp)); + gp.param = I915_PARAM_CHIPSET_ID; + gp.value = &devid; + ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp)); + + return devid; } /** |