<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - libGL error: MESA-LOADER: failed to retrieve device information on virgl"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=107309">107309</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libGL error: MESA-LOADER: failed to retrieve device information on virgl
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>DRI
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>XOrg git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>libdrm
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vliaskovitis@suse.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=140732" name="attach_140732" title="xf86drm: Correctly parse pci device information for virtio gpu">attachment 140732</a> <a href="attachment.cgi?id=140732&action=edit" title="xf86drm: Correctly parse pci device information for virtio gpu">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=107309&attachment=140732'>[review]</a>
xf86drm: Correctly parse pci device information for virtio gpu

Mesa 18.1.3-201.1
kernel 4.17.5-1-default
libdrm 2.4.92-1.2

glxinfo | grep -i renderer
OpenGL renderer string: virgl

LIBGL_DEBUG=verbose glxgears
libGL error: MESA-LOADER: failed to retrieve device information
libGL: using driver virtio_gpu for 4
libGL: OpenDriver: trying /usr/lib64/dri/tls/virtio_gpu_dri.so
libGL: OpenDriver: trying /usr/lib64/dri/virtio_gpu_dri.so

Adding some debug drmMsg() prints, I found that the MESA-LOADER error message
happens because drmGetDevice2() returns -ENODEV. And that happens because
drmParseSubsystemType() returns -EINVAL.

drmParseSubsystemType() expects /sys/dev/char/DRM_MAJOR\:0/device/subsystem to
be one of pci, usb, platform, hostix. But virtio-gpu has bus subsystem virtio:

ls -al /sys/dev/char/226\:0/device/subsystem
lrwxrwxrwx 1 root root 0 Jul 19 17:39 /sys/dev/char/226:0/device/subsystem ->
../../../../bus/virtio

ls -al /sys/dev/char/226\:128/device/subsystem
lrwxrwxrwx 1 root root 0 Jul 19 17:39 /sys/dev/char/226:128/device/subsystem ->
../../../../bus/virtio

I am not sure if this is a cosmetic error, or if it matters. I am attaching a
proposed patch.

Since the virtio-gpu device is actually a pci device, we can still parse the
correct information from the corresponding pci device:

ls -al /sys/dev/char/226\:0
lrwxrwxrwx 1 root root 0 Jul 20 13:30 /sys/dev/char/226:0 ->
../../devices/pci0000:00/0000:00:02.0/virtio0/drm/card0

i.e. use /sys/dev/char/226\:128/../../../ instead of /sys/dev/char/226\:128/
for virtio devices.

to parse subsystem, and subsequently pci bus and pci device information.

(Let me know if bugzilla is still the place to report bugs, or if 
<a href="https://gitlab.freedesktop.org/mesa/drm">https://gitlab.freedesktop.org/mesa/drm</a> is now the preferred location)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>