From 98e1db501173303e58ef6a1def94ab7a2d84afc1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 13 Apr 2023 11:01:51 -0400 Subject: [PATCH] amdgpu: add an environment variable that overrides the context priority Reviewed-by: Pierre-Eric Pelloux-Prayer --- amdgpu/amdgpu_cs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c index 638fd7d..0eceb38 100644 --- a/amdgpu/amdgpu_cs.c +++ b/amdgpu/amdgpu_cs.c @@ -56,10 +56,22 @@ drm_public int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, union drm_amdgpu_ctx args; int i, j, k; int r; + char *override_priority; if (!dev || !context) return -EINVAL; + override_priority = getenv("AMD_PRIORITY"); + if (override_priority) { + /* The priority is a signed integer. The variable type is + * wrong. If parsing fails, priority is unchanged. + */ + if (sscanf(override_priority, "%i", &priority) == 1) { + printf("amdgpu: context priority changed to %i\n", + priority); + } + } + gpu_context = calloc(1, sizeof(struct amdgpu_context)); if (!gpu_context) return -ENOMEM; -- 2.7.4