From 7775c79035e76f76a3500d6a9b88392efe08bae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= Date: Sat, 8 Mar 2025 12:28:26 -0300 Subject: [PATCH] v3dv: don't overwrite the primary fd if it's already set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a valid primary file descriptor is already set (e.g. from vc4), don't overwrite it with -1. This prevents losing a valid primary fd and resolves issues arising when vc4 is the first node returned by `drmGetDevices2()` and v3d is the second. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12777 Fixes: 188f1c6cbe7 ("v3dv: rewrite device identification") Signed-off-by: MaĆ­ra Canal Reviewed-by: Iago Toral Quiroga Part-of: --- src/broadcom/vulkan/v3dv_device.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 2a4eaa5b51c..a7139743c03 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -1594,10 +1594,12 @@ enumerate_devices(struct vk_instance *vk_instance) if (devices[i]->bustype != DRM_BUS_PLATFORM) continue; - if ((devices[i]->available_nodes & 1 << DRM_NODE_RENDER)) + if ((devices[i]->available_nodes & 1 << DRM_NODE_RENDER)) { try_device(devices[i]->nodes[DRM_NODE_RENDER], &render_fd, "v3d"); - if ((devices[i]->available_nodes & 1 << DRM_NODE_PRIMARY)) + } else if (primary_fd == -1 && + (devices[i]->available_nodes & 1 << DRM_NODE_PRIMARY)) { try_display_device(instance, devices[i]->nodes[DRM_NODE_PRIMARY], &primary_fd); + } #endif if (render_fd >= 0 && primary_fd >= 0)