winsys/amdgpu: Use render node only as fallback

If ac_drm_device_initialize returns -EACCES for the fd passed in.

A render node file description can't have DRM master status, which means
AMDGPU_CTX_PRIORITY_HIGH can't work without CAP_SYS_NICE (which
generally only the root user has).

Fixes: 8f30e90fc1 ("winsys/amdgpu: Prefer render node FD for ac_drm_device_initialize")
(cherry picked from commit 5cc3264b53)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41104>
This commit is contained in:
Michel Dänzer 2026-04-15 10:49:26 +02:00 committed by Eric Engestrom
parent 3740d70fc5
commit 705dabbc26
2 changed files with 7 additions and 9 deletions

View file

@ -2234,7 +2234,7 @@
"description": "winsys/amdgpu: Use render node only as fallback",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "8f30e90fc104c2b9e044d279fe953a308c44353f",
"notes": null

View file

@ -394,7 +394,7 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
{
struct amdgpu_screen_winsys *sws;
struct amdgpu_winsys *aws;
ac_drm_device *dev = NULL;
ac_drm_device *dev;
uint32_t drm_major, drm_minor;
int r;
@ -412,7 +412,8 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
/* Initialize the amdgpu device. This should always return the same pointer
* for the same fd. */
if (drmGetNodeTypeFromFd(fd) != DRM_NODE_RENDER) {
r = ac_drm_device_initialize(fd, is_virtio, &drm_major, &drm_minor, &dev);
if (r == -EACCES && drmGetNodeTypeFromFd(fd) != DRM_NODE_RENDER) {
char *render_device = drmGetRenderDeviceNameFromFd(fd);
if (render_device) {
@ -431,12 +432,9 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config,
}
}
if (!dev) {
r = ac_drm_device_initialize(fd, is_virtio, &drm_major, &drm_minor, &dev);
if (r) {
mesa_loge("amdgpu: amd%s_device_initialize failed.\n", is_virtio ? "vgpu" : "gpu");
goto fail;
}
if (r) {
mesa_loge("amdgpu: amd%s_device_initialize failed.\n", is_virtio ? "vgpu" : "gpu");
goto fail;
}
/* Lookup a winsys if we have already created one for this device. */