From db4d7a303279d0127a60b7cecb62e068f03f53e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= Date: Fri, 17 Jan 2025 08:47:43 -0300 Subject: [PATCH] v3dv: VK_EXT_acquire_drm_display doesn't require a DRM master fd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using VK_EXT_acquire_drm_display, the Vulkan API user must provide the DRM master fd that will be used. This operation is performed through `vkAcquireDrmDisplayEXT()` in which `drmFd` will be assigned to `wsi->fd` and will be used for privileged operations. This means that, when we are creating the physical device, we need to open a DRM primary node (as the specification states that "The provided drmFd must correspond to the one owned by the physicalDevice."), but it doesn't need to be the DRM master. Therefore, when using VK_EXT_acquire_drm_display, keep the primary fd open and don't check if the fd is the DRM master. Signed-off-by: MaĆ­ra Canal Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/vulkan/v3dv_device.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index f6a8411bbd1..9905a4e16a5 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -1481,8 +1481,6 @@ static void try_display_device(struct v3dv_instance *instance, const char *path, int32_t *fd) { - bool khr_display = instance->vk.enabled_extensions.KHR_display || - instance->vk.enabled_extensions.EXT_acquire_drm_display; *fd = open(path, O_RDWR | O_CLOEXEC); if (*fd < 0) { mesa_loge("Opening %s failed: %s\n", path, strerror(errno)); @@ -1493,13 +1491,10 @@ try_display_device(struct v3dv_instance *instance, const char *path, if (!drmIsKMS(*fd)) goto fail; - /* If using VK_KHR_display, we require the fd to have a connected output. - * We need to use this strategy because Raspberry Pi 5 can load different - * drivers for different types of connectors and the one with a connected - * output may not be vc4, which unlike Raspberry Pi 4, doesn't drive the - * DSI output for example. + /* Note that VK_EXT_acquire_drm_display requires KHR_display so there is + * no need to check for it explicitly here. */ - if (!khr_display) { + if (!instance->vk.enabled_extensions.KHR_display) { if (instance->vk.enabled_extensions.KHR_xcb_surface || instance->vk.enabled_extensions.KHR_xlib_surface || instance->vk.enabled_extensions.KHR_wayland_surface) @@ -1508,7 +1503,21 @@ try_display_device(struct v3dv_instance *instance, const char *path, goto fail; } - /* If the display device isn't the DRM master, we can't get its resources */ + /* When using VK_EXT_acquire_drm_display, the user is expected to get + * the master fd and provide it to the driver through vkAcquireDrmDisplayEXT. + * Therefore, the fd we open here won't be master. + */ + if (instance->vk.enabled_extensions.EXT_acquire_drm_display) + return; + + /* If using VK_KHR_display, we require the fd to have a connected output. + * We need to use this strategy because Raspberry Pi 5 can load different + * drivers for different types of connectors and the one with a connected + * output may not be vc4, which unlike Raspberry Pi 4, doesn't drive the + * DSI output for example. + * + * If the display device isn't the DRM master, we can't get its resources. + */ if (!drmIsMaster(*fd)) goto fail;