summaryrefslogtreecommitdiffstats
path: root/src/loader/loader.c
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2020-03-05 14:41:25 +0000
committerEmil Velikov <[email protected]>2020-04-01 16:57:22 +0100
commit91478db20d5ccfeb9c35652cf01acdcfcd285414 (patch)
treeca9429b3296a25bccafe37f52bbb633338a26c48 /src/loader/loader.c
parentbf1838838a695f27d9d9c486e608a9412044a598 (diff)
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 <[email protected]> Reviewed-by: Adam Jackson <[email protected]> Reviewed-by: Eric Engestrom <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4084> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4084>
Diffstat (limited to 'src/loader/loader.c')
-rw-r--r--src/loader/loader.c56
1 files 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)
{