xserver: Branch 'master' - 3 commits

Peter Hutterer whot at kemper.freedesktop.org
Wed Oct 26 05:35:38 UTC 2016


 Xi/stubs.c                     |   14 ++++++++
 config/config.c                |    2 +
 hw/dmx/dmxinput.c              |    5 +++
 hw/kdrive/src/kinput.c         |    5 +++
 hw/xfree86/common/xf86Xinput.c |   64 ++++++++++++++++++++++++++---------------
 hw/xquartz/darwinXinput.c      |   15 +++++++++
 include/input.h                |    1 
 7 files changed, 84 insertions(+), 22 deletions(-)

New commits:
commit d13cb974426f7f1110b0bdb08c4ebb46ff8975f7
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 21 06:27:57 2016 +1000

    ddx: add new call to purge input devices that weren't added
    
    Special case for the systemd-logind case in xfree86: when we're vt-switched
    away and a device is plugged in, we get a paused fd from logind. Since we
    can't probe the device or do anything with it, we store that device in the
    xfree86 and handle it later when we vt-switch back. The device is not added to
    inputInfo.devices until that time.
    
    When the device is removed while still vt-switched away, the the config system
    never notifies the DDX. It only runs through inputInfo.devices and our device
    was never added to that.
    
    When a device is plugged in, removed, and plugged in again while vt-switched
    away, we have two entries in the xfree86-specific list that refer to the same
    device node, both pending for addition later. On VT switch back, the first one
    (the already removed one) will be added successfully, the second one (the
    still plugged-in one) fails. Since the fd is correct, the device works until
    it is removed again. The removed devices' config_info (i.e. the syspath)
    doesn't match the actual device we addded tough (the input number increases
    with each plug), it doesn't get removed, the fd remains open and we lose track
    of the fd count. Plugging the device in again leads to a dead device.
    
    Fix this by adding a call to notify the DDX to purge any remainders of devices
    with the given config_info, that's the only identifiable bit we have at this
    point.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=97928
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 39bee7c..27848a2 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -143,3 +143,17 @@ DeleteInputDeviceRequest(DeviceIntPtr dev)
 {
     RemoveDevice(dev, TRUE);
 }
+
+/****************************************************************************
+ *
+ * Caller: configRemoveDevice (and others)
+ *
+ * Remove any traces of the input device specified in config_info.
+ * This is only necessary if the ddx keeps information around beyond
+ * the NewInputDeviceRequest/DeleteInputDeviceRequest
+ *
+ */
+void
+RemoveInputDeviceTraces(const char *config_info)
+{
+}
diff --git a/config/config.c b/config/config.c
index 1fb368c..fb60295 100644
--- a/config/config.c
+++ b/config/config.c
@@ -107,6 +107,8 @@ remove_devices(const char *backend, const char *config_info)
         if (dev->config_info && strcmp(dev->config_info, config_info) == 0)
             remove_device(backend, dev);
     }
+
+    RemoveInputDeviceTraces(config_info);
 }
 
 BOOL
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index 4ccb439..d201034 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -123,3 +123,8 @@ void
 DeleteInputDeviceRequest(DeviceIntPtr pDev)
 {
 }
+
+void
+RemoveInputDeviceTraces(const char *config_info)
+{
+}
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 2c39624..8b08747 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2302,3 +2302,8 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
 {
     RemoveDevice(pDev, TRUE);
 }
+
+void
+RemoveInputDeviceTraces(const char *config_info)
+{
+}
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 0095272..39de498 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1119,6 +1119,21 @@ DeleteInputDeviceRequest(DeviceIntPtr pDev)
     input_unlock();
 }
 
+void
+RemoveInputDeviceTraces(const char *config_info)
+{
+    PausedInputDevicePtr d, tmp;
+
+    xorg_list_for_each_entry_safe(d, tmp, &new_input_devices_list, node) {
+        const char *ci = xf86findOptionValue(d->pInfo->options, "config_info");
+        if (!ci || strcmp(ci, config_info) != 0)
+            continue;
+
+        xorg_list_del(&d->node);
+        free(d);
+    }
+}
+
 /*
  * convenient functions to post events
  */
diff --git a/hw/xquartz/darwinXinput.c b/hw/xquartz/darwinXinput.c
index 3efaa2c..fea7e92 100644
--- a/hw/xquartz/darwinXinput.c
+++ b/hw/xquartz/darwinXinput.c
@@ -147,3 +147,18 @@ DeleteInputDeviceRequest(DeviceIntPtr dev)
 {
     DEBUG_LOG("DeleteInputDeviceRequest(%p)\n", dev);
 }
+
+/****************************************************************************
+ *
+ * Caller: configRemoveDevice (and others)
+ *
+ * Remove any traces of the input device specified in config_info.
+ * This is only necessary if the ddx keeps information around beyond
+ * the NewInputDeviceRequest/DeleteInputDeviceRequest
+ *
+ */
+void
+RemoveInputDeviceTraces(const char *config_info)
+{
+    DEBUG_LOG("RemoveInputDeviceTraces(%s)\n", config_info);
+}
diff --git a/include/input.h b/include/input.h
index c7b1e91..bb58b22 100644
--- a/include/input.h
+++ b/include/input.h
@@ -635,6 +635,7 @@ extern _X_EXPORT int NewInputDeviceRequest(InputOption *options,
                                            InputAttributes * attrs,
                                            DeviceIntPtr *dev);
 extern _X_EXPORT void DeleteInputDeviceRequest(DeviceIntPtr dev);
+extern _X_EXPORT void RemoveInputDeviceTraces(const char *config_info);
 
 extern _X_EXPORT void DDXRingBell(int volume, int pitch, int duration);
 
commit 8fcf2fa78f09257933b17e7dc9a03a2034e3076f
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 20 15:45:46 2016 +1000

    xfree86: swap the list of paused devices to an xorg_list
    
    No functional changes but it makes it easier to remove elements from the
    middle of the list (future patch).
    
    We don't have an init call into this file, so the list is manually
    initialized.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index e31aab3..0095272 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -110,8 +110,16 @@
 static int
  xf86InputDevicePostInit(DeviceIntPtr dev);
 
-static InputInfoPtr *new_input_devices;
-static int new_input_devices_count;
+typedef struct {
+    struct xorg_list node;
+    InputInfoPtr pInfo;
+} PausedInputDeviceRec;
+typedef PausedInputDeviceRec *PausedInputDevicePtr;
+
+static struct xorg_list new_input_devices_list = {
+    .next = &new_input_devices_list,
+    .prev = &new_input_devices_list,
+};
 
 /**
  * Eval config and modify DeviceVelocityRec accordingly
@@ -907,11 +915,10 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
         if (fd != -1) {
             if (paused) {
                 /* Put on new_input_devices list for delayed probe */
-                new_input_devices = xnfreallocarray(new_input_devices,
-                                                    new_input_devices_count + 1,
-                                                    sizeof(pInfo));
-                new_input_devices[new_input_devices_count] = pInfo;
-                new_input_devices_count++;
+                PausedInputDevicePtr new_device = xnfalloc(sizeof *new_device);
+                new_device->pInfo = pInfo;
+
+                xorg_list_append(&new_device->node, &new_input_devices_list);
                 systemd_logind_release_fd(pInfo->major, pInfo->minor, fd);
                 free(path);
                 return BadMatch;
@@ -1540,11 +1547,12 @@ xf86PostTouchEvent(DeviceIntPtr dev, uint32_t touchid, uint16_t type,
 void
 xf86InputEnableVTProbe(void)
 {
-    int i, is_auto = 0;
+    int is_auto = 0;
     DeviceIntPtr pdev;
+    PausedInputDevicePtr d, tmp;
 
-    for (i = 0; i < new_input_devices_count; i++) {
-        InputInfoPtr pInfo = new_input_devices[i];
+    xorg_list_for_each_entry_safe(d, tmp, &new_input_devices_list, node) {
+        InputInfoPtr pInfo = d->pInfo;
         const char *value = xf86findOptionValue(pInfo->options, "_source");
 
         is_auto = 0;
@@ -1557,8 +1565,9 @@ xf86InputEnableVTProbe(void)
         xf86NewInputDevice(pInfo, &pdev,
                                   (!is_auto ||
                                    (is_auto && xf86Info.autoEnableDevices)));
+        xorg_list_del(&d->node);
+        free(d);
     }
-    new_input_devices_count = 0;
 }
 
 /* end of xf86Xinput.c */
commit 28d8855cd4e3be8831fb1c17bf1d205bd8465d1e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 20 15:25:51 2016 +1000

    xfree86: use the right option traversal list to search for an option
    
    They're identically laid-out structs but let's use the right type to search
    for our desired value.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 538b110..e31aab3 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1541,23 +1541,19 @@ void
 xf86InputEnableVTProbe(void)
 {
     int i, is_auto = 0;
-    InputOption *option = NULL;
     DeviceIntPtr pdev;
 
     for (i = 0; i < new_input_devices_count; i++) {
         InputInfoPtr pInfo = new_input_devices[i];
+        const char *value = xf86findOptionValue(pInfo->options, "_source");
 
         is_auto = 0;
-        nt_list_for_each_entry(option, pInfo->options, list.next) {
-            const char *key = input_option_get_key(option);
-            const char *value = input_option_get_value(option);
-
-            if (strcmp(key, "_source") == 0 &&
-                (strcmp(value, "server/hal") == 0 ||
-                 strcmp(value, "server/udev") == 0 ||
-                 strcmp(value, "server/wscons") == 0))
-                is_auto = 1;
-        }
+        if (value &&
+            (strcmp(value, "server/hal") == 0 ||
+             strcmp(value, "server/udev") == 0 ||
+             strcmp(value, "server/wscons") == 0))
+            is_auto = 1;
+
         xf86NewInputDevice(pInfo, &pdev,
                                   (!is_auto ||
                                    (is_auto && xf86Info.autoEnableDevices)));


More information about the xorg-commit mailing list