From: "Christian König" <christian.koenig@amd.com>
To: "Srinivasan Shanmugam" <srinivasan.shanmugam@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Guchun Chen" <guchun.chen@amd.com>,
"Pan Xinhui" <Xinhui.Pan@amd.com>
Cc: Le Ma <le.ma@amd.com>,
amd-gfx@lists.freedesktop.org,
Hawking Zhang <Hawking.Zhang@amd.com>
Subject: Re: [PATCH] drm/amdgpu: Use READ_ONCE() when reading the values in 'sdma_v4_4_2_ring_get_rptr'
Date: Mon, 21 Aug 2023 13:23:37 +0200 [thread overview]
Message-ID: <8210ebe4-b637-5aaf-c548-b2a4be718f98@amd.com> (raw)
In-Reply-To: <20230804054641.3250542-1-srinivasan.shanmugam@amd.com>
Am 04.08.23 um 07:46 schrieb Srinivasan Shanmugam:
> Instead of declaring pointers use READ_ONCE(), when accessing those
> values to make sure that the compiler doesn't voilate any cache
> coherences
That commit message is a bit confusing and not 100% technically correct.
The compiler is not causing any cache coherency issues, but potentially
re-ordering things or reading the value multiple times.
Just write something like "Use READ_ONCE() instead of declaring the
pointer volatile.". The background explanation would exceed the
information suitable for a commit message anyway.
Apart from that looks good to me,
Christian.
>
> Cc: Guchun Chen <guchun.chen@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
> Cc: Le Ma <le.ma@amd.com>
> Cc: Hawking Zhang <Hawking.Zhang@amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> index f413898dda37..267c1b7b8dcd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c
> @@ -154,13 +154,13 @@ static int sdma_v4_4_2_init_microcode(struct amdgpu_device *adev)
> */
> static uint64_t sdma_v4_4_2_ring_get_rptr(struct amdgpu_ring *ring)
> {
> - u64 *rptr;
> + u64 rptr;
>
> /* XXX check if swapping is necessary on BE */
> - rptr = ((u64 *)&ring->adev->wb.wb[ring->rptr_offs]);
> + rptr = READ_ONCE(*((u64 *)&ring->adev->wb.wb[ring->rptr_offs]));
>
> - DRM_DEBUG("rptr before shift == 0x%016llx\n", *rptr);
> - return ((*rptr) >> 2);
> + DRM_DEBUG("rptr before shift == 0x%016llx\n", rptr);
> + return rptr >> 2;
> }
>
> /**
next prev parent reply other threads:[~2023-08-21 11:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-04 5:46 [PATCH] drm/amdgpu: Use READ_ONCE() when reading the values in 'sdma_v4_4_2_ring_get_rptr' Srinivasan Shanmugam
2023-08-18 11:26 ` Ma, Le
2023-08-21 11:23 ` Christian König [this message]
2023-08-21 20:49 ` Felix Kuehling
2023-08-22 9:53 ` Christian König
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=8210ebe4-b637-5aaf-c548-b2a4be718f98@amd.com \
--to=christian.koenig@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=guchun.chen@amd.com \
--cc=le.ma@amd.com \
--cc=srinivasan.shanmugam@amd.com \
/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