xf86-video-intel: src/intel_module.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Aug 20 04:23:31 PDT 2012


 src/intel_module.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

New commits:
commit b5b76ad849bfda1e75192d1cb3c6c0fcc623bb91
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 20 12:01:39 2012 +0100

    Sanity check that the driver is an i915.ko GEM device before claiming it
    
    This fixes an issue with us claiming Poulsbo and friends even though we
    do not speak their language.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_module.c b/src/intel_module.c
index c0403ca..0a70b24 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -31,6 +31,7 @@
 #include <xf86_OSproc.h>
 #include <xf86Parser.h>
 #include <xf86drmMode.h>
+#include <i915_drm.h>
 
 #include <xorgVersion.h>
 
@@ -369,20 +370,35 @@ static Bool intel_driver_func(ScrnInfoPtr pScrn,
 static Bool has_kernel_mode_setting(struct pci_device *dev)
 {
 	char id[20];
-	int ret;
+	int ret, fd;
 
 	snprintf(id, sizeof(id),
 		 "pci:%04x:%02x:%02x.%d",
 		 dev->domain, dev->bus, dev->dev, dev->func);
 
 	ret = drmCheckModesettingSupported(id);
-	if (ret && xf86LoadKernelModule("i915"))
-		ret = drmCheckModesettingSupported(id);
-	/* Be nice to the user and load fbcon too */
-	if (!ret)
+	if (ret) {
+		if (xf86LoadKernelModule("i915"))
+			ret = drmCheckModesettingSupported(id);
+		if (ret)
+			return FALSE;
+		/* Be nice to the user and load fbcon too */
 		(void)xf86LoadKernelModule("fbcon");
+	}
+
+	/* Confirm that this is a i915.ko device with GEM/KMS enabled */
+	ret = FALSE;
+	fd = drmOpen(NULL, id);
+	if (fd != -1) {
+		struct drm_i915_getparam gp;
+
+		gp.param = I915_PARAM_HAS_GEM;
+		gp.value = &ret;
+		(void)drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		close(fd);
+	}
 
-	return ret == 0;
+	return ret;
 }
 
 extern XF86ConfigPtr xf86configptr;


More information about the xorg-commit mailing list