From c420a3495be38f8128fd1352f547771fa66f9293 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: (cherry picked from commit 7775c79035e76f76a3500d6a9b88392efe08bae7) --- .pick_status.json | 2 +- src/broadcom/vulkan/v3dv_device.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index d7b611bc749..201fa93fc84 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2124,7 +2124,7 @@ "description": "v3dv: don't overwrite the primary fd if it's already set", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "188f1c6cbe79ca777188718a017482ab6362c425", "notes": null diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index f6a8411bbd1..f9181fda0ec 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -1587,10 +1587,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)