From 2b8c3a12c68e39d9d3f95509575469681fc1bbf4 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Thu, 30 Jan 2025 10:47:20 +0100 Subject: [PATCH] winsys/amdgpu: treat cs overflow as context lost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing code relies on assert to identify when a cs overlow occurs. On builds without asserts, a cs overflow won't be detected and it will likely lead to a hang. Reporting a preemptively a PIPE_UNKNOWN_CONTEXT_RESET error seems ok as the context is lost anyway. Reviewed-by: Marek Olšák Part-of: --- src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp index e75ba3f15f0..8515d406c81 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_cs.cpp @@ -1065,7 +1065,8 @@ static bool amdgpu_cs_check_space(struct radeon_cmdbuf *rcs, unsigned dw) struct amdgpu_cs *cs = amdgpu_cs(rcs); struct amdgpu_ib *main_ib = &cs->main_ib; - assert(rcs->current.cdw <= rcs->current.max_dw); + if (rcs->current.cdw > rcs->current.max_dw) + return false; unsigned projected_size_dw = rcs->prev_dw + rcs->current.cdw + dw; @@ -2112,7 +2113,11 @@ static int amdgpu_cs_flush(struct radeon_cmdbuf *rcs, } if (rcs->current.cdw > rcs->current.max_dw) { - fprintf(stderr, "amdgpu: command stream overflowed\n"); + amdgpu_ctx_set_sw_reset_status( + (struct radeon_winsys_ctx*)cs->ctx, PIPE_UNKNOWN_CONTEXT_RESET, + "amdgpu: command stream overflowed (current: %d, max: %d)\n", + rcs->current.cdw, rcs->current.max_dw); + return -1; } /* If the CS is not empty or overflowed.... */