AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Apply IH Ptr mask after updating IH Read Ptr
@ 2024-08-08  1:42 Ramesh Errabolu
  0 siblings, 0 replies; only message in thread
From: Ramesh Errabolu @ 2024-08-08  1:42 UTC (permalink / raw)
  To: amd-gfx; +Cc: Ramesh Errabolu

Apply IH Ptr mask immediately after updating to IH Read ptr.
Ideally the operation to update and mask should be atomic. This
will ensure that Read Ptr points to a valid index in the IH
ring buffer.

Signed-off-by: Ramesh Errabolu <Ramesh.Errabolu@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c  | 5 ++++-
 drivers/gpu/drm/amd/amdgpu/cik_ih.c     | 5 ++++-
 drivers/gpu/drm/amd/amdgpu/cz_ih.c      | 5 ++++-
 drivers/gpu/drm/amd/amdgpu/iceland_ih.c | 5 ++++-
 drivers/gpu/drm/amd/amdgpu/si_ih.c      | 4 ++++
 drivers/gpu/drm/amd/amdgpu/tonga_ih.c   | 5 ++++-
 6 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
index f3b0aaf3ebc6..2fd13d424213 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ih.c
@@ -280,8 +280,11 @@ void amdgpu_ih_decode_iv_helper(struct amdgpu_device *adev,
 	entry->src_data[2] = dw[6];
 	entry->src_data[3] = dw[7];
 
-	/* wptr/rptr are in bytes! */
+	/* Apply IH Ptr mask after adding sizeof(Intrpt)
+	 * bytes to IH Read ptr
+	 */
 	ih->rptr += 32;
+	ih->rptr &= ih->ptr_mask;
 }
 
 uint64_t amdgpu_ih_decode_iv_ts_helper(struct amdgpu_ih_ring *ih, u32 rptr,
diff --git a/drivers/gpu/drm/amd/amdgpu/cik_ih.c b/drivers/gpu/drm/amd/amdgpu/cik_ih.c
index 576baa9dbb0e..41c0c56d41f6 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_ih.c
@@ -265,8 +265,11 @@ static void cik_ih_decode_iv(struct amdgpu_device *adev,
 	entry->vmid = (dw[2] >> 8) & 0xff;
 	entry->pasid = (dw[2] >> 16) & 0xffff;
 
-	/* wptr/rptr are in bytes! */
+	/* Apply IH Ptr mask after adding sizeof(Intrpt)
+	 * bytes to IH Read ptr
+	 */
 	ih->rptr += 16;
+	ih->rptr &= ih->ptr_mask;
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/cz_ih.c b/drivers/gpu/drm/amd/amdgpu/cz_ih.c
index 072643787384..a94ddecc3d33 100644
--- a/drivers/gpu/drm/amd/amdgpu/cz_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/cz_ih.c
@@ -256,8 +256,11 @@ static void cz_ih_decode_iv(struct amdgpu_device *adev,
 	entry->vmid = (dw[2] >> 8) & 0xff;
 	entry->pasid = (dw[2] >> 16) & 0xffff;
 
-	/* wptr/rptr are in bytes! */
+	/* Apply IH Ptr mask after adding sizeof(Intrpt)
+	 * bytes to IH Read ptr
+	 */
 	ih->rptr += 16;
+	ih->rptr &= ih->ptr_mask;
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
index 07984f7c3ae7..d47f008110ba 100644
--- a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c
@@ -255,8 +255,11 @@ static void iceland_ih_decode_iv(struct amdgpu_device *adev,
 	entry->vmid = (dw[2] >> 8) & 0xff;
 	entry->pasid = (dw[2] >> 16) & 0xffff;
 
-	/* wptr/rptr are in bytes! */
+	/* Apply IH Ptr mask after adding sizeof(Intrpt)
+	 * bytes to IH Read ptr
+	 */
 	ih->rptr += 16;
+	ih->rptr &= ih->ptr_mask;
 }
 
 /**
diff --git a/drivers/gpu/drm/amd/amdgpu/si_ih.c b/drivers/gpu/drm/amd/amdgpu/si_ih.c
index 5237395e4fab..9e51024f1851 100644
--- a/drivers/gpu/drm/amd/amdgpu/si_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/si_ih.c
@@ -147,7 +147,11 @@ static void si_ih_decode_iv(struct amdgpu_device *adev,
 	entry->ring_id = dw[2] & 0xff;
 	entry->vmid = (dw[2] >> 8) & 0xff;
 
+	/* Apply IH Ptr mask after adding sizeof(Intrpt)
+	 * bytes to IH Read ptr
+	 */
 	ih->rptr += 16;
+	ih->rptr &= ih->ptr_mask;
 }
 
 static void si_ih_set_rptr(struct amdgpu_device *adev,
diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
index 24d49d813607..db3c7aeb9425 100644
--- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c
@@ -259,8 +259,11 @@ static void tonga_ih_decode_iv(struct amdgpu_device *adev,
 	entry->vmid = (dw[2] >> 8) & 0xff;
 	entry->pasid = (dw[2] >> 16) & 0xffff;
 
-	/* wptr/rptr are in bytes! */
+	/* Apply IH Ptr mask after adding sizeof(Intrpt)
+	 * bytes to IH Read ptr
+	 */
 	ih->rptr += 16;
+	ih->rptr &= ih->ptr_mask;
 }
 
 /**
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-08-08  1:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08  1:42 [PATCH] drm/amdgpu: Apply IH Ptr mask after updating IH Read Ptr Ramesh Errabolu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox