Commit 46c35f25 authored by Chris Wilson's avatar Chris Wilson 😣

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's avatarChris Wilson <>
Cc: Katarzyna Dec <>
Reviewed-by: Katarzyna Dec's avatarKatarzyna Dec <>
parent c7a0b451
......@@ -75,8 +75,6 @@
* and [batchbuffer](igt-gpu-tools-intel-batchbuffer.html) libraries as dependencies.
uint16_t __drm_device_id;
static int __get_drm_device_name(int fd, char *name)
drm_version_t version;
......@@ -142,7 +140,6 @@ static bool has_known_intel_chipset(int fd)
if (!intel_gen(devid))
return false;
__drm_device_id = devid;
return true;
......@@ -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;
intel_get_drm_devid(int fd)
struct drm_i915_getparam gp;
const char *override;
int devid = 0;
override = getenv("INTEL_DEVID_OVERRIDE");
if (override)
return strtol(override, NULL, 0);
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;
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