From: sashiko-bot@kernel.org
To: "Karunika Choo" <karunika.choo@arm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v1 20/27] drm/panthor: Handle partition control INVALID_COMMAND interrupt
Date: Tue, 22 Sep 2026 21:04:45 +0000 [thread overview]
Message-ID: <20260922210445.E61DD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922204535.2850094-21-karunika.choo@arm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] drm/panthor: stale pc->last_cmd state from untracked yield_idle() causes spurious command handling
- [High] drm/panthor: synchronous state evaluation in INVALID_COMMAND handler races with hardware transitions
- [High] drm/panthor: lockless state check in window_close() causes permanently leaked windows
- [High] drm/panthor: overwriting pc->current_aw before CLOSE_WINDOW completes breaks state machine
--
commit 137cc070e4a25e7d342b37a597b27e601b15068c
Author: Karunika Choo <karunika.choo@arm.com>
drm/panthor: Handle partition control INVALID_COMMAND interrupt
This commit introduces handling for INVALID_COMMAND interrupts when partition
state requirements are not met. It retries commands when the partition state
permits, or requests scheduler recovery for open-window commands with
inconsistent assignments.
> diff --git a/drivers/gpu/drm/panthor/arbitration/panthor_partition_control.c b/drivers/gpu/drm/panthor/arbitration/panthor_partition_control.c
> index 95c26015cb637..446f77fc67891 100644
> --- a/drivers/gpu/drm/panthor/arbitration/panthor_partition_control.c
> +++ b/drivers/gpu/drm/panthor/arbitration/panthor_partition_control.c
[ ... ]
> @@ -101,18 +114,45 @@ static int partition_state_wait(struct panthor_partition_control *pc, u32 state)
[ ... ]
> static int yield_idle(struct panthor_partition_control *pc)
> {
> - gpu_write(pc->iomem, AM_PART_COMMAND,
> - AM_PART_SET_COMMAND(PART_CMD_YIELD_IDLE));
> + guard(spinlock_irqsave)(&pc->lock);
> +
> + /*
> + * This is a notification to yield the GPU once FW is idle. It is not
> + * a command that must succeed. Nothing of note is lost if the command
> + * fails apart from some minor scheduling optimisation losses. We can
> + * skip tracking this command.
> + */
> + partition_command_write_untracked(
> + pc, AM_PART_SET_COMMAND(PART_CMD_YIELD_IDLE));
[Severity: High]
Does sending PART_CMD_YIELD_IDLE untracked leave stale state in pc->last_cmd?
If the scheduler calls yield_idle() and the hardware rejects the command,
raising PART_INVALID_COMMAND, the interrupt handler will read the stale
pc->last_cmd (for instance, from a previous OPEN_WINDOW) and act upon it.
Can this lead to spurious command retries or fatal scheduler resets?
>
> return 0;
> }
> @@ -127,8 +167,8 @@ static int window_close(struct panthor_partition_control *pc)
>
[Severity: High]
Does the lockless hardware state check at the beginning of window_close()
race with pending commands?
If called immediately after window_open(), the hardware state may still be
PART_STATE_RESET because the OPEN_WINDOW command is still in flight.
window_close() assumes the window is already closed and returns early
without sending CLOSE_WINDOW, leaving the window permanently open and
leaking hardware resources.
> pc->closing = true;
>
> - gpu_write(pc->iomem, AM_PART_COMMAND,
> - AM_PART_SET_COMMAND(PART_CMD_CLOSE_WINDOW));
> + partition_command_write(pc, AM_PART_SET_COMMAND(PART_CMD_CLOSE_WINDOW),
> + pc->current_aw);
>
> return 0;
> }
> @@ -153,8 +193,8 @@ static int window_open(struct panthor_partition_control *pc, u8 aw_id)
>
> guard(spinlock_irqsave)(&pc->lock);
>
> - gpu_write(pc->iomem, AM_PART_COMMAND,
> - AM_PART_SET_COMMAND(PART_CMD_OPEN_WINDOW) | AM_PART_SET_WINDOW(aw_id));
> + partition_command_write(pc, (AM_PART_SET_COMMAND(PART_CMD_OPEN_WINDOW) |
> + AM_PART_SET_WINDOW(aw_id)), aw_id);
>
> pc->current_aw = aw_id;
[Severity: High]
Does overwriting pc->current_aw before CLOSE_WINDOW completes break the
state machine?
In window_open(), if the window is already open, it calls window_close()
and then immediately overwrites pc->current_aw with the new aw_id. When
the hardware finishes closing and raises PART_RESET_DONE, the handler
consumes the new current_aw, clears it to -1, and sends a spurious stop
notification for the new window. Subsequent INVALID_COMMAND interrupts
for the new window will be ignored.
>
> @@ -166,6 +206,8 @@ static void partition_handle_reset_done(struct panthor_partition_control *pc)
[ ... ]
> +static void partition_handle_invalid_cmd(struct panthor_partition_control *pc)
> +{
[ ... ]
> + switch (AM_PART_GET_COMMAND(pc->last_cmd.cmd)) {
> + case PART_CMD_YIELD_NOW:
> + case PART_CMD_CLOSE_WINDOW:
> + if (partition_state_get(pc) == PART_STATE_WINDOW_OPEN) {
> + partition_command_write_untracked(pc, pc->last_cmd.cmd);
> + return;
> + }
> + break;
> + case PART_CMD_OPEN_WINDOW:
> + if (partition_state_get(pc) == PART_STATE_RESET) {
> + partition_command_write_untracked(pc, pc->last_cmd.cmd);
> + return;
> + } else if (partition_aw_get(pc) == pc->last_cmd.aw_id) {
> + return;
> + }
> +
> + on_err = true;
[Severity: High]
Does this synchronous state evaluation race with hardware transitions?
When OPEN_WINDOW is sent back-to-back after CLOSE_WINDOW, the hardware
rejects it because it hasn't reached PART_STATE_RESET yet. The IRQ fires,
and the handler synchronously reads the hardware state. If the hardware is
still transitioning and hasn't reached RESET, the handler falls through to
setting on_err = true, causing a fatal scheduler reset instead of retrying.
> + aw_id = pc->last_cmd.aw_id;
> +
> + break;
> + default:
> + return;
> + }
> + }
> +
> + if (on_err)
> + panthor_arbitration_notify_err(dev_get_drvdata(pc->dev), aw_id);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260922204535.2850094-1-karunika.choo@arm.com?part=20
next prev parent reply other threads:[~2026-09-22 21:04 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 20:44 [PATCH v1 00/27] drm/panthor: Add Mali v15 virtualization support Karunika Choo
2026-09-22 20:44 ` [PATCH v1 01/27] drm/panthor: Ignore -EOPNOTSUPP for shader-present nvmem lookup Karunika Choo
2026-09-22 20:44 ` [PATCH v1 02/27] drm/panthor: Move register access helpers out of panthor_device.h Karunika Choo
2026-09-22 20:54 ` sashiko-bot
2026-09-22 20:44 ` [PATCH v1 03/27] drm/panthor: Parse and store GPU_ID fields Karunika Choo
2026-09-22 20:56 ` sashiko-bot
2026-09-22 20:44 ` [PATCH v1 04/27] drm/panthor: Add 64-bit GPU_ID decoding for v15 GPUs Karunika Choo
2026-09-22 21:01 ` sashiko-bot
2026-09-22 23:23 ` Deborah Brouwer
2026-09-22 20:44 ` [PATCH v1 05/27] drm/panthor: Move register base offsets to the HW description Karunika Choo
2026-09-22 20:45 ` [PATCH v1 06/27] drm/panthor: Derive MMU AS register addresses from base and stride Karunika Choo
2026-09-22 21:00 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 07/27] dt-bindings: gpu: mali-valhall-csf: Add Mali Gen5 AM compatible Karunika Choo
2026-09-28 10:02 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 08/27] drm/panthor: Add Mali v15 hardware support Karunika Choo
2026-09-22 20:58 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 09/27] drm/panthor: Skip devfreq when no OPP table is present Karunika Choo
2026-09-22 20:45 ` [PATCH v1 10/27] dt-bindings: gpu: panthor: Document panthor-system bindings Karunika Choo
2026-09-22 20:56 ` sashiko-bot
2026-09-28 10:05 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 11/27] drm/panthor: Add AM_SYSTEM platform driver Karunika Choo
2026-09-22 20:59 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 12/27] dt-bindings: gpu: panthor: Document panthor-arbitration bindings Karunika Choo
2026-09-22 20:59 ` sashiko-bot
2026-09-28 10:06 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 13/27] drm/panthor: Add AM_PARTITION_CONTROL support Karunika Choo
2026-09-22 20:57 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 14/27] drm/panthor: Add AM message helpers Karunika Choo
2026-09-22 20:58 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 15/27] drm/panthor: Add AM_RESOURCE_GROUP support Karunika Choo
2026-09-22 20:56 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 16/27] drm/panthor: Add arbitration scheduler Karunika Choo
2026-09-22 21:00 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 17/27] drm/panthor: Route arbitration events Karunika Choo
2026-09-22 21:04 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 18/27] dt-bindings: gpu: panthor: Document AW assignment DT property Karunika Choo
2026-09-22 20:57 ` sashiko-bot
2026-09-28 10:06 ` Krzysztof Kozlowski
2026-09-22 20:45 ` [PATCH v1 19/27] drm/panthor: Add AW assignment tracking Karunika Choo
2026-09-22 20:45 ` [PATCH v1 20/27] drm/panthor: Handle partition control INVALID_COMMAND interrupt Karunika Choo
2026-09-22 21:04 ` sashiko-bot [this message]
2026-09-22 20:45 ` [PATCH v1 21/27] drm/panthor: Request AW to yield GPU access on idle Karunika Choo
2026-09-22 21:07 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 22/27] drm/panthor: Add access-window support Karunika Choo
2026-09-22 21:05 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 23/27] drm/panthor: Synchronize HW component PM transitions Karunika Choo
2026-09-22 20:45 ` [PATCH v1 24/27] drm/panthor: Route HW component PM through access windows Karunika Choo
2026-09-22 21:06 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 25/27] drm/panthor: Tolerate access-window loss during HW waits Karunika Choo
2026-09-22 21:14 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 26/27] drm/panthor: Prevent missed post-yield cleanup due to reset Karunika Choo
2026-09-22 21:12 ` sashiko-bot
2026-09-22 20:45 ` [PATCH v1 27/27] drm/panthor: Release GPU access immediately for out-of-band grants Karunika Choo
2026-09-22 21:06 ` sashiko-bot
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=20260922210445.E61DD1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=karunika.choo@arm.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