[PATCH xserver 6/7] modesetting: Check for vanished outputs after updating output ids

Daniel Martin consume.noise at gmail.com
Mon Nov 20 10:02:09 UTC 2017


Doing this before updating the output_ids is not a good idea as we
compare the output id in the loop and the output id is unreliable.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 51 ++++++++++++++----------
 1 file changed, 29 insertions(+), 22 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index a6f10ca91..e0c9f0e69 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -2355,28 +2355,6 @@ drmmode_handle_uevents(int fd, void *closure)
         goto out_free_res;
     }
 
-    /* figure out if we have gotten rid of any connectors
-       traverse old output list looking for outputs */
-    for (i = 0; i < config->num_output; i++) {
-        xf86OutputPtr output = config->output[i];
-        drmmode_output_private_ptr drmmode_output;
-
-        drmmode_output = output->driver_private;
-        found = FALSE;
-        for (j = 0; j < mode_res->count_connectors; j++) {
-            if (mode_res->connectors[j] == drmmode_output->output_id) {
-                found = TRUE;
-                break;
-            }
-        }
-        if (found)
-            continue;
-
-        drmmode_output->output_id = -1;
-
-        changed = TRUE;
-    }
-
     /* Re-evaluate the outputs, add new ones and update output ids. */
     for (i = 0; i < mode_res->count_connectors; i++) {
         drmModePropertyBlobPtr path_blob;
@@ -2416,6 +2394,35 @@ drmmode_handle_uevents(int fd, void *closure)
         drmModeFreeConnector(koutput);
     }
 
+    /* Figure out if we have gotten rid of any connectors. As we updated
+     * the output_ids above, we can use them for comparision. */
+    for (i = 0; i < config->num_output; i++) {
+        xf86OutputPtr output = config->output[i];
+        drmmode_output_private_ptr drmmode_output;
+
+        drmmode_output = output->driver_private;
+        found = FALSE;
+
+        if (drmmode_output->output_id == -1)
+            continue;
+
+        for (j = 0; j < mode_res->count_connectors; j++) {
+            if (mode_res->connectors[j] == drmmode_output->output_id) {
+                found = TRUE;
+                break;
+            }
+        }
+        if (found)
+            continue;
+
+        xf86DrvMsg(scrn->scrnIndex, X_DEBUG,
+                   "hotplug event: output %s vanished\n",
+                   output->name);
+
+        drmmode_output->output_id = -1;
+        changed = TRUE;
+    }
+
     if (changed) {
         RRSetChanged(xf86ScrnToScreen(scrn));
         RRTellChanged(xf86ScrnToScreen(scrn));
-- 
2.13.6



More information about the xorg-devel mailing list