xserver: Branch 'server-1.14-branch' - 5 commits

Matt Dew marcoz at kemper.freedesktop.org
Thu May 23 14:16:09 PDT 2013


 hw/xfree86/common/xf86.h                   |    1 
 hw/xfree86/common/xf86Events.c             |   15 +++++++++
 hw/xfree86/common/xf86Init.c               |    2 -
 hw/xfree86/common/xf86Xinput.c             |    2 -
 hw/xfree86/common/xf86platformBus.c        |   19 ++++++++++++
 hw/xfree86/common/xf86platformBus.h        |    4 ++
 hw/xfree86/modes/xf86Crtc.c                |    5 +--
 hw/xfree86/os-support/linux/lnx_platform.c |   45 +++++++++++++++++++++++++----
 hw/xfree86/os-support/solaris/sun_init.c   |    2 -
 hw/xfree86/os-support/xf86_OSproc.h        |    3 +
 include/hotplug.h                          |    1 
 11 files changed, 88 insertions(+), 11 deletions(-)

New commits:
commit 348de79d8c3993577912c7aaf891b7ae702ad32d
Merge: a11cf8d c760fb0
Author: Matt Dew <marcoz at osource.org>
Date:   Thu May 23 14:49:33 2013 -0600

    Merge commit 'c760fb0154848d47438908ba8b3da2fffc68a460' into server-1.14-branch

diff --cc hw/xfree86/os-support/linux/lnx_platform.c
index 2bc8214,21768ee..d751f59
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@@ -116,9 -137,18 +137,17 @@@ xf86PlatformDeviceProbe(struct OdevAttr
      if (i != xf86_num_platform_devices)
          goto out_free;
  
 -    LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n",
 -               path);
 +    LogMessage(X_INFO, "xfree86: Adding drm device (%s)\n", path);
  
-     ret = get_drm_info(attribs, path);
+     if (!xf86VTOwner()) {
+             /* if we don't currently own the VT then don't probe the device,
+                just mark it as unowned for later use */
+             attribs->unowned = TRUE;
+             xf86_add_platform_device(attribs);
+             return;
+     }
+ 
+     ret = get_drm_info(attribs, path, -1);
      if (ret == FALSE)
          goto out_free;
  
commit c760fb0154848d47438908ba8b3da2fffc68a460
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 10 03:26:33 2013 +0000

    hw/xfree86: Only report SetDesiredModes() failed if at least one modeset fails
    
    commit 6703a7c7cf1a349c137e247a0c8eb462ff7b07be
    Author: Keith Packard <keithp at keithp.com>
    Date:   Tue Jan 8 20:24:32 2013 -0800
    
        hw/xfree86: Require only one working CRTC to start the server.
    
    changed the logic to try to set the mode on all connected outputs rather
    than abort upon the first failure. The return error code was then
    tweaked such that it reported success if it set a mode on any crtc.
    However, this confuses the headless case where we never enable any crtcs
    and also, importantly, never fail to set a crtc.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=59190
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Also-written-by: Maarten Lankhorst <maarten.lankhorst at canonical.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 451ba4bd41b82acd4aec6236ba121e00cfeb311b)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index f9ae465..7d55f60 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2598,8 +2598,8 @@ xf86SetDesiredModes(ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
     xf86CrtcPtr crtc = config->crtc[0];
+    int enabled = 0, failed = 0;
     int c;
-    int enabled = 0;
 
     /* A driver with this hook will take care of this */
     if (!crtc->funcs->set_mode_major) {
@@ -2659,11 +2659,12 @@ xf86SetDesiredModes(ScrnInfoPtr scrn)
                 if (config->output[o]->crtc == crtc)
                     config->output[o]->crtc = NULL;
             crtc->enabled = FALSE;
+            ++failed;
 	}
     }
 
     xf86DisableUnusedFunctions(scrn);
-    return enabled != 0;
+    return enabled != 0 || failed == 0;
 }
 
 /**
commit 5c296c32d9486201c0fbb51e905dd3f8542c4d88
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 10 16:32:15 2013 +1000

    xf86: don't hotplug output devices while VT switched.
    
    We don't want to hotplug output devices while we are VT switched,
    as we get races between multiple X servers on the device open, and
    drm device master status. This just queues device opens until we return
    from VT switch.
    
    Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    (cherry picked from commit 22cab8a28a433d03a4e6ba97f9a160271d73cb52)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 44c4d4a..7a35250 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -84,6 +84,7 @@
 #include "dpmsproc.h"
 #endif
 
+#include "xf86platformBus.h"
 /*
  * This is a toggling variable:
  *  FALSE = No VT switching keys have been pressed last time around
@@ -561,6 +562,9 @@ xf86VTSwitch(void)
         for (ih = InputHandlers; ih; ih = ih->next)
             xf86EnableInputHandler(ih);
 
+        /* check for any new output devices */
+        xf86platformVTProbe();
+
         OsReleaseSIGIO();
     }
 }
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 5866333..9034dad 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -113,6 +113,11 @@ xf86_get_platform_device_attrib(struct xf86_platform_device *device, int attrib_
     return NULL;
 }
 
+Bool
+xf86_get_platform_device_unowned(int index)
+{
+    return xf86_platform_devices[index].attribs->unowned;
+}
 
 /*
  * xf86IsPrimaryPlatform() -- return TRUE if primary device
@@ -498,4 +503,18 @@ xf86platformRemoveDevice(int index)
  out:
     return;
 }
+
+/* called on return from VT switch to find any new devices */
+void xf86platformVTProbe(void)
+{
+    int i;
+
+    for (i = 0; i < xf86_num_platform_devices; i++) {
+        if (xf86_platform_devices[i].attribs->unowned == FALSE)
+            continue;
+
+        xf86_platform_devices[i].attribs->unowned = FALSE;
+        xf86PlatformReprobeDevice(i, xf86_platform_devices[i].attribs);
+    }
+}
 #endif
diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h
index 49afc24..4e17578 100644
--- a/hw/xfree86/common/xf86platformBus.h
+++ b/hw/xfree86/common/xf86platformBus.h
@@ -46,6 +46,8 @@ extern int
 xf86_remove_platform_device(int dev_index);
 extern Bool
 xf86_add_platform_device_attrib(int index, int attrib_id, char *attrib_str);
+extern Bool
+xf86_get_platform_device_unowned(int index);
 
 extern int
 xf86platformAddDevice(int index);
@@ -59,6 +61,8 @@ xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *bu
 
 extern _X_EXPORT int
 xf86PlatformMatchDriver(char *matches[], int nmatches);
+
+extern void xf86platformVTProbe(void);
 #endif
 
 #endif
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index 76f5583..21768ee 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -18,7 +18,7 @@
 #include "hotplug.h"
 
 static Bool
-get_drm_info(struct OdevAttributes *attribs, char *path)
+get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
 {
     drmSetVersion sv;
     char *buf;
@@ -37,10 +37,14 @@ get_drm_info(struct OdevAttributes *attribs, char *path)
         return FALSE;
     }
 
-    xf86_add_platform_device(attribs);
+    /* for a delayed probe we've already added the device */
+    if (delayed_index == -1) {
+            xf86_add_platform_device(attribs);
+            delayed_index = xf86_num_platform_devices - 1;
+    }
 
     buf = drmGetBusid(fd);
-    xf86_add_platform_device_attrib(xf86_num_platform_devices - 1,
+    xf86_add_platform_device_attrib(delayed_index,
                                     ODEV_ATTRIB_BUSID, buf);
     drmFreeBusid(buf);
     close(fd);
@@ -89,6 +93,23 @@ xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *bu
 }
 
 void
+xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs)
+{
+    Bool ret;
+    char *dpath;
+    dpath = xf86_get_platform_attrib(index, ODEV_ATTRIB_PATH);
+
+    ret = get_drm_info(attribs, dpath, index);
+    if (ret == FALSE) {
+        xf86_remove_platform_device(index);
+        return;
+    }
+    ret = xf86platformAddDevice(index);
+    if (ret == -1)
+        xf86_remove_platform_device(index);
+}
+
+void
 xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
 {
     struct OdevAttribute *attrib;
@@ -119,7 +140,15 @@ xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
     LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n",
                path);
 
-    ret = get_drm_info(attribs, path);
+    if (!xf86VTOwner()) {
+            /* if we don't currently own the VT then don't probe the device,
+               just mark it as unowned for later use */
+            attribs->unowned = TRUE;
+            xf86_add_platform_device(attribs);
+            return;
+    }
+
+    ret = get_drm_info(attribs, path, -1);
     if (ret == FALSE)
         goto out_free;
 
@@ -138,6 +167,9 @@ void NewGPUDeviceRequest(struct OdevAttributes *attribs)
     if (old_num == xf86_num_platform_devices)
         return;
 
+    if (xf86_get_platform_device_unowned(xf86_num_platform_devices - 1) == TRUE)
+        return;
+
     ret = xf86platformAddDevice(xf86_num_platform_devices-1);
     if (ret == -1)
         xf86_remove_platform_device(xf86_num_platform_devices-1);
@@ -171,7 +203,10 @@ void DeleteGPUDeviceRequest(struct OdevAttributes *attribs)
 
     ErrorF("xf86: remove device %d %s\n", index, syspath);
 
-    xf86platformRemoveDevice(index);
+    if (xf86_get_platform_device_unowned(index) == TRUE)
+            xf86_remove_platform_device(index);
+    else
+            xf86platformRemoveDevice(index);
 out:
     config_odev_free_attribute_list(attribs);
 }
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index ea2b16e..6be5946 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -223,6 +223,9 @@ extern _X_EXPORT void xf86InitVidMem(void);
 #include "hotplug.h"
 void
 xf86PlatformDeviceProbe(struct OdevAttributes *attribs);
+
+void
+xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs);
 #endif
 
 _XFUNCPROTOEND
diff --git a/include/hotplug.h b/include/hotplug.h
index 2a95b45..29a22c4 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -40,6 +40,7 @@ struct OdevAttribute {
 
 struct OdevAttributes {
     struct xorg_list list;
+    Bool unowned;
 };
 
 struct OdevAttributes *
commit 39ce034505b6526b5c945a6f44a34e020a22d187
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 10 16:32:11 2013 +1000

    xf86: use new xf86VTOwner interface in a few places
    
    This replaces some previous uses of direct xf86Screens[0] accesses.
    
    Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
    Signed-off-by: Dave Airlie <airlied at gmail.com>
    (cherry picked from commit 5b359cf6135ca173d8f65cb92926332f07f91efe)

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 052f9d6..44c4d4a 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -428,7 +428,7 @@ xf86VTSwitch(void)
      * Since all screens are currently all in the same state it is sufficient
      * check the first.  This might change in future.
      */
-    if (xf86Screens[0]->vtSema) {
+    if (xf86VTOwner()) {
 
         DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
                BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 1695dbf..91ec4c8 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -819,7 +819,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
     if (serverGeneration != 1) {
         xf86Resetting = TRUE;
         /* All screens are in the same state, so just check the first */
-        if (!xf86Screens[0]->vtSema) {
+        if (!xf86VTOwner()) {
 #ifdef HAS_USL_VTS
             ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
 #endif
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index bee407b..26c03c6 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -870,7 +870,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
     }
 
     /* Enable it if it's properly initialised and we're currently in the VT */
-    if (enable && dev->inited && dev->startup && xf86Screens[0]->vtSema) {
+    if (enable && dev->inited && dev->startup && xf86VTOwner()) {
         OsBlockSignals();
         EnableDevice(dev, TRUE);
         if (!dev->enabled) {
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 4b75a98..68527a5 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -274,7 +274,7 @@ xf86OpenConsole(void)
              * this is to make sure we don't continue until the activate
              * signal is received.
              */
-            if (!xf86Screens[0]->vtSema)
+            if (!xf86VTOwner())
                 sleep(5);
         }
 #endif                          /* HAS_USL_VTS */
commit 92135056375fe9a2b637487dd4a9274ab6dd338d
Author: Dave Airlie <airlied at gmail.com>
Date:   Wed Apr 10 16:32:02 2013 +1000

    xfree86: add VT owner interface
    
    This is just a simple interface to avoid accessing x86Screens[0]
    directly.
    
    Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
    Signed-off-by: Dave Airlie <airlied at gmail.com>
    (cherry picked from commit d61ea1f64db45201c1a2b39c39293c5768d98092)

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 1514c26..828d958 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -243,6 +243,7 @@ extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler) (void));
 extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
 extern _X_EXPORT void xf86ProcessActionEvent(ActionEvent action, void *arg);
 extern _X_EXPORT void xf86PrintBacktrace(void);
+extern _X_EXPORT Bool xf86VTOwner(void);
 
 /* xf86Helper.c */
 
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index d92174e..052f9d6 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -769,3 +769,12 @@ DDXRingBell(int volume, int pitch, int duration)
 {
     xf86OSRingBell(volume, pitch, duration);
 }
+
+Bool
+xf86VTOwner(void)
+{
+    /* at system startup xf86Screens[0] won't be set - but we will own the VT */
+    if (xf86NumScreens == 0)
+	return TRUE;
+    return xf86Screens[0]->vtSema;
+}


More information about the xorg-commit mailing list