Feel free to add my r-b to this patch.

On 2018-06-25 19:36, Emil Velikov wrote:
From: Emil Velikov <emil.veli...@collabora.com>

The GPU almost exclusively lives on the PCI bus, so we expose it as a
normal PCI one.

This allows any 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 needed we can add the separate set at a later
stage.

Here are a couple of '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.veli...@collabora.com>
---
  xf86drm.c | 13 ++++++++++++-
  1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/xf86drm.c b/xf86drm.c
index 8ccd528f..b847ea26 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;
@@ -2996,7 +3002,7 @@ static char *
  get_real_pci_path(int maj, int min)
  {
      char path[PATH_MAX + 1];
-    char *real_path = malloc(PATH_MAX);
+    char *term, *real_path = malloc(PATH_MAX);
if (!real_path)
          return NULL;
@@ -3007,6 +3013,10 @@ get_real_pci_path(int maj, int min)
          return NULL;
      }
+ term = strrchr(real_path, '/');
+    if (term && strncmp(term, "/virtio", 7) == 0)
+        *term = 0;
+
      return real_path;
  }
@@ -3744,6 +3754,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:

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to