v3dv: don't overwrite the primary fd if it's already set

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: 188f1c6cbe ("v3dv: rewrite device identification")
Signed-off-by: Maíra Canal <mcanal@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33958>
(cherry picked from commit 7775c79035)
This commit is contained in:
Maíra Canal 2025-03-08 12:28:26 -03:00 committed by Eric Engestrom
parent 2d9d444aa7
commit c420a3495b
2 changed files with 5 additions and 3 deletions

View file

@ -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

View file

@ -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)