mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Runyu Xiao <runyu.xiao@seu.edu.cn>, alexander.deucher@amd.com
Cc: airlied@gmail.com, simona@ffwll.ch, kevinyang.wang@amd.com,
	kenneth.feng@amd.com, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	jianhao.xu@seu.edu.cn
Subject: Re: [RFC PATCH v2 1/5] drm/amdgpu: add typed helpers for ring writeback slots
Date: Fri, 17 Jul 2026 09:26:02 +0200	[thread overview]
Message-ID: <6288019f-b026-42d6-997a-5c322c9d0520@amd.com> (raw)
In-Reply-To: <20260717033009.649538-2-runyu.xiao@seu.edu.cn>

On 7/17/26 05:30, Runyu Xiao wrote:
> AMDGPU ring writeback slots are currently accessed with a mix of direct
> pointer dereferences, casted u64 accesses, READ_ONCE()/WRITE_ONCE() on
> casted pointers,

Clear NAK to that.

Those differentiation are completely intentional and exits for documentation purposes.

> and atomic64_t casts.

Well that is clearly problematic, where do you see that?

> Add small typed helpers for reading and writing 32-bit and 64-bit ring
> writeback slots. This makes the intended slot width explicit at each
> call site and provides a single access model for the later cleanup
> patches in this series.

That's just nonsense.

The writeback pointers not only vary between 32 and 64bits but are sometimes full 256bits with all kind of information in them.

In general it should be a 32bit pointer which can be indexed and/or cast to 64bit if necessary.

Regards,
Christian.

> 
> This patch only introduces the helpers and does not change any existing
> call site behavior.
> 
> Signed-off-by: Runyu Xiao <runyu.xiao@seu.edu.cn>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> index 8f28b3bd7..cdc855285 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
> @@ -457,6 +457,26 @@ struct amdgpu_ring {
>  #define amdgpu_ring_patch_de(r, o) ((r)->funcs->patch_de((r), (o)))
>  #define amdgpu_ring_reset(r, v, f) (r)->funcs->reset((r), (v), (f))
>  
> +static inline u32 amdgpu_ring_wb_read32(const void *cpu_addr)
> +{
> +	return READ_ONCE(*(const u32 *)cpu_addr);
> +}
> +
> +static inline void amdgpu_ring_wb_write32(void *cpu_addr, u32 value)
> +{
> +	WRITE_ONCE(*(u32 *)cpu_addr, value);
> +}
> +
> +static inline u64 amdgpu_ring_wb_read64(const void *cpu_addr)
> +{
> +	return READ_ONCE(*(const u64 *)cpu_addr);
> +}
> +
> +static inline void amdgpu_ring_wb_write64(void *cpu_addr, u64 value)
> +{
> +	WRITE_ONCE(*(u64 *)cpu_addr, value);
> +}
> +
>  unsigned int amdgpu_ring_max_ibs(enum amdgpu_ring_type type);
>  int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw);
>  void amdgpu_ring_ib_begin(struct amdgpu_ring *ring);


  reply	other threads:[~2026-07-17  7:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  3:30 [RFC PATCH v2 0/5] drm/amdgpu: rework ring writeback pointer accesses Runyu Xiao
2026-07-17  3:30 ` [RFC PATCH v2 1/5] drm/amdgpu: add typed helpers for ring writeback slots Runyu Xiao
2026-07-17  7:26   ` Christian König [this message]
2026-07-17  3:30 ` [RFC PATCH v2 2/5] drm/amdgpu: convert 32-bit ring writeback accesses to helpers Runyu Xiao
2026-07-17  3:30 ` [RFC PATCH v2 3/5] drm/amdgpu: convert 64-bit " Runyu Xiao
2026-07-17  3:30 ` [RFC PATCH v2 4/5] drm/amdgpu: make ring rptr_cpu_addr and wptr_cpu_addr typeless Runyu Xiao
2026-07-17  3:30 ` [RFC PATCH v2 5/5] drm/amdgpu/mes: reset full 64-bit wptr in queue init Runyu Xiao

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=6288019f-b026-42d6-997a-5c322c9d0520@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=kenneth.feng@amd.com \
    --cc=kevinyang.wang@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=runyu.xiao@seu.edu.cn \
    --cc=simona@ffwll.ch \
    /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

all inboxes | Powered by JetHome®