From 45a4a0745acc7c572a3a6d28fb567b13be6ccfa4 Mon Sep 17 00:00:00 2001 From: Weifeng Liu Date: Tue, 23 Dec 2025 10:45:57 +0800 Subject: [PATCH 1/3] DRMBackend: Return boolean value in init_drm --- src/Backends/DRMBackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Backends/DRMBackend.cpp b/src/Backends/DRMBackend.cpp index 731825456b..ba2859b02b 100644 --- a/src/Backends/DRMBackend.cpp +++ b/src/Backends/DRMBackend.cpp @@ -1231,7 +1231,7 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh) { drm_log.errorf( "'%s' is not a KMS device", drm->device_name ); wlsession_close_kms(); - return -1; + return false; } if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) { From 573c073b28030e6aa7034ffd4f725b96093154b0 Mon Sep 17 00:00:00 2001 From: Weifeng Liu Date: Tue, 23 Dec 2025 11:35:44 +0800 Subject: [PATCH 2/3] wlrserver: Ensure device opened by wlsession_open_kms is KMS-capable This ensures the function's semantics align with its name and simplifies the implementation of subsequent patch. --- src/Backends/DRMBackend.cpp | 7 ------- src/wlserver.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Backends/DRMBackend.cpp b/src/Backends/DRMBackend.cpp index ba2859b02b..dad65bf5f2 100644 --- a/src/Backends/DRMBackend.cpp +++ b/src/Backends/DRMBackend.cpp @@ -1227,13 +1227,6 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh) return false; } - if ( !drmIsKMS( drm->fd ) ) - { - drm_log.errorf( "'%s' is not a KMS device", drm->device_name ); - wlsession_close_kms(); - return false; - } - if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0) { drm_log.errorf("drmSetClientCap(ATOMIC) failed"); return false; diff --git a/src/wlserver.cpp b/src/wlserver.cpp index 1631ca780d..2c09188072 100644 --- a/src/wlserver.cpp +++ b/src/wlserver.cpp @@ -1686,6 +1686,12 @@ int wlsession_open_kms( const char *device_name ) { wlserver.wlr.device = wlr_session_open_file( wlserver.wlr.session, device_name ); if ( wlserver.wlr.device == nullptr ) return -1; + if ( !drmIsKMS(wlserver.wlr.device->fd) ) { + wl_log.errorf( "'%s' is not a KMS device", device_name ); + wlr_session_close_file( wlserver.wlr.session, wlserver.wlr.device ); + wlserver.wlr.device = nullptr; + return -1; + } } else { From 958eee94b44c66d45c2eb427e7384f2992b13f39 Mon Sep 17 00:00:00 2001 From: Weifeng Liu Date: Tue, 23 Dec 2025 11:41:45 +0800 Subject: [PATCH 3/3] DRMBackend: Use fallback KMS device if Vulkan primary is unusable In certain SR-IOV virtualization setups, rendering and display functions are split across different DRM nodes. A typical case is using an Intel iGPU Virtual Function (VF) as the Vulkan render device, while using virtio-GPU as the KMS device for output. If the detected Vulkan primary device is found to be unsatisfactory for KMS, the backend will now attempt to initialize an alternative KMS-capable device to ensure a working display. --- src/Backends/DRMBackend.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Backends/DRMBackend.cpp b/src/Backends/DRMBackend.cpp index dad65bf5f2..9ab0bf67c0 100644 --- a/src/Backends/DRMBackend.cpp +++ b/src/Backends/DRMBackend.cpp @@ -1221,6 +1221,14 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh) } drm->fd = wlsession_open_kms( drm->device_name ); + if ( drm->fd < 0 && drm->device_name ) + { + drm_log.infof("retrying with an arbitrary DRM device"); + free( drm->device_name ); + drm->device_name = nullptr; + drm->fd = wlsession_open_kms( nullptr ); + } + if ( drm->fd < 0 ) { drm_log.errorf("Could not open KMS device");