winsys/amdgpu: fall back to a normal priority without root in the winsys
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34983>
This commit is contained in:
Marek Olšák 2025-05-23 11:07:23 -04:00 committed by Marge Bot
parent 2ef6aa5934
commit 0dc5d649ea
2 changed files with 9 additions and 10 deletions

View file

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

View file

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