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

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