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@xxxxxxx> --- 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