From 6d6da5bf4d89a94461328d42dd3f0b96722045ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 9 Aug 2022 17:04:47 -0400 Subject: [PATCH] winsys/amdgpu: terminate process on CS rejection when unrobust context is lost We agreed on this with the kernel team as the most graceful way to deal with this scenario. Remove the allow_context_lost use because it's always true there if num_rejected_cs is true. Reviewed-by: Mihai Preda Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c index d6e14e6888b..c504dc318c4 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.c @@ -1489,7 +1489,7 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index) bool noop = false; - if (acs->allow_context_lost && acs->ctx->num_rejected_cs) { + if (acs->ctx->num_rejected_cs) { r = -ECANCELED; } else { struct drm_amdgpu_cs_chunk chunks[7]; @@ -1632,6 +1632,16 @@ static void amdgpu_cs_submit_ib(void *job, void *gdata, int thread_index) } if (r) { + if (!acs->allow_context_lost) { + /* Non-robust contexts are allowed to terminate the process. The only alternative is + * to skip command submission, which would look like a freeze because nothing is drawn, + * which is not a useful state to be in under any circumstances. + */ + fprintf(stderr, "amdgpu: The CS has been rejected (%i), but the context isn't robust.\n", r); + fprintf(stderr, "amdgpu: The process will be terminated.\n"); + exit(1); + } + if (r == -ECANCELED) fprintf(stderr, "amdgpu: The CS has been cancelled because the context is lost.\n"); else