[Mesa-dev] [PATCH] loader: Make drmGetVersion logic conditional on non-pci devices
Stéphane Marchesin
marcheu at chromium.org
Wed Jan 29 17:33:23 PST 2014
On systems without libudev, the loader_get_pci_id_for_fd() call will
return 0, which will trigger the drmGetVersion logic. Sadly, this
logic assumes that the kernel driver name matches the dri driver name,
which is not the case on recent intel GPUs (for example i965 dri
driver and i915 kernel module).
This patch changes this logic by making it conditional on a list of
known non-pci drivers (freedreno and tegra). This fixes dri on machines
without libudev.
---
src/loader/loader.c | 52 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 18 deletions(-)
diff --git a/src/loader/loader.c b/src/loader/loader.c
index ee4c1e0..71c1252 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -301,34 +301,50 @@ out:
return device_name;
}
-char *
-loader_get_driver_for_fd(int fd, unsigned driver_types)
+static char*
+loader_get_nonpci_name_for_fd(int fd)
{
- int vendor_id, chip_id, i, j;
+#ifndef __NOT_HAVE_DRM_H
char *driver = NULL;
+ int i = 0;
+ char* known_nonpci_drivers[] = { "msm", "kgsl", "tegra", NULL };
- if (!driver_types)
- driver_types = _LOADER_GALLIUM | _LOADER_DRI;
-
- if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id)) {
+ /* fallback to drmGetVersion(): */
+ drmVersionPtr version = drmGetVersion(fd);
-#ifndef __NOT_HAVE_DRM_H
- /* fallback to drmGetVersion(): */
- drmVersionPtr version = drmGetVersion(fd);
+ if (!version) {
+ log_(_LOADER_WARNING, "failed to get driver name for fd %d\n", fd);
+ return NULL;
+ }
- if (!version) {
- log_(_LOADER_WARNING, "failed to get driver name for fd %d\n", fd);
- return NULL;
+ while (known_nonpci_drivers[i]) {
+ if (!strcmp(version->name, known_nonpci_drivers[i])) {
+ driver = strndup(version->name, version->name_len);
+ log_(_LOADER_INFO, "using driver %s for %d\n", driver, fd);
+ break;
}
+ i++;
+ }
- driver = strndup(version->name, version->name_len);
- log_(_LOADER_INFO, "using driver %s for %d\n", driver, fd);
+ drmFreeVersion(version);
- drmFreeVersion(version);
+ return driver;
+#else
+ return NULL;
#endif
+}
- return driver;
- }
+char *
+loader_get_driver_for_fd(int fd, unsigned driver_types)
+{
+ int vendor_id, chip_id, i, j;
+ char *driver = NULL;
+
+ if (!driver_types)
+ driver_types = _LOADER_GALLIUM | _LOADER_DRI;
+
+ if (!loader_get_pci_id_for_fd(fd, &vendor_id, &chip_id))
+ return loader_get_nonpci_name_for_fd(fd);
for (i = 0; driver_map[i].driver; i++) {
if (vendor_id != driver_map[i].vendor_id)
--
1.8.5.3
More information about the mesa-dev
mailing list