Blame SOURCES/0001-linux-Make-platform-device-probe-less-fragile.patch

98b35a
From 28320833d61af76dc3b77b985c69706f3e021836 Mon Sep 17 00:00:00 2001
98b35a
From: Adam Jackson <ajax@redhat.com>
98b35a
Date: Tue, 18 Sep 2018 14:37:51 -0400
98b35a
Subject: [PATCH xserver] linux: Make platform device probe less fragile
98b35a
98b35a
At the point where xf86BusProbe runs we haven't yet taken our own VT,
98b35a
which means we can't perform drm "master" operations on the device. This
98b35a
is tragic, because we need master to fish the bus id string out of the
98b35a
kernel, which we can only do after drmSetInterfaceVersion, which for
98b35a
some reason stores that string on the device not the file handle and
98b35a
thus needs master access.
98b35a
98b35a
Fortunately we know the format of the busid string, and it happens to
98b35a
almost be the same as the ID_PATH variable from udev. Use that instead
98b35a
and stop calling drmSetInterfaceVersion.
98b35a
98b35a
Signed-off-by: Adam Jackson <ajax@redhat.com>
98b35a
---
98b35a
 config/udev.c                              | 17 ++++++++++++-----
98b35a
 hw/xfree86/os-support/linux/lnx_platform.c | 13 ++-----------
98b35a
 2 files changed, 14 insertions(+), 16 deletions(-)
98b35a
98b35a
diff --git a/config/udev.c b/config/udev.c
98b35a
index 3a73189e25..8c6c4b6665 100644
98b35a
--- a/config/udev.c
98b35a
+++ b/config/udev.c
98b35a
@@ -56,7 +56,7 @@ static struct udev_monitor *udev_monitor;
98b35a
 
98b35a
 #ifdef CONFIG_UDEV_KMS
98b35a
 static void
98b35a
-config_udev_odev_setup_attribs(const char *path, const char *syspath,
98b35a
+config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path, const char *syspath,
98b35a
                                int major, int minor,
98b35a
                                config_odev_probe_proc_ptr probe_callback);
98b35a
 #endif
98b35a
@@ -128,7 +128,7 @@ device_added(struct udev_device *udev_device)
98b35a
 
98b35a
         LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n", path);
98b35a
 
98b35a
-        config_udev_odev_setup_attribs(path, syspath, major(devnum),
98b35a
+        config_udev_odev_setup_attribs(udev_device, path, syspath, major(devnum),
98b35a
                                        minor(devnum), NewGPUDeviceRequest);
98b35a
         return;
98b35a
     }
98b35a
@@ -322,7 +322,7 @@ device_removed(struct udev_device *device)
98b35a
 
98b35a
         LogMessage(X_INFO, "config/udev: removing GPU device %s %s\n",
98b35a
                    syspath, path);
98b35a
-        config_udev_odev_setup_attribs(path, syspath, major(devnum),
98b35a
+        config_udev_odev_setup_attribs(device, path, syspath, major(devnum),
98b35a
                                        minor(devnum), DeleteGPUDeviceRequest);
98b35a
         /* Retry vtenter after a drm node removal */
98b35a
         systemd_logind_vtenter();
98b35a
@@ -465,17 +465,24 @@ config_udev_fini(void)
98b35a
 #ifdef CONFIG_UDEV_KMS
98b35a
 
98b35a
 static void
98b35a
-config_udev_odev_setup_attribs(const char *path, const char *syspath,
98b35a
+config_udev_odev_setup_attribs(struct udev_device *udev_device, const char *path, const char *syspath,
98b35a
                                int major, int minor,
98b35a
                                config_odev_probe_proc_ptr probe_callback)
98b35a
 {
98b35a
     struct OdevAttributes *attribs = config_odev_allocate_attributes();
98b35a
+    const char *value;
98b35a
 
98b35a
     attribs->path = XNFstrdup(path);
98b35a
     attribs->syspath = XNFstrdup(syspath);
98b35a
     attribs->major = major;
98b35a
     attribs->minor = minor;
98b35a
 
98b35a
+    value = udev_device_get_property_value(udev_device, "ID_PATH");
98b35a
+    if (value && !strncmp(value, "pci-", 4)) {
98b35a
+        attribs->busid = XNFstrdup(value);
98b35a
+        attribs->busid[3] = ':';
98b35a
+    }
98b35a
+
98b35a
     /* ownership of attribs is passed to probe layer */
98b35a
     probe_callback(attribs);
98b35a
 }
98b35a
@@ -516,7 +523,7 @@ config_udev_odev_probe(config_odev_probe_proc_ptr probe_callback)
98b35a
         else if (!check_seat(udev_device))
98b35a
             goto no_probe;
98b35a
 
98b35a
-        config_udev_odev_setup_attribs(path, syspath, major(devnum),
98b35a
+        config_udev_odev_setup_attribs(udev_device, path, syspath, major(devnum),
98b35a
                                        minor(devnum), probe_callback);
98b35a
     no_probe:
98b35a
         udev_device_unref(udev_device);
98b35a
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
98b35a
index 70374ace88..0eb6d22875 100644
98b35a
--- a/hw/xfree86/os-support/linux/lnx_platform.c
98b35a
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
98b35a
@@ -30,6 +30,8 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
98b35a
     int err = 0;
98b35a
     Bool paused, server_fd = FALSE;
98b35a
 
98b35a
+    LogMessage(X_INFO, "Platform probe for %s\n", attribs->syspath);
98b35a
+
98b35a
     fd = systemd_logind_take_fd(attribs->major, attribs->minor, path, &paused);
98b35a
     if (fd != -1) {
98b35a
         if (paused) {
98b35a
@@ -53,13 +55,6 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
98b35a
     sv.drm_dd_major = -1;       /* Don't care */
98b35a
     sv.drm_dd_minor = -1;       /* Don't care */
98b35a
 
98b35a
-    err = drmSetInterfaceVersion(fd, &sv;;
98b35a
-    if (err) {
98b35a
-        xf86Msg(X_ERROR, "%s: failed to set DRM interface version 1.4: %s\n",
98b35a
-                path, strerror(-err));
98b35a
-        goto out;
98b35a
-    }
98b35a
-
98b35a
     /* for a delayed probe we've already added the device */
98b35a
     if (delayed_index == -1) {
98b35a
             xf86_add_platform_device(attribs, FALSE);
98b35a
@@ -69,10 +64,6 @@ get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
98b35a
     if (server_fd)
98b35a
         xf86_platform_devices[delayed_index].flags |= XF86_PDEV_SERVER_FD;
98b35a
 
98b35a
-    buf = drmGetBusid(fd);
98b35a
-    xf86_platform_odev_attributes(delayed_index)->busid = XNFstrdup(buf);
98b35a
-    drmFreeBusid(buf);
98b35a
-
98b35a
     v = drmGetVersion(fd);
98b35a
     if (!v) {
98b35a
         xf86Msg(X_ERROR, "%s: failed to query DRM version\n", path);
98b35a
-- 
98b35a
2.19.0
98b35a