From: sashiko-bot@kernel.org
To: "Gregory Williams" <gregory.williams@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 13/15] accel/amd-ai-engine: Add pm ops for firmware calls
Date: Wed, 18 Nov 2026 23:46:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-222211@kernel.org> (raw)
In-Reply-To: <20261118233211.4121361-14-gregory.williams@amd.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] accel/amd-ai-engine: spurious goto again after flush in
aie_part_pm_ops()
- [Low] accel/amd-ai-engine: missing @loc kernel-doc in
aie_op_handshake_data
- [Low] accel/amd-ai-engine: 32-bit shift overflow on dma_addr_t in
aie_part_pm_ops()
--
commit d2e06ea50ba27d65c500c4af65cd1c3eb56d05cf
Author: Gregory Williams <gregory.williams@amd.com>
accel/amd-ai-engine: Add pm ops for firmware calls
This commit adds platform management operation structures and helpers to
pack and flush privileged AI Engine register operations to trusted
firmware via coherent DMA buffers.
> diff --git a/drivers/accel/amd-ai-engine/ai-engine-pm.c b/drivers/accel/amd-ai-engine/ai-engine-pm.c
> new file mode 100644
> index 0000000000000..103879456f520
> --- /dev/null
> +++ b/drivers/accel/amd-ai-engine/ai-engine-pm.c
> @@ -0,0 +1,472 @@
[ ... ]
> +int aie_part_pm_ops(struct aie_partition *apart, void *data, u32 type,
> + struct aie_range range, bool flush)
> +{
> + struct aie_pm_ops *pm_ops = &apart->pm_ops;
> + struct aie_op_start_num_col *op_range;
> + ssize_t end;
> + int ret = 0;
> +
> +again:
> + op_range = pm_ops->op_range;
> + if (!op_range ||
> + op_range->num_col != range.size.col ||
> + op_range->start_col != range.start.col) {
> + if (check_add_overflow(pm_ops->offset, sizeof(*op_range), &end) ||
> + end >= pm_ops->size) {
> + ret = aie_part_pm_ops_flush(apart);
> + if (ret)
> + return ret;
> + }
> + pm_ops->op_range = pm_ops->pkt_va + pm_ops->offset;
> + pm_ops->offset += sizeof(*pm_ops->op_range);
> + op_range = pm_ops->op_range;
> + op_range->type = XILINX_AIE_OPS_START_NUM_COL;
> + op_range->start_col = range.start.col;
> + op_range->num_col = range.size.col;
> + op_range->len = sizeof(*op_range);
> + }
[ ... ]
> + if (type & AIE_PART_INIT_OPT_HW_ERR_STS) {
> + struct aie_op_hw_err *op;
> +
> + if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
> + end >= pm_ops->size) {
> + ret = aie_part_pm_ops_flush(apart);
> + if (ret)
> + return ret;
> + goto again;
> + }
> + type &= ~AIE_PART_INIT_OPT_HW_ERR_STS;
> + op = pm_ops->pkt_va + pm_ops->offset;
> + pm_ops->offset += sizeof(*op);
> + op->type = XILINX_AIE_OPS_CLR_HW_ERR_STS;
> + op->len = sizeof(*op);
> + op->val = *((u16 *)data);
> + ret = aie_part_pm_ops_flush(apart);
> + if (ret)
> + return ret;
> + goto again;
> + }
> + if (type & AIE_PART_INIT_OPT_DIS_TLAST_ERROR) {
> + struct aie_op_tlast *op;
> +
> + if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
> + end >= pm_ops->size) {
> + ret = aie_part_pm_ops_flush(apart);
> + if (ret)
> + return ret;
> + goto again;
> + }
> + type &= ~AIE_PART_INIT_OPT_DIS_TLAST_ERROR;
> + op = pm_ops->pkt_va + pm_ops->offset;
> + pm_ops->offset += sizeof(*op);
> + op->type = XILINX_AIE_OPS_CTRL_PKT_TLAST_ERR;
> + op->len = sizeof(*op);
> + op->state = *((u16 *)data);
> + }
> + if (type & AIE_PART_INIT_OPT_HANDSHAKE) {
> + struct aie_op_handshake *op;
> + struct aie_op_handshake_addr *hs_addr = data;
> +
> + if (check_add_overflow(pm_ops->offset, sizeof(*op), &end) ||
> + end >= pm_ops->size) {
> + ret = aie_part_pm_ops_flush(apart);
> + if (ret)
> + return ret;
> + goto again;
> + }
> +
> + type &= ~AIE_PART_INIT_OPT_HANDSHAKE;
> + op = pm_ops->pkt_va + pm_ops->offset;
> + pm_ops->offset += sizeof(*op);
> + op->type = XILINX_AIE_OPS_HANDSHAKE;
> + op->len = sizeof(*op) + hs_addr->size;
> + op->offset = hs_addr->offset;
> + op->low_addr = hs_addr->hs_dma & 0xFFFFFFFFULL;
> + op->high_addr = hs_addr->hs_dma >> 32;
[Severity: Low]
Can shifting hs_addr->hs_dma by 32 bits trigger a -Wshift-count-overflow
warning on 32-bit COMPILE_TEST builds?
hs_dma has type dma_addr_t, which is 32 bits wide when
CONFIG_ARCH_DMA_ADDR_T_64BIT is disabled. Using lower_32_bits() and
upper_32_bits() as in aie_part_pm_ops_flush() avoids the shift overflow.
> + if (flush)
> + ret = aie_part_pm_ops_flush(apart);
> +
> + if (ret)
> + return ret;
> + goto again;
> + }
> +
> + if (type)
> + dev_warn(&apart->dev, "Unknown ops type: 0x%x\n", type);
> +
> + if (flush)
> + ret = aie_part_pm_ops_flush(apart);
> +
> + return ret;
> +}
[Severity: Medium]
Why do the AIE_PART_INIT_OPT_HW_ERR_STS and AIE_PART_INIT_OPT_HANDSHAKE
branches flush and jump back to again after queuing their operation?
Jumping to again after aie_part_pm_ops_flush() resets pm_ops->op_range to
NULL causes a new XILINX_AIE_OPS_START_NUM_COL range header to be written
into pm_ops->pkt_va even when no bits remain in type. When flush is
true, the function then flushes a second time at the end; when flush is
false with AIE_PART_INIT_OPT_HW_ERR_STS (which also ignores the flush
parameter), an empty range header is left in pm_ops->pkt_va and will not
be stripped by aie_part_pm_ops_flush() if the next call uses a different
column range.
> diff --git a/include/linux/amd-ai-engine.h b/include/linux/amd-ai-engine.h
> index f5750d219e211..9df3463985afd 100644
> --- a/include/linux/amd-ai-engine.h
> +++ b/include/linux/amd-ai-engine.h
[ ... ]
> +/**
> + * struct aie_op_handshake_data - AI engine uc handshake region information
> + * @addr: handshake data address from where the data needs to be copied.
> + * @size: handshake data size.
> + * @offset: offset for handshake region update.
> + */
> +struct aie_op_handshake_data {
> + void *addr;
> + size_t size;
> + size_t offset;
> + struct aie_location loc;
> +};
[Severity: Low]
The kernel-doc comment for struct aie_op_handshake_data is missing an
entry for @loc, which will trigger a kernel-doc warning under W=1.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118233211.4121361-1-gregory.williams@amd.com?part=13
next prev parent reply other threads:[~2026-11-18 23:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 23:31 [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Gregory Williams
2026-11-18 23:32 ` [PATCH 11/15] dt-bindings: soc: xilinx: Add Versal AI Engine DT binding Gregory Williams
2026-11-18 23:45 ` sashiko-bot
2026-11-19 10:59 ` Krzysztof Kozlowski
2026-11-18 23:32 ` [PATCH 12/15] accel/amd-ai-engine: Add AMD AI Engine device driver Gregory Williams
2026-11-18 23:45 ` sashiko-bot
2026-11-18 23:32 ` [PATCH 13/15] accel/amd-ai-engine: Add pm ops for firmware calls Gregory Williams
2026-11-18 23:46 ` sashiko-bot [this message]
2026-11-18 23:32 ` [PATCH 14/15] accel/amd-ai-engine: Add support to enable/disable tile clocks Gregory Williams
2026-11-18 23:45 ` sashiko-bot
2026-11-18 23:32 ` [PATCH 15/15] accel/amd-ai-engine: Add reset operations Gregory Williams
2026-11-18 23:51 ` sashiko-bot
2026-11-19 8:19 ` [PATCH 00/15] accel: Add AMD Versal AI Engine driver (with Versal Gen 2 firmware support) Jerome Brunet
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=sashiko-outbox-222211@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregory.williams@amd.com \
--cc=sashiko-reviews@lists.linux.dev \
/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