aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>2020-01-29 16:08:41 +0100
committerKristian H. Kristensen <hoegsberg@gmail.com>2020-02-24 21:53:41 +0000
commit8a73372e62a73fe8d874aa39458c508cdb5bb6f4 (patch)
tree4975f92226358647ae82b611d708d5d9d358a645
parentc4eae71d7e44df2c1f89fb3460b1f7f8feaff0df (diff)
downloadexternal_libdrm-8a73372e62a73fe8d874aa39458c508cdb5bb6f4.tar.gz
external_libdrm-8a73372e62a73fe8d874aa39458c508cdb5bb6f4.tar.bz2
external_libdrm-8a73372e62a73fe8d874aa39458c508cdb5bb6f4.zip
xf86drm: fix subsystem type lookup for virtio mmio-based devices
Currently the code assumes that a virtio based device is always located on the PCI bus. Modify the parser to make it check the device's parent directory to determine on which bus it is located. Output for virtio-pci is the PCI bus. Output for virtio-mmio is the Platform bus. Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com> Signed-off-by: Mikhail Golubev <Mikhail.Golubev@opensynergy.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
-rw-r--r--xf86drm.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/xf86drm.c b/xf86drm.c
index b1479128..d240f95b 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3005,10 +3005,20 @@ static int drmParseSubsystemType(int maj, int min)
{
#ifdef __linux__
char path[PATH_MAX + 1] = "";
+ char real_path[PATH_MAX + 1] = "";
+ int subsystem_type;
- snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device", maj, min);
+ snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
+ if (!realpath(path, real_path))
+ return -errno;
+ snprintf(path, sizeof(path), "%s", real_path);
- return get_subsystem_type(path);
+ subsystem_type = get_subsystem_type(path);
+ if (subsystem_type == DRM_BUS_VIRTIO) {
+ strncat(path, "/..", PATH_MAX);
+ subsystem_type = get_subsystem_type(path);
+ }
+ return subsystem_type;
#elif defined(__OpenBSD__) || defined(__DragonFly__)
return DRM_BUS_PCI;
#else
@@ -3710,7 +3720,6 @@ process_device(drmDevicePtr *device, const char *d_name,
switch (subsystem_type) {
case DRM_BUS_PCI:
- case DRM_BUS_VIRTIO:
return drmProcessPciDevice(device, node, node_type, maj, min,
fetch_deviceinfo, flags);
case DRM_BUS_USB: