[Intel-gfx] [PATCH] Check that the drm fd is i915 before calling i915 ioctls on it

Adam Jackson ajax at redhat.com
Mon Aug 20 18:27:14 CEST 2012


Signed-off-by: Adam Jackson <ajax at redhat.com>
---
 src/intel_module.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/intel_module.c b/src/intel_module.c
index edea48d..be9688a 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -392,11 +392,17 @@ static Bool has_kernel_mode_setting(struct pci_device *dev)
 	ret = FALSE;
 	fd = drmOpen(NULL, id);
 	if (fd != -1) {
-		struct drm_i915_getparam gp;
+		drmVersionPtr v;
 
-		gp.param = I915_PARAM_HAS_GEM;
-		gp.value = &ret;
-		(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		v = drmGetVersion(fd);
+		if (v && !strcmp(v->name, "i915")) {
+			struct drm_i915_getparam gp;
+
+			gp.param = I915_PARAM_HAS_GEM;
+			gp.value = &ret;
+			(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp);
+		}
+		drmFreeVersion(v);
 		close(fd);
 	}
 
-- 
1.7.7.6




More information about the Intel-gfx mailing list