From: Alex Deucher alexander.deucher@amd.com
[ Upstream commit a4a4c0ae6742ec7d6bf1548d2c6828de440814a0 ]
We shouldn't return after the last section. We need to update the rest of the CSIB.
Reviewed-by: Rodrigo Siqueira siqueira@igalia.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Sasha Levin sashal@kernel.org ---
Now I'll analyze the specific code changes and provide my backport recommendation: **YES** This commit should be backported to stable kernel trees. Here's my detailed analysis: ## Code Analysis The commit fixes a logic bug in the `gfx_v9_0_get_csb_buffer()` function that builds GPU command buffers for AMD GFX9 hardware. Looking at the code change: **Before:** ```c if (sect->id == SECT_CONTEXT) { buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); buffer[count++] = cpu_to_le32(ext->reg_index - PACKET3_SET_CONTEXT_REG_START); for (i = 0; i < ext->reg_count; i++) buffer[count++] = cpu_to_le32(ext->extent[i]); } else { return; // ← BUGGY early return } ``` **After:** ```c if (sect->id == SECT_CONTEXT) { buffer[count++] = cpu_to_le32(PACKET3(PACKET3_SET_CONTEXT_REG, ext->reg_count)); buffer[count++] = cpu_to_le32(ext->reg_index - PACKET3_SET_CONTEXT_REG_START); for (i = 0; i < ext->reg_count; i++) buffer[count++] = cpu_to_le32(ext->extent[i]); } // ← Early return removed, execution continues ``` ## Why This Should Be Backported ### 1. **Fixes a Clear Logic Bug** The early return prevents the function from completing its work. After the loop, the function needs to write critical termination packets: ```c buffer[count++] = cpu_to_le32(PACKET3(PACKET3_PREAMBLE_CNTL, 0)); buffer[count++] = cpu_to_le32(PACKET3_PREAMBLE_END_CLEAR_STATE); buffer[count++] = cpu_to_le32(PACKET3(PACKET3_CLEAR_STATE, 0)); buffer[count++] = cpu_to_le32(0); ``` ### 2. **Meets Stable Tree Criteria** - **Small and contained**: Simple one-line removal with clear intent - **Low regression risk**: Removing early return allows proper completion - **Important bug fix**: Prevents GPU command buffer corruption - **No architectural changes**: Pure bug fix without new features ### 3. **Comparison with Historical Examples** Looking at the provided historical commits, this fix is similar to commit #3 (marked YES) which also fixed preamble handling. Both commits: - Fix logic bugs in AMD GPU driver - Have minimal code changes - Address proper command/state handling - Are critical for correct driver operation ### 4. **Stability Impact** While currently masked because all existing clear state data only uses `SECT_CONTEXT` sections, this bug creates: - **Buffer corruption risk**: Incomplete command buffers sent to GPU - **Forward compatibility issues**: Future hardware might use other section types - **Inconsistent state**: Size calculation function has same bug pattern ### 5. **Hardware Criticality** This affects the GFX9 generation which includes widely deployed GPUs like: - Vega series (RX Vega 56/64) - Raven Ridge APUs (Ryzen 2000G/3000G series) - Renoir APUs (Ryzen 4000 series) ### 6. **Clear Commit Message** The commit message explicitly states "We need to update the rest of the CSIB" - indicating this fixes incomplete processing, exactly what stable backports target. **Conclusion**: This is a textbook stable backport candidate - a small, contained fix for a clear logic bug in a critical GPU initialization path that could lead to hardware instability. The risk/reward ratio strongly favors backporting.
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c index 811cacacc2090..6cc382197378d 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c @@ -1782,8 +1782,6 @@ static void gfx_v9_0_get_csb_buffer(struct amdgpu_device *adev, PACKET3_SET_CONTEXT_REG_START); for (i = 0; i < ext->reg_count; i++) buffer[count++] = cpu_to_le32(ext->extent[i]); - } else { - return; } } }