[PATCH] Preload kernel module before checking if KMS is supported.

Pauli Nieminen suokkos at gmail.com
Tue Feb 9 09:31:11 PST 2010


---
 src/radeon_probe.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/radeon_probe.c b/src/radeon_probe.c
index 42e7259..08e5818 100644
--- a/src/radeon_probe.c
+++ b/src/radeon_probe.c
@@ -31,6 +31,8 @@
 #endif
 
 #include <string.h>
+#include <errno.h>
+#include <unistd.h>
 
 /*
  * Authors:
@@ -87,6 +89,41 @@ RADEONIdentify(int flags)
 
 
 #ifdef XF86DRM_MODE
+static Bool radeon_check_kernel_module_is_loaded(ScrnInfoPtr pScrn, char *busIdString)
+{
+    drmSetVersion saveSv, sv;
+    int fd = -1, err;
+    int count = 10;
+
+    sv.drm_di_major = 1;
+    sv.drm_di_minor = 1;
+    sv.drm_dd_major = -1;
+
+    saveSv = sv;
+    while (count--) {
+	fd = drmOpen(RADEON_DRIVER_NAME, busIdString);
+
+	if (fd < 0) {
+	    xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 0,
+			    "[KMS] drmOpen failed.\n");
+	    return FALSE;
+	}
+
+	err = drmSetInterfaceVersion(fd, &sv);
+
+	if (err != -EPERM)
+	    break;
+
+	sv = saveSv;
+	drmClose(fd);
+	fd = -1;
+	usleep(100000);
+    }
+    drmClose(fd);
+
+    return fd != -1 ? TRUE : FALSE;
+}
+
 static Bool radeon_kernel_mode_enabled(ScrnInfoPtr pScrn, struct pci_device *pci_dev)
 {
     char *busIdString;
@@ -99,6 +136,12 @@ static Bool radeon_kernel_mode_enabled(ScrnInfoPtr pScrn, struct pci_device *pci
     }
 
     busIdString = DRICreatePCIBusID(pci_dev);
+
+    if (!radeon_check_kernel_module_is_loaded(pScrn, busIdString)) {
+      xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
+		   "[KMS] drm kernel module is not loaded, no kernel modesetting.\n");
+	return FALSE;
+    }
     ret = drmCheckModesettingSupported(busIdString);
     xfree(busIdString);
     if (ret) {
-- 
1.6.3.3



More information about the xorg-driver-ati mailing list