From 0dc5d649ea3eef4382aaa278fa23e3779209dcd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 23 May 2025 11:07:23 -0400 Subject: [PATCH] winsys/amdgpu: fall back to a normal priority without root in the winsys Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/drivers/radeonsi/si_pipe.c | 9 --------- src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp | 10 +++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 948cf9ce95e..a589ceefd58 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -550,15 +550,6 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign /* Initialize the context handle and the command stream. */ sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags); - if (!sctx->ctx && sctx->context_flags & PIPE_CONTEXT_HIGH_PRIORITY) { - /* Context priority should be treated as a hint. If context creation - * fails with the requested priority, for example because the caller - * lacks CAP_SYS_NICE capability or other system resource constraints, - * fallback to normal priority. - */ - sctx->context_flags &= ~PIPE_CONTEXT_HIGH_PRIORITY; - sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags); - } if (!sctx->ctx) { fprintf(stderr, "radeonsi: can't create radeon_winsys_ctx\n"); goto fail; diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp index 3fbd4a76a83..46c187072cb 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp @@ -268,7 +268,15 @@ static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws, un dev = ctx->aws->dev; - r = ac_drm_cs_ctx_create2(dev, amdgpu_priority, &ctx->ctx_handle); + while (1) { + r = ac_drm_cs_ctx_create2(dev, amdgpu_priority, &ctx->ctx_handle); + if (r == -EACCES && amdgpu_priority == AMDGPU_CTX_PRIORITY_HIGH) { + /* Try again with a lower priority. */ + amdgpu_priority = AMDGPU_CTX_PRIORITY_NORMAL; + continue; + } + break; + } if (r) { fprintf(stderr, "amdgpu: amdgpu_cs_ctx_create2 failed. (%i)\n", r); goto error_create;