[PATCH v2 09/14] hotplug: Extend OdevAttributes for server-managed fd support

Hans de Goede hdegoede at redhat.com
Tue Feb 4 12:49:15 CET 2014


With systemd-logind support, the xserver, rather than the drivers will be
responsible for opening/closing the fd for drm nodes.

This commit adds a fd member to OdevAttributes to store the fd to pass it
along to the driver.

systemd-logind tracks devices by their chardev major + minor numbers, so
also add OdevAttributes to store the major and minor.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 hw/xfree86/common/xf86platformBus.c | 14 ++++++++++++++
 hw/xfree86/common/xf86platformBus.h |  1 +
 include/hotplug.h                   | 10 ++++++++++
 3 files changed, 25 insertions(+)

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 97d606a..e1d7bd0 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -128,6 +128,20 @@ xf86_get_platform_device_unowned(int index)
         TRUE : FALSE;
 }
 
+struct xf86_platform_device *
+xf86_find_platform_device_by_devnum(int major, int minor)
+{
+    int i, attr_major, attr_minor;
+
+    for (i = 0; i < xf86_num_platform_devices; i++) {
+        attr_major = xf86_get_platform_int_attrib(i, ODEV_ATTRIB_MAJOR, 0);
+        attr_minor = xf86_get_platform_int_attrib(i, ODEV_ATTRIB_MINOR, 0);
+        if (attr_major == major && attr_minor == minor)
+            return &xf86_platform_devices[i];
+    }
+    return NULL;
+}
+
 /*
  * xf86IsPrimaryPlatform() -- return TRUE if primary device
  * is a platform device and it matches this one.
diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h
index 9a49260..3e27d34 100644
--- a/hw/xfree86/common/xf86platformBus.h
+++ b/hw/xfree86/common/xf86platformBus.h
@@ -35,6 +35,7 @@ struct xf86_platform_device {
 
 /* xf86_platform_device flags */
 #define XF86_PDEV_UNOWNED       0x01
+#define XF86_PDEV_SERVER_FD     0x02
 
 #ifdef XSERVER_PLATFORM_BUS
 int xf86platformProbe(void);
diff --git a/include/hotplug.h b/include/hotplug.h
index 70d80f8..676e647 100644
--- a/include/hotplug.h
+++ b/include/hotplug.h
@@ -78,6 +78,12 @@ config_odev_free_attributes(struct OdevAttributes *attribs);
 #define ODEV_ATTRIB_SYSPATH 2
 /* DRI-style bus id */
 #define ODEV_ATTRIB_BUSID 3
+/* Server managed FD */
+#define ODEV_ATTRIB_FD 4
+/* Major number of the device node pointed to by ODEV_ATTRIB_PATH */
+#define ODEV_ATTRIB_MAJOR 5
+/* Minor number of the device node pointed to by ODEV_ATTRIB_PATH */
+#define ODEV_ATTRIB_MINOR 6
 
 typedef void (*config_odev_probe_proc_ptr)(struct OdevAttributes *attribs);
 void config_odev_probe(config_odev_probe_proc_ptr probe_callback);
@@ -88,4 +94,8 @@ void DeleteGPUDeviceRequest(struct OdevAttributes *attribs);
 #endif
 
 #define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0"))
+
+struct xf86_platform_device *
+xf86_find_platform_device_by_devnum(int major, int minor);
+
 #endif                          /* HOTPLUG_H */
-- 
1.8.5.3



More information about the xorg-devel mailing list