From: Mathias Fröhlich <[email protected]> Do not offer a hardware drm backed egl device if no render node is available. The current implementation will fail on this egl device. On top it issues a warning that is actually missleading. There are finally more error paths that can fail on the way to a hardware backed egl device. Fixing all of them would kind of require opening the drm device and see if there is a usable driver associated with the device. The taken approach avoids a full probe and fixes at least this kind of problem on kvm virtualization hosts I observe here.
Signed-off-by: Mathias Fröhlich <[email protected]> --- src/egl/main/egldevice.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/egl/main/egldevice.c b/src/egl/main/egldevice.c index 76b8960fa5b..6b791383af5 100644 --- a/src/egl/main/egldevice.c +++ b/src/egl/main/egldevice.c @@ -105,12 +105,16 @@ _EGLDevice _eglSoftwareDevice = { * Negative value on error, zero if newly added, one if already in list. */ static int -_eglAddDRMDevice(drmDevicePtr device, _EGLDevice **out_dev) +_eglAddDRMDevice(drmDevicePtr device, bool also_primary, _EGLDevice **out_dev) { _EGLDevice *dev; + int wanted_nodes = 1 << DRM_NODE_RENDER; - if ((device->available_nodes & (1 << DRM_NODE_PRIMARY | - 1 << DRM_NODE_RENDER)) == 0) + /* In case we have an fd given initially, we can accept a primary node */ + if (also_primary) + wanted_nodes |= 1 << DRM_NODE_PRIMARY; + + if ((device->available_nodes & wanted_nodes) == 0) return -1; dev = _eglGlobal.DeviceList; @@ -176,7 +180,7 @@ _eglAddDevice(int fd, bool software) } /* Device is not added - error or already present */ - if (_eglAddDRMDevice(device, &dev) != 0) + if (_eglAddDRMDevice(device, true, &dev) != 0) drmFreeDevice(&device); #else _eglLog(_EGL_FATAL, "Driver bug: Built without libdrm, yet looking for HW device"); @@ -273,7 +277,7 @@ _eglRefreshDeviceList(void) num_devs = drmGetDevices2(0, devices, ARRAY_SIZE(devices)); for (int i = 0; i < num_devs; i++) { - ret = _eglAddDRMDevice(devices[i], NULL); + ret = _eglAddDRMDevice(devices[i], false, NULL); /* Device is not added - error or already present */ if (ret != 0) -- 2.21.0 _______________________________________________ mesa-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-dev
