summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2018-05-15 17:37:49 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2018-07-24 16:25:05 +0100
commit3988580e4c0f4b3647a0c6af138a3825453fe6e0 (patch)
tree164c183aa5e5c24b9d495cb5dfc40bfa618e18d0
parenta02900133b32dd4a7d6da4966f455ab337e80dfc (diff)
xf86drm: Add drmDevice support for virtio_gpu
The GPU almost exclusively lives on the PCI bus, so we expose it as a normal PCI one. This allows all existing drmDevice users to work without any changes. One could wonder why a separate typeset is not introduced, alike say host1x. Unlike host1x the PCI/platform distinction for virtio provides no extra information. Plus if needed we can add the separate set at a later stage. Here are a few 'features' that virtio seems to be missing: - provides extra information on top the plaform devices - supports a range of GPU devices - is considered hardware description (DT) Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Tested-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch>
-rw-r--r--xf86drm.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/xf86drm.c b/xf86drm.c
index 51e00d23..1e621e99 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2954,6 +2954,9 @@ sysfs_uevent_get(const char *path, const char *fmt, ...)
}
#endif
+/* Little white lie to avoid major rework of the existing code */
+#define DRM_BUS_VIRTIO 0x10
+
static int drmParseSubsystemType(int maj, int min)
{
#ifdef __linux__
@@ -2983,6 +2986,9 @@ static int drmParseSubsystemType(int maj, int min)
if (strncmp(name, "/host1x", 7) == 0)
return DRM_BUS_HOST1X;
+ if (strncmp(name, "/virtio", 7) == 0)
+ return DRM_BUS_VIRTIO;
+
return -EINVAL;
#elif defined(__OpenBSD__)
return DRM_BUS_PCI;
@@ -2995,12 +3001,16 @@ static int drmParseSubsystemType(int maj, int min)
static char *
get_real_pci_path(int maj, int min, char *real_path)
{
- char path[PATH_MAX + 1];
+ char path[PATH_MAX + 1], *term;
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
if (!realpath(path, real_path))
return NULL;
+ term = strrchr(real_path, '/');
+ if (term && strncmp(term, "/virtio", 7) == 0)
+ *term = 0;
+
return real_path;
}
@@ -3724,6 +3734,7 @@ 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: