From: sashiko-bot@kernel.org
To: "David Zhang" <yidong.zhang@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH V2 13/20] accel/amdxdna: Prepare for AIE4 command submission
Date: Tue, 06 Oct 2026 04:35:07 +0000 [thread overview]
Message-ID: <20261006043508.5FF721F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261006042230.547807-14-yidong.zhang@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] amdxdna: monotonic regression in get_read_index() due to lockless update
--
commit 556cf69a63f5758be4c65cd88bedd02f3117e2ca
Author: David Zhang <yidong.zhang@amd.com>
accel/amdxdna: Prepare for AIE4 command submission
This commit prepares data structures and completion wait helpers for AIE4
command submission. It extends the amdxdna_job_priv structure and implements
an ordered retry mechanism in get_read_index() when a torn read is detected.
> diff --git a/drivers/accel/amdxdna/aie4_ctx.c b/drivers/accel/amdxdna/aie4_ctx.c
> --- a/drivers/accel/amdxdna/aie4_ctx.c
> +++ b/drivers/accel/amdxdna/aie4_ctx.c
[ ... ]
> static u64 get_read_index(struct amdxdna_hwctx *hwctx)
> {
[ ... ]
> + /*
> + * Cache valid sample as fallback for torn reads. Lockless on purpose:
> + * a racing caller may store an older value, which only delays seeing
> + * a completion until the next wakeup, never reports one early.
> + */
> + WRITE_ONCE(priv->last_read_index, ri);
[Severity: Medium]
Can this lockless assignment allow concurrent get_read_index() callers to
overwrite a newer completion index with an older one?
For example, if Thread A reads ri=10, and Thread B reads ri=11 and writes
last_read_index=11, could Thread A then execute this assignment and write
last_read_index=10? This appears to cause last_read_index to go backward.
> return ri;
> }
[ ... ]
> int aie4_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq, u32 timeout)
> {
[ ... ]
> - if (!ret)
> + if (!ret) {
> ret = -ETIME;
> + } else if (ret > 0 && !check_cert_comp_linked(hwctx, cert_comp) &&
> + get_read_index(hwctx) <= seq) {
[Severity: Medium]
If last_read_index went backward as described above, could this check
falsely evaluate to true?
If a torn read falls back to the stale last_read_index while the device
disconnects or suspends, it seems a successfully completed command might
incorrectly fail and return -EAGAIN.
> + /* Disconnect (suspend or TDR) before the command completed. */
> + ret = -EAGAIN;
> + }
>
> aie4_put_cert_comp(cert_comp);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261006042230.547807-1-yidong.zhang@amd.com?part=13
next prev parent reply other threads:[~2026-10-06 4:35 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 4:22 [PATCH V2 00/20] accel/amdxdna: Kernel submission and PM for AIE4 David Zhang
2026-10-06 4:22 ` [PATCH V2 01/20] accel/amdxdna: Rename NPU3 firmware files David Zhang
2026-10-06 4:22 ` [PATCH V2 02/20] accel/amdxdna: Remove mmap for doorbell David Zhang
2026-10-06 4:22 ` [PATCH V2 03/20] accel/amdxdna: Add CERT firmware version support David Zhang
2026-10-06 4:22 ` [PATCH V2 04/20] accel/amdxdna: Upgrade firmware version to 6.0 David Zhang
2026-10-06 4:22 ` [PATCH V2 05/20] accel/amdxdna: Add NPU3 classic device support David Zhang
2026-10-06 4:22 ` [PATCH V2 06/20] accel/amdxdna: Add AIE version query to aie4_get_info David Zhang
2026-10-06 4:22 ` [PATCH V2 07/20] accel/amdxdna: Add get and set power_mode for AIE4 David Zhang
2026-10-06 4:22 ` [PATCH V2 08/20] accel/amdxdna: Add clock, DPM frequency, and resource info queries " David Zhang
2026-10-06 4:22 ` [PATCH V2 09/20] accel/amdxdna: Add context switch hysteresis with debugfs control David Zhang
2026-10-06 4:35 ` sashiko-bot
2026-10-06 4:22 ` [PATCH V2 10/20] accel/amdxdna: Refactor AIE4 hardware initialization sequence David Zhang
2026-10-06 4:22 ` [PATCH V2 11/20] accel/amdxdna: Decouple AIE4 doorbell and MSI-X notify transport hooks David Zhang
2026-10-06 4:22 ` [PATCH V2 12/20] accel/amdxdna: Implement AIE4 kernel queue lifecycle and memory layout David Zhang
2026-10-06 4:22 ` [PATCH V2 13/20] accel/amdxdna: Prepare for AIE4 command submission David Zhang
2026-10-06 4:35 ` sashiko-bot [this message]
2026-10-06 4:22 ` [PATCH V2 14/20] accel/amdxdna: Implement AIE4 command packet building and submission David Zhang
2026-10-06 4:41 ` sashiko-bot
2026-10-06 7:12 ` Eva Crystal
2026-10-07 22:54 ` Zhang, Yidong (David)
2026-10-06 4:22 ` [PATCH V2 15/20] accel/amdxdna: Make hmm_invalidate common for AIE2 and AIE4 David Zhang
2026-10-06 4:22 ` [PATCH V2 16/20] accel/amdxdna: Finalize runtime PM before acquiring dev_lock on removal David Zhang
2026-10-06 7:13 ` Eva Crystal
2026-10-06 17:01 ` Lizhi Hou
2026-10-07 1:18 ` Eva Crystal
2026-10-06 4:22 ` [PATCH V2 17/20] accel/amdxdna: Implement AIE4 suspend and resume David Zhang
2026-10-06 4:22 ` [PATCH V2 18/20] accel/amdxdna: Link SR-IOV VFs for power management sequencing David Zhang
2026-10-06 4:35 ` sashiko-bot
2026-10-06 4:22 ` [PATCH V2 19/20] accel/amdxdna: Implement runtime suspend and resume support David Zhang
2026-10-06 4:43 ` sashiko-bot
2026-10-06 4:22 ` [PATCH V2 20/20] accel/amdxdna: Enable AIE4 firmware logging to DRAM David Zhang
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=20261006043508.5FF721F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yidong.zhang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.