From: sashiko-bot@kernel.org
To: "Gregory Williams" <gregory.williams@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 15/15] accel/amd-ai-engine: Add reset operations
Date: Wed, 18 Nov 2026 23:51:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-222217@kernel.org> (raw)
In-Reply-To: <20261118233211.4121361-16-gregory.williams@amd.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] accel/amd-ai-engine: unflushed pm_ops on error in
aiemlv2_part_init()
- [Medium] accel/amd-ai-engine: unchecked 2-column NMU range in
aiemlv2_part_init()
- [Low] accel/amd-ai-engine: open-coded polling in
aie_part_maskpoll_register()
--
commit 7ceb805ff0b7740b5882eeff9e935665efc44bc8
Author: Gregory Williams <gregory.williams@amd.com>
accel/amd-ai-engine: Add reset operations
This commit adds partition initialization and teardown callbacks for AI
Engine partitions, configuring resets, memory zeroization, NMU routing,
ECC scrubbing, error reporting, and tile clocks.
> diff --git a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
> index 26dd1d726bfad..910a9bda23055 100644
> --- a/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
> +++ b/drivers/accel/amd-ai-engine/ai-engine-aiemlv2.c
[ ... ]
> @@ -173,10 +177,250 @@ static int aiemlv2_set_part_clocks(struct aie_partition *apart)
[ ... ]
> +static int aiemlv2_part_init(struct aie_partition *apart,
> + struct aie_partition_init_args *args)
> +{
> + u32 opts;
> + int ret;
[ ... ]
> + if (args->init_opts & AIE_PART_INIT_OPT_NMU_CONFIG) {
> + struct aie_range range = {0};
> +
> + opts |= AIE_PART_INIT_OPT_NMU_CONFIG;
> + if (apart->range.start.col == 0) {
> + range.size.col = 2;
> + ret = aie_part_pm_ops(apart, NULL, AIE_PART_INIT_OPT_NMU_CONFIG,
> + range, 0);
> + if (ret)
> + goto out;
> + }
> + }
[Severity: Medium]
Can this configure column 1 outside the partition's allocated columns?
If a 1-column partition is requested at column 0 (apart->range.start.col
== 0, apart->range.size.col == 1), setting range.size.col = 2 without
checking apart->range.size.col >= 2 programs NMU routing on column 1 as
well, which may belong to another partition.
> +
> + if (args->init_opts & AIE_PART_INIT_OPT_HW_ERR_INT) {
> + u16 data = 0;
> +
> + opts |= AIE_PART_INIT_OPT_HW_ERR_INT;
> + ret = aie_part_pm_ops(apart, &data, AIE_PART_INIT_OPT_HW_ERR_INT,
> + apart->range, 0);
> + if (ret)
> + goto out;
> + }
> +
> + if (args->init_opts & AIE_PART_INIT_OPT_HW_ERR_MASK) {
> + u16 data = 0x2;
> +
> + opts |= AIE_PART_INIT_OPT_HW_ERR_MASK;
> + ret = aie_part_pm_ops(apart, &data, AIE_PART_INIT_OPT_HW_ERR_MASK,
> + apart->range, 0);
> + if (ret)
> + goto out;
> + }
> +
> + if (args->init_opts & AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD) {
> + u16 data;
> +
> + if (args->ecc_scrub > U16_MAX) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + data = args->ecc_scrub;
> + opts |= AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD;
> + ret = aie_part_pm_ops(apart, &data,
> + AIE_PART_INIT_OPT_SET_ECC_SCRUB_PERIOD,
> + apart->range, 0);
> + if (ret)
> + goto out;
> + }
> +
> + if (args->init_opts & AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV) {
> + opts |= AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV;
> +
> + ret = aie_part_pm_ops(apart, NULL, AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV,
> + apart->range, 0);
> + if (ret)
> + goto out;
> + }
> +
> + /* Request tile locations */
> + ret = aie_part_request_tiles(apart, args->num_tiles, args->locs);
> + if (ret)
> + goto out;
> +
> + if (args->init_opts & AIE_PART_INIT_OPT_DIS_TLAST_ERROR) {
> + u16 data = 0;
> +
> + opts |= AIE_PART_INIT_OPT_DIS_TLAST_ERROR;
> + ret = aie_part_pm_ops(apart, &data,
> + AIE_PART_INIT_OPT_DIS_TLAST_ERROR,
> + apart->range, 1);
> + if (ret)
> + goto out;
> + }
> +
> + if (opts != args->init_opts)
> + dev_warn(&apart->dev, "Invalid init_opts: 0x%x\n", opts ^ args->init_opts);
> +
> +out:
> + mutex_unlock(&apart->mlock);
> + return ret;
> +}
[Severity: Medium]
Does the error path leave unflushed commands queued in apart->pm_ops?
The operations from AIE_PART_INIT_OPT_NMU_CONFIG through
AIE_PART_INIT_OPT_UC_ENB_MEM_PRIV are queued with flush = 0 and rely on
aie_part_request_tiles() -> aiemlv2_set_part_clocks() ->
aie_part_pm_ops_flush() to flush and reset the buffer. If args->ecc_scrub
> U16_MAX or aie_part_request_tiles() fails (for example, when
args->num_tiles > 0 and args->locs is NULL), jumping to out leaves those
descriptors in apart->pm_ops.pkt_va, so they will be sent to firmware
ahead of the DMA pause operations on the next initialize or teardown call.
Validating args before modifying hardware state and resetting
apart->pm_ops on failure would avoid both the stale command buffer and
leaving the partition partially reset on -EINVAL.
> diff --git a/drivers/accel/amd-ai-engine/ai-engine-part.c b/drivers/accel/amd-ai-engine/ai-engine-part.c
> index 35451d1ed88a4..2cd93c02246e5 100644
> --- a/drivers/accel/amd-ai-engine/ai-engine-part.c
> +++ b/drivers/accel/amd-ai-engine/ai-engine-part.c
[ ... ]
> @@ -106,3 +107,34 @@ struct aie_partition *aie_part_create(struct aie_device *adev,
> device_unregister(&apart->dev);
> return ERR_PTR(ret);
> }
> +
> +/**
> + * aie_part_maskpoll_register() - Mask polls an address for a data in a partition.
> + * @apart: AI engine partition.
> + * @offset: AI engine register offset.
> + * @data: data to poll.
> + * @mask: if it is non 0, it is mask read.
> + * @timeout: Timeout in microseconds.
> + *
> + * Return: zero for success, or -EBUSY for failure
> + */
> +int aie_part_maskpoll_register(struct aie_partition *apart, u32 offset, u32 data,
> + u32 mask, u32 timeout)
> +{
> + u32 usleep_time = 10;
> + u32 value;
> + u32 i;
> +
> + for (i = 0; i < timeout; i += usleep_time) {
> + value = readl(apart->adev->base + offset);
> + if ((value & mask) == data)
> + return 0;
> + usleep_range(usleep_time, usleep_time + 10);
> + }
> +
> + value = readl(apart->adev->base + offset);
> + if ((value & mask) == data)
> + return 0;
> +
> + return -EBUSY;
> +}
[Severity: Low]
Can this use readl_poll_timeout() from linux/iopoll.h instead of an
open-coded loop? Advancing i by 10 us per iteration while calling
usleep_range(10, 20) does not account for sleeps up to 20 us or scheduler
wakeup overhead, so a 2000000 us timeout can block for much longer than 2
seconds per column while holding apart->mlock.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118233211.4121361-1-gregory.williams@amd.com?part=15
next prev parent reply other threads:[~2026-11-18 23:51 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
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 [this message]
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-222217@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