From: Ramesh Errabolu <Ramesh.Errabolu@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Ramesh Errabolu <Ramesh.Errabolu@amd.com>
Subject: [PATCH] drm/amdgpu: Apply IH Ptr mask after updating IH Read Ptr
Date: Wed, 7 Aug 2024 20:42:34 -0500 [thread overview]
Message-ID: <20240808014234.1165123-1-Ramesh.Errabolu@amd.com> (raw)
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
reply other threads:[~2024-08-08 1:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240808014234.1165123-1-Ramesh.Errabolu@amd.com \
--to=ramesh.errabolu@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox