[RFC] modesetting: Add workaround for platform devices and buggy xserver

Rob Clark robdclark at gmail.com
Mon Jun 16 08:05:52 PDT 2014


If the xserver does not have a bug fix for a problem with auto-loading
true platform devices, then work around the issue by failing the
platformProbe().  This way the user can at least still load the driver
with a custom .conf file.

---
 src/driver.c | 37 ++++++++++++++++++++++++++++++++++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/driver.c b/src/driver.c
index cc526f6..3e2d2c2 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -136,6 +136,8 @@ static const OptionInfoRec Options[] = {
 
 int modesettingEntityIndex = -1;
 
+static Bool supports_non_pci_platform_devs = FALSE;
+
 static MODULESETUPPROTO(Setup);
 
 static XF86ModuleVersionInfo VersRec = {
@@ -213,11 +215,33 @@ static int check_outputs(int fd)
     return ret;
 }
 
-static Bool probe_hw(char *dev)
+static Bool probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
 {
     int fd = open_hw(dev);
     if (fd != -1) {
         int ret = check_outputs(fd);
+        /* if called in platformProbe path, and server does not
+         * supports_non_pci_platform_devs then we need to reject
+         * and fallback to old probe.   Otherwise things won't
+         * even work if user has a .conf file, thanks to autoAddGPU
+         * loop.
+         */
+        if (platform_dev && !supports_non_pci_platform_devs) {
+            drmSetVersion sv;
+            char *busid;
+
+            sv.drm_di_major = 1;
+            sv.drm_di_minor = 4;
+            sv.drm_dd_major = -1;       /* Don't care */
+            sv.drm_dd_minor = -1;       /* Don't care */
+
+            drmSetInterfaceVersion(fd, &sv);
+
+            busid = drmGetBusid(fd);
+            if (busid && !strncmp(busid, "platform:", 9))
+                ret = FALSE;
+            drmFreeBusid(busid);
+        }
         close(fd);
         return ret;
     }
@@ -273,6 +297,10 @@ AvailableOptions(int chipid, int busid)
     return Options;
 }
 
+#if 1 /* XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(???) */
+#  define SERVER_SUPPORTS_NON_PCI_PLATFORM_DEVS 12
+#endif
+
 static Bool
 ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
 {
@@ -283,6 +311,9 @@ ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
 	    flag = (CARD32 *)data;
 	    (*flag) = 0;
 	    return TRUE;
+        case SERVER_SUPPORTS_NON_PCI_PLATFORM_DEVS:
+            supports_non_pci_platform_devs = TRUE;
+            return TRUE;
 	default:
 	    return FALSE;
     }
@@ -341,7 +372,7 @@ ms_platform_probe(DriverPtr driver,
     if (flags & PLATFORM_PROBE_GPU_SCREEN)
             scr_flags = XF86_ALLOCATE_GPU_SCREEN;
 
-    if (probe_hw(path)) {
+    if (probe_hw(path, dev)) {
         scrn = xf86AllocateScreen(driver, scr_flags);
         xf86AddEntityToScreen(scrn, entity_num);
 
@@ -387,7 +418,7 @@ Probe(DriverPtr drv, int flags)
     for (i = 0; i < numDevSections; i++) {
 
 	dev = xf86FindOptionValue(devSections[i]->options,"kmsdev");
-	if (probe_hw(dev)) {
+	if (probe_hw(dev, NULL)) {
 	    int entity;
 	    entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
 	    scrn = xf86ConfigFbEntity(scrn, 0, entity,
-- 
1.9.3



More information about the xorg-devel mailing list