Mesa (master): loader: fallback to kernel name, if PCI fails

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 1 16:53:34 UTC 2020


Module: Mesa
Branch: master
Commit: 91478db20d5ccfeb9c35652cf01acdcfcd285414
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=91478db20d5ccfeb9c35652cf01acdcfcd285414

Author: Emil Velikov <emil.velikov at collabora.com>
Date:   Thu Mar  5 14:41:25 2020 +0000

loader: fallback to kernel name, if PCI fails

Currently, if the PCI machinery fails, we return a NULL driver name.
In the past this has resulted in various workarounds.

To avoid those, fallback to loader_get_kernel_driver_name(). It's not
perfect, yet perfectly reasonable.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4084>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4084>

---

 src/loader/loader.c | 56 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 33 insertions(+), 23 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 38d8752e26e..8548cbdfedb 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -428,33 +428,14 @@ loader_get_device_name_for_fd(int fd)
    return result;
 }
 
-char *
-loader_get_driver_for_fd(int fd)
+static char *
+loader_get_pci_driver(int fd)
 {
    int vendor_id, chip_id, i, j;
    char *driver = NULL;
 
-   /* Allow an environment variable to force choosing a different driver
-    * binary.  If that driver binary can't survive on this FD, that's the
-    * user's problem, but this allows vc4 simulator to run on an i965 host,
-    * and may be useful for some touch testing of i915 on an i965 host.
-    */
-   if (geteuid() == getuid()) {
-      driver = getenv("MESA_LOADER_DRIVER_OVERRIDE");
-      if (driver)
-         return strdup(driver);
-   }
-
-#if defined(HAVE_LIBDRM) && defined(USE_DRICONF)
-   driver = loader_get_dri_config_driver(fd);
-   if (driver)
-      return driver;
-#endif
-
-   if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
-      driver = loader_get_kernel_driver_name(fd);
-      return driver;
-   }
+   if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id))
+      return NULL;
 
    for (i = 0; i < ARRAY_SIZE(driver_map); i++) {
       if (vendor_id != driver_map[i].vendor_id)
@@ -482,6 +463,35 @@ out:
    return driver;
 }
 
+char *
+loader_get_driver_for_fd(int fd)
+{
+   char *driver;
+
+   /* Allow an environment variable to force choosing a different driver
+    * binary.  If that driver binary can't survive on this FD, that's the
+    * user's problem, but this allows vc4 simulator to run on an i965 host,
+    * and may be useful for some touch testing of i915 on an i965 host.
+    */
+   if (geteuid() == getuid()) {
+      driver = getenv("MESA_LOADER_DRIVER_OVERRIDE");
+      if (driver)
+         return strdup(driver);
+   }
+
+#if defined(HAVE_LIBDRM) && defined(USE_DRICONF)
+   driver = loader_get_dri_config_driver(fd);
+   if (driver)
+      return driver;
+#endif
+
+   driver = loader_get_pci_driver(fd);
+   if (!driver)
+      driver = loader_get_kernel_driver_name(fd);
+
+   return driver;
+}
+
 void
 loader_set_logger(loader_logger *logger)
 {



More information about the mesa-commit mailing list