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

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