Currently xorg ignores the seat assignments for drm devices because the devices are initialized earlier in the code. Depending on race conditions, the first X server will get more than one of the drm devices, which breaks multiseat systems.

This patch fixes that by rejecting drm devices that haven't been assigned to our seat. The code has been mostly taken from config/udev.c and modified.

This patch is against HEAD, but also applies cleanly and has been tested against 1.16.2.901.

Jonathan
>From cd7afbb896fccfaee06c0196dd260aee37b40222 Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <[email protected]>
Date: Mon, 19 Jan 2015 16:51:17 +0200
Subject: [PATCH] Respect seat assignments when assigning drm devices to
 server. Currently, drm devices go to whichever server can get them first.

See https://bugzilla.redhat.com/show_bug.cgi?id=1183654

Signed-off-by: Jonathan Dieter <[email protected]>
---
 hw/xfree86/os-support/linux/lnx_platform.c | 44 ++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index 1d145b3..335b814 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -20,6 +20,10 @@
 #include "hotplug.h"
 #include "systemd-logind.h"
 
+#ifdef CONFIG_UDEV_KMS
+#include <libudev.h>
+#endif
+
 static Bool
 get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
 {
@@ -161,6 +165,46 @@ xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
     if (i != xf86_num_platform_devices)
         goto out_free;
 
+    #ifdef CONFIG_UDEV_KMS
+    {
+        struct udev_device *udev_device;
+        const char *dev_seat;
+        char *syspath = NULL;
+        struct udev *udev;
+
+        udev = udev_new();
+        if (!udev)
+            goto out_free;
+
+        syspath = config_odev_get_attribute(attribs, ODEV_ATTRIB_SYSPATH);
+
+        udev_device = udev_device_new_from_syspath(udev, syspath);
+        if (!udev_device) {
+            udev_unref(udev);
+            goto out_free;
+        }
+
+        dev_seat = udev_device_get_property_value(udev_device, "ID_SEAT");
+        if (!dev_seat)
+            dev_seat = "seat0";
+
+        if (SeatId && strcmp(dev_seat, SeatId)) {
+            LogMessage(X_INFO, "xfree86: Not adding drm device (%s): Wrong seat: %s\n", path, dev_seat);
+            udev_unref(udev);
+            udev_device_unref(udev_device);
+            goto out_free;
+        }
+
+        if (!SeatId && strcmp(dev_seat, "seat0")) {
+            LogMessage(X_INFO, "xfree86: Not adding drm device (%s): Wrong seat: %s\n", path, dev_seat);
+            udev_unref(udev);
+            udev_device_unref(udev_device);
+            goto out_free;
+        }
+        udev_unref(udev);
+        udev_device_unref(udev_device);
+    }
+    #endif
     LogMessage(X_INFO, "xfree86: Adding drm device (%s)\n", path);
 
     if (!xf86VTOwner()) {
-- 
2.1.0

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to