From: "Timur Kristóf" <timur.kristof@gmail.com>
To: amd-gfx@lists.freedesktop.org,
Alex Deucher <alexander.deucher@amd.com>,
christian.koenig@amd.com, Tvrtko Ursulin <tursulin@ursulin.net>,
pierre-eric.pelloux-prayer@amd.com,
Natalie Vock <natalie.vock@gmx.de>
Cc: "Timur Kristóf" <timur.kristof@gmail.com>
Subject: [PATCH 04/11] drm/amdgpu/gfx6: Initialize compute rings before CP start
Date: Mon, 13 Jul 2026 15:07:02 +0200 [thread overview]
Message-ID: <20260713130709.34262-5-timur.kristof@gmail.com> (raw)
In-Reply-To: <20260713130709.34262-1-timur.kristof@gmail.com>
In GFX6 GPUs, compute takes the same CP path as graphics.
CP ME command parser executes packets for each ring buffer:
RB0 supports graphics, RB1 and RB2 are compute only.
Initialize all three rings before calling gfx_v6_0_cp_gfx_start()
to make sure they are all in a sane state before execution starts.
Previously, the two compute-only rings were initialized after
the ME had been already started, which could cause the ME to
start executing the ring contents before the rings could be
properly initialized. This happens to work when the HW is first
initialized, but not during an IP block reset where we want
to reinitialize the compute rings before starting the ME
to prevent it from executing garbage from these rings.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
---
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 134 ++++++++++++++------------
1 file changed, 70 insertions(+), 64 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
index 8e8e5fe487f5..ca6a62e822b1 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
@@ -2128,12 +2128,24 @@ static int gfx_v6_0_cp_gfx_start(struct amdgpu_device *adev)
return 0;
}
+/**
+ * gfx_v6_0_cp_gfx_resume() - Initialize CP rings
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * In GFX6 GPUs, compute takes the same CP path as graphics.
+ * CP ME command parser executes packets for each ring buffer:
+ * RB0 supports graphics, RB1 and RB2 are compute only.
+ * Initialize all three rings before calling gfx_v6_0_cp_gfx_start()
+ * to make sure they are all in a sane state before execution starts.
+ */
static int gfx_v6_0_cp_gfx_resume(struct amdgpu_device *adev)
{
struct amdgpu_ring *ring;
u32 tmp;
u32 rb_bufsz;
int r;
+ int i;
u64 rptr_addr;
WREG32(mmCP_SEM_WAIT_TIMER, 0x0);
@@ -2173,12 +2185,69 @@ static int gfx_v6_0_cp_gfx_resume(struct amdgpu_device *adev)
WREG32(mmCP_RB0_BASE, ring->gpu_addr >> 8);
+ /* ring 1 - compute only */
+ if (adev->gfx.num_compute_rings >= 1) {
+ ring = &adev->gfx.compute_ring[0];
+
+ rb_bufsz = order_base_2(ring->ring_size / 8);
+ tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE / 8) << 8) | rb_bufsz;
+#ifdef __BIG_ENDIAN
+ tmp |= BUF_SWAP_32BIT;
+#endif
+ WREG32(mmCP_RB1_CNTL, tmp);
+
+ WREG32(mmCP_RB1_CNTL, tmp | CP_RB1_CNTL__RB_RPTR_WR_ENA_MASK);
+ ring->wptr = 0;
+ WREG32(mmCP_RB1_WPTR, ring->wptr);
+
+ rptr_addr = ring->rptr_gpu_addr;
+ WREG32(mmCP_RB1_RPTR_ADDR, lower_32_bits(rptr_addr));
+ WREG32(mmCP_RB1_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
+
+ mdelay(1);
+ WREG32(mmCP_RB1_CNTL, tmp);
+ WREG32(mmCP_RB1_BASE, ring->gpu_addr >> 8);
+ }
+
+ /* ring 2 - compute only */
+ if (adev->gfx.num_compute_rings >= 2) {
+ ring = &adev->gfx.compute_ring[1];
+
+ rb_bufsz = order_base_2(ring->ring_size / 8);
+ tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE / 8) << 8) | rb_bufsz;
+#ifdef __BIG_ENDIAN
+ tmp |= BUF_SWAP_32BIT;
+#endif
+ WREG32(mmCP_RB2_CNTL, tmp);
+
+ WREG32(mmCP_RB2_CNTL, tmp | CP_RB2_CNTL__RB_RPTR_WR_ENA_MASK);
+ ring->wptr = 0;
+ WREG32(mmCP_RB2_WPTR, ring->wptr);
+ rptr_addr = ring->rptr_gpu_addr;
+ WREG32(mmCP_RB2_RPTR_ADDR, lower_32_bits(rptr_addr));
+ WREG32(mmCP_RB2_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
+
+ mdelay(1);
+ WREG32(mmCP_RB2_CNTL, tmp);
+ WREG32(mmCP_RB2_BASE, ring->gpu_addr >> 8);
+ }
+
/* start the rings */
gfx_v6_0_cp_gfx_start(adev);
- r = amdgpu_ring_test_helper(ring);
+
+ /* Wait for the initial packets to finish, run gfx ring test */
+ r = amdgpu_ring_test_helper(&adev->gfx.gfx_ring[0]);
if (r)
return r;
+ for (i = 0; i < adev->gfx.num_compute_rings; i++) {
+ ring = &adev->gfx.compute_ring[i];
+
+ r = amdgpu_ring_test_helper(ring);
+ if (r)
+ return r;
+ }
+
return 0;
}
@@ -2225,66 +2294,6 @@ static void gfx_v6_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
}
-static int gfx_v6_0_cp_compute_resume(struct amdgpu_device *adev)
-{
- struct amdgpu_ring *ring;
- u32 tmp;
- u32 rb_bufsz;
- int i, r;
- u64 rptr_addr;
-
- /* ring1 - compute only */
- /* Set ring buffer size */
-
- ring = &adev->gfx.compute_ring[0];
- rb_bufsz = order_base_2(ring->ring_size / 8);
- tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
-#ifdef __BIG_ENDIAN
- tmp |= BUF_SWAP_32BIT;
-#endif
- WREG32(mmCP_RB1_CNTL, tmp);
-
- WREG32(mmCP_RB1_CNTL, tmp | CP_RB1_CNTL__RB_RPTR_WR_ENA_MASK);
- ring->wptr = 0;
- WREG32(mmCP_RB1_WPTR, ring->wptr);
-
- rptr_addr = ring->rptr_gpu_addr;
- WREG32(mmCP_RB1_RPTR_ADDR, lower_32_bits(rptr_addr));
- WREG32(mmCP_RB1_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
-
- mdelay(1);
- WREG32(mmCP_RB1_CNTL, tmp);
- WREG32(mmCP_RB1_BASE, ring->gpu_addr >> 8);
-
- ring = &adev->gfx.compute_ring[1];
- rb_bufsz = order_base_2(ring->ring_size / 8);
- tmp = (order_base_2(AMDGPU_GPU_PAGE_SIZE/8) << 8) | rb_bufsz;
-#ifdef __BIG_ENDIAN
- tmp |= BUF_SWAP_32BIT;
-#endif
- WREG32(mmCP_RB2_CNTL, tmp);
-
- WREG32(mmCP_RB2_CNTL, tmp | CP_RB2_CNTL__RB_RPTR_WR_ENA_MASK);
- ring->wptr = 0;
- WREG32(mmCP_RB2_WPTR, ring->wptr);
- rptr_addr = ring->rptr_gpu_addr;
- WREG32(mmCP_RB2_RPTR_ADDR, lower_32_bits(rptr_addr));
- WREG32(mmCP_RB2_RPTR_ADDR_HI, upper_32_bits(rptr_addr) & 0xFF);
-
- mdelay(1);
- WREG32(mmCP_RB2_CNTL, tmp);
- WREG32(mmCP_RB2_BASE, ring->gpu_addr >> 8);
-
-
- for (i = 0; i < 2; i++) {
- r = amdgpu_ring_test_helper(&adev->gfx.compute_ring[i]);
- if (r)
- return r;
- }
-
- return 0;
-}
-
static void gfx_v6_0_cp_enable(struct amdgpu_device *adev, bool enable)
{
gfx_v6_0_cp_gfx_enable(adev, enable);
@@ -2334,9 +2343,6 @@ static int gfx_v6_0_cp_resume(struct amdgpu_device *adev)
return r;
r = gfx_v6_0_cp_gfx_resume(adev);
- if (r)
- return r;
- r = gfx_v6_0_cp_compute_resume(adev);
if (r)
return r;
--
2.55.0
next prev parent reply other threads:[~2026-07-13 13:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 13:06 [PATCH 00/11] drm/amdgpu/gfx6: Use GFX IP block soft reset on GFX6 Timur Kristóf
2026-07-13 13:06 ` [PATCH 01/11] drm/amdgpu/gfx6: Improve emit_cntxcntl() Timur Kristóf
2026-07-13 13:07 ` [PATCH 02/11] drm/amdgpu/gfx6: Fixup emitting SWITCH_BUFFER packets Timur Kristóf
2026-07-13 13:07 ` [PATCH 03/11] drm/amdgpu/gfx6: Use PFP on the compute queues too Timur Kristóf
2026-07-13 13:07 ` Timur Kristóf [this message]
2026-07-13 13:07 ` [PATCH 05/11] drm/amdgpu/gfx6: Clean up rings during reset Timur Kristóf
2026-07-13 13:07 ` [PATCH 06/11] drm/amdgpu/gfx6: Execute CLEAR_STATE when initializing compute rings Timur Kristóf
2026-07-13 13:07 ` [PATCH 07/11] drm/amdgpu/gfx6: Properly enable/disable priv_req and priv_inst interrupts Timur Kristóf
2026-07-15 10:19 ` Tvrtko Ursulin
2026-07-15 10:53 ` Timur Kristóf
2026-07-15 11:22 ` Tvrtko Ursulin
2026-07-13 13:07 ` [PATCH 08/11] drm/amdgpu/gfx6: Adjust how harvested TCCs are set up Timur Kristóf
2026-07-13 13:07 ` [PATCH 09/11] drm/amdgpu/gfx6: Use COND_EXEC Timur Kristóf
2026-07-13 13:07 ` [PATCH 10/11] drm/amdgpu/gfx6: Add IP block soft reset implementation Timur Kristóf
2026-07-13 13:07 ` [PATCH 11/11] drm/amdgpu/gfx6: Enable IP block soft reset as a GPU recovery method Timur Kristóf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260713130709.34262-5-timur.kristof@gmail.com \
--to=timur.kristof@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=natalie.vock@gmx.de \
--cc=pierre-eric.pelloux-prayer@amd.com \
--cc=tursulin@ursulin.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.