summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Kristóf <timur.kristof@gmail.com>2026-09-08 20:10:48 +0200
committerAlex Deucher <alexander.deucher@amd.com>2026-09-17 11:38:27 -0400
commitde73eb26f90d6fcab431928fa5f68448ddbf697e (patch)
treebf5cd7c96156ca0cddf3579441cef12c5e0e9f3d
parent3eb5587e133849a47554949190200107368358ff (diff)
downloadlinux-next-de73eb26f90d6fcab431928fa5f68448ddbf697e.tar.gz
linux-next-de73eb26f90d6fcab431928fa5f68448ddbf697e.zip
drm/amdgpu: Add amdgpu_ring_clear_ring_and_ptrs()
A new helper function which clears the contents of a ring and the relevant pointers such as rptr/wptr. Suggested-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
index 61e30de1977b..49df2c4745a1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
@@ -488,6 +488,25 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring)
memset32(ring->ring, ring->funcs->nop, ring->buf_mask + 1);
}
+static inline void amdgpu_ring_clear_ring_and_ptrs(struct amdgpu_ring *ring)
+{
+ /* Clear the contents of the ring. */
+ amdgpu_ring_clear_ring(ring);
+
+ /* Clear the ring pointers on the CPU. */
+ ring->wptr = 0;
+
+ /*
+ * Clear the ring pointers allocated in writeback.
+ *
+ * Note: we always allocate 64 bits for these pointers,
+ * but older HW generations only use the lower 32 bits.
+ * Use 64-bit atomics for simplicity.
+ */
+ atomic64_set((atomic64_t *)ring->wptr_cpu_addr, 0);
+ atomic64_set((atomic64_t *)ring->rptr_cpu_addr, 0);
+}
+
static inline void amdgpu_ring_write(struct amdgpu_ring *ring, uint32_t v)
{
ring->ring[ring->wptr++ & ring->buf_mask] = v;