From fa85b5affbc80f86278d3dbaab72165423590930 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 5 Jan 2026 18:32:09 +0000 Subject: [PATCH 1/3] wsi/display: add connectors to connectors list during allocation All callsites of wsi_display_alloc_connector already do that. Signed-off-by: Yuxuan Shui --- src/vulkan/wsi/wsi_common_display.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index f72e85c5e66..cc049709cb2 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -667,6 +667,7 @@ wsi_display_alloc_connector(struct wsi_display *wsi, /* XXX use EDID name */ connector->name = "monitor"; list_inithead(&connector->display_modes); + list_addtail(&connector->list, &wsi->connectors); return connector; } @@ -716,7 +717,6 @@ wsi_display_get_connector(struct wsi_device *wsi_device, drmModeFreeConnector(drm_connector); return NULL; } - list_addtail(&connector->list, &wsi->connectors); } if (!find_connector_properties(connector, drm_connector, drm_fd)) { @@ -3954,7 +3954,6 @@ wsi_display_get_randr_output(struct wsi_device *wsi_device, if (!connector) { return NULL; } - list_addtail(&connector->list, &wsi->connectors); } connector->output = output; } From 9854d522e234ec6743cad9031f99122c8004b402 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 5 Jan 2026 19:03:21 +0000 Subject: [PATCH 2/3] wsi/display: initialize Xlib display connector property IDs in all cases Usually connector property IDs are acquired in wsi_display_get_connector, which is called by wsi_get_connectors, and in turn by vkGetPhysicalDeviceDisplayProperties2KHR and vkGetPhysicalDeviceDisplayPlanePropertiesKHR. Except if the drm fd is not available when these functions are called. Which will be the case if vkAcquireXlibDisplayEXT is not called first. So it goes like this. First, the display is created in vkGetRandROutputDisplayEXT. Then it's used in vkGetPhysicalDeviceDisplayPlanePropertiesKHR, but since the drm fd is not available at this point, connector property IDs are not initialized. Later, this display is used in vkAcquireXlibDisplayEXT, which also doesn't touch the property IDs. Finally in drm_atomic_commit, the atomic commit fails with EINVAL, specifically because of the uninitialized ID of the "CRTC_ID" property. Since it's one of the properties drm_atomic_commit tries to set. This commit makes sure that find_connector_properties is called in vkAcquireXlibDisplayEXT to initialize the property IDs. Fixes: 513ffea1d366 ("wsi/display: use atomic mode setting") Signed-off-by: Yuxuan Shui --- src/vulkan/wsi/wsi_common_display.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index cc049709cb2..a2898a72c82 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -4116,6 +4116,22 @@ wsi_AcquireXlibDisplayEXT(VkPhysicalDevice physicalDevice, return VK_ERROR_INITIALIZATION_FAILED; drmSetClientCap(fd, DRM_CLIENT_CAP_ATOMIC, 1); + + drmModeConnectorPtr drm_connector = + drmModeGetConnector(fd, connector->id); + + if (!drm_connector) { + close(fd); + return VK_ERROR_INITIALIZATION_FAILED; + } + + bool success = find_connector_properties(connector, drm_connector, fd); + drmModeFreeConnector(drm_connector); + if (!success) { + close(fd); + return VK_ERROR_INITIALIZATION_FAILED; + } + wsi->fd = fd; #endif From 3e0ba16cd8eb63f61106861a37bb7f5ea35ce788 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 5 Jan 2026 19:13:14 +0000 Subject: [PATCH 3/3] wsi/display: move set atomic cap out of wsi_display_get_connector In all other cases, we immediately set atomic cap after acquiring a drm fd: - wsi_init - AcquireXlib - AcquireDrm wsi_GetDrmDisplayEXT is the only function left where the atomic cap is set by wsi_display_get_connector. This commit moves the set atomic cap into wsi_GetDrmDisplayEXT. Signed-off-by: Yuxuan Shui --- src/vulkan/wsi/wsi_common_display.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/vulkan/wsi/wsi_common_display.c b/src/vulkan/wsi/wsi_common_display.c index a2898a72c82..0a6b30cc4c0 100644 --- a/src/vulkan/wsi/wsi_common_display.c +++ b/src/vulkan/wsi/wsi_common_display.c @@ -694,14 +694,6 @@ wsi_display_get_connector(struct wsi_device *wsi_device, if (drm_fd < 0) return NULL; - /* We set this flag because this is the common entrypoint before we start - * using atomic capabilities -- it's a simple bool setting in the kernel to - * make the properties we start querying be available, and re-setting it is - * harmless. Otherwise, we'd need to push it up to all the entrypoints that - * a drm FD comes thorugh. - */ - drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ATOMIC, 1); - drmModeConnectorPtr drm_connector = drmModeGetConnector(drm_fd, connector_id); @@ -4471,6 +4463,8 @@ wsi_GetDrmDisplayEXT(VkPhysicalDevice physicalDevice, return VK_ERROR_UNKNOWN; } + drmSetClientCap(drmFd, DRM_CLIENT_CAP_ATOMIC, 1); + struct wsi_display_connector *connector = wsi_display_get_connector(wsi_device, drmFd, connectorId);