From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A314264F8A; Sun, 1 Jun 2025 23:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748820373; cv=none; b=Dm0HJN5Xkg5tlWYuyvG8Ama3h46W4edVNAUFp5hodrinEbdZ2sYhmq6PnqttiDLx4xDGMDSVwqPQ6jHbm9PG+Hsd5iW1/dbzY63K0FH0GK4zTzrD7U1cYa7/imXF1niQS76UZwP68hucl1ZrUSTJmDOWHM2r3/9SUlKgn/cjAm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748820373; c=relaxed/simple; bh=Uad+awJZ+IQ1eu1cNI06Q6fba1AUketKvqh48VTsdek=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=bQqJmOD7pF9lmdYmB9QOoSwFn0KfDDCwdStduGDGcNIraBGa/oogVn44I9tDMHurKQyn3po8G4GNxEq5x5qt1TKrLWfkEZTDMZveRGBVhXNkmrtncCxH/Ckx0TtIidpVAlzUjnpjS6M9wpkLhZ6ww/owILIKAxROlEVpqMIraXI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X+/r90Ky; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X+/r90Ky" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DEB9C4CEEE; Sun, 1 Jun 2025 23:26:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748820373; bh=Uad+awJZ+IQ1eu1cNI06Q6fba1AUketKvqh48VTsdek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X+/r90KyjkFXWXGP5L+eOIKXqzwaI4pRxHFudyvavUhYzb1eNIR2c17eJCoS9IOe4 ymcjZ8iWfamJF+VkXTB0Q6DTStLJ+FkS+TiGzKty2p5G3R9g5f5e1x15HPqAYAfo9H r82OQbLh9CY2upVbj5Noh4FHLDTiGx7Mq4Ux+HVLHXIMSBd71dzEjyg+5txal0FUEu jf7dn0TmT5UT5sKFtLLGcBJDrBUVDi5jlyyQlmEoLJY5lBhjOVJVLTkw7KMjo/Uh2O Z2S4ZE9hi6PD4sP+67lEqj2fr3c9MjW+9TxHbk0rj7nbzjvUeArVKC44j68oQkXbff sSOZ5MX4GSl9g== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Alex Deucher , Rodrigo Siqueira , Sasha Levin , christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch, sunil.khatri@amd.com, srinivasan.shanmugam@amd.com, vitaly.prosyak@amd.com, Jesse.zhang@amd.com, Jiadong.Zhu@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH AUTOSEL 6.15 037/110] drm/amdgpu/gfx10: fix CSIB handling Date: Sun, 1 Jun 2025 19:23:19 -0400 Message-Id: <20250601232435.3507697-37-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250601232435.3507697-1-sashal@kernel.org> References: <20250601232435.3507697-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.15 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Alex Deucher [ Upstream commit 683308af030cd9b8d3f1de5cbc1ee51788878feb ] We shouldn't return after the last section. We need to update the rest of the CSIB. Reviewed-by: Rodrigo Siqueira Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- **YES** This commit should be backported to stable kernel trees. ## Detailed Analysis: ### The Bug The commit fixes a critical bug in the `gfx_v10_0_get_csb_buffer()` function in `/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c`. The function is responsible for building a Command Stream Buffer (CSB) for GPU initialization. **The problematic code before the fix:** ```c for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { for (ext = sect->section; ext->extent != NULL; ++ext) { 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; // ← BUG: Early return prevents rest of buffer initialization } } } ``` **The fix removes the early return:** ```c for (sect = adev->gfx.rlc.cs_data; sect->section != NULL; ++sect) { for (ext = sect->section; ext->extent != NULL; ++ext) { 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 - now continues to process rest of buffer } } ``` ### Why This Should Be Backported: 1. **Fixes Important GPU Initialization Bug**: This is a clear functional bug that affects AMDGPU GFX10 hardware. Looking at the clearstate data structure, I can see that `gfx10_cs_data[]` contains only `SECT_CONTEXT` sections, but if any future section was not `SECT_CONTEXT`, the early return would prevent critical buffer initialization from completing. 2. **Affects Critical Hardware Functionality**: The CSB (Command Stream Buffer) is essential for proper GPU initialization. An incomplete buffer could lead to: - GPU hang during initialization - Incorrect register states - System instability - Failed GPU bring-up 3. **Small, Contained Fix**: The fix is minimal - it simply removes an erroneous `else { return; }` clause. This has very low risk of introducing regressions. 4. **No Architectural Changes**: This doesn't change any APIs, interfaces, or architectural decisions. It's a pure bugfix. 5. **Follows Stable Tree Criteria**: - Important bugfix ✓ - Minimal risk ✓ - Confined to a subsystem ✓ - No new features ✓ 6. **Critical GPU Subsystem**: The commit touches GPU command submission infrastructure, which is critical for system stability when AMD GFX10 hardware is present. 7. **Clear Commit Message**: The commit message clearly explains the bug: "We shouldn't return after the last section. We need to update the rest of the CSIB." Looking at the reference commits, this aligns with "Similar Commit #4" which was marked YES for backporting - it's a clear functional bugfix in critical GPU subsystem code that prevents proper operation. The missing code after the early return includes essential buffer finalization: - Setting PA_SC_TILE_STEERING_OVERRIDE register - Adding PACKET3_PREAMBLE_END_CLEAR_STATE - Adding PACKET3_CLEAR_STATE command Without these, the GPU's clear state buffer would be incomplete, potentially causing initialization failures. drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c index 23e6a05359c24..82c9ad9af5177 100644 --- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c @@ -4322,8 +4322,6 @@ static void gfx_v10_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; } } } -- 2.39.5