From: sashiko-bot@kernel.org
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 09/13] drm/panfrost: Add debugfs knob for manually triggering a GPU reset
Date: Fri, 24 Jul 2026 00:14:05 +0000 [thread overview]
Message-ID: <20260724001406.52A8B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724-claude-fixes-v3-9-542af61abd0f@collabora.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] The return value of `pm_runtime_get_if_in_use()` is evaluated as a boolean, which incorrectly treats negative error codes (e.g., `-EINVAL`) as success, leading to a PM usage count underflow and unsafe hardware access.
- [High] Dropping the runtime PM reference prematurely when `wait_event_interruptible_timeout()` times out or is interrupted allows the device to suspend while the asynchronous hardware reset is still executing.
- [Medium] The return value of `wait_event_interruptible_timeout()` is ignored, masking failures from userspace.
--
--- Patch [9]: [PATCH v3 09/13] drm/panfrost: Add debugfs knob for manually triggering a GPU reset ---
commit 30e9d18cee2bcd687cf4536c70ee21485ca931d0
Author: Adrián Larumbe <adrian.larumbe@collabora.com>
drm/panfrost: Add debugfs knob for manually triggering a GPU reset
This commit introduces a new debugfs file "reset" to the panfrost driver.
It allows userspace to manually trigger a GPU reset by writing to it, and
to read whether a reset is currently pending.
> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
> index cf115db9cebfd..80746e3754100 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
[ ... ]
> @@ -631,3 +632,40 @@ void panfrost_device_reset(struct panfrost_device *pfdev, bool enable_job_int)
[ ... ]
> +static int reset_set(void *data, u64 val)
> +{
> + struct panfrost_device *pfdev =
> + container_of(data, struct panfrost_device, base);
> +
> + if (pm_runtime_get_if_in_use(pfdev->base.dev)) {
[Severity: High]
Does this incorrectly treat negative error codes as success?
If runtime PM is disabled (e.g., CONFIG_PM is disabled or during unbind),
pm_runtime_get_if_in_use() returns -EINVAL. This condition will evaluate to
true, causing the code to schedule a reset and call pm_runtime_put() without
an actual reference being taken.
This can lead to a PM usage counter underflow and potential hardware access
on an unpowered device. Should this explicitly check for a return value > 0?
> + panfrost_device_schedule_reset(pfdev);
> + wait_event_interruptible_timeout(pfdev->reset.wait,
> + !atomic_read(&pfdev->reset.pending),
> + msecs_to_jiffies(60));
[Severity: Medium]
Is it intentional to ignore the return value of the wait?
If the wait is interrupted by a signal (-ERESTARTSYS) or times out (0), the
function unconditionally returns 0, falsely indicating success to userspace.
[Severity: High]
Can dropping the PM reference on timeout or signal interruption cause the
device to suspend while the reset is still executing?
If the wait is interrupted or times out, the code proceeds to pm_runtime_put()
even though the reset work might still be pending or running.
Because panfrost_reset() drops PM references for active jobs before the
hardware reset, dropping this reference can drop the usage counter to zero.
If the device suspends while the async reset work is concurrently accessing
MMIO registers, could this trigger a synchronous external abort?
> + pm_runtime_put(pfdev->base.dev);
> + }
> +
> + return 0;
> +}
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-claude-fixes-v3-0-542af61abd0f@collabora.com?part=9
next prev parent reply other threads:[~2026-07-24 0:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 23:58 [PATCH v3 00/13] RPM, perfcnt and other minor fixes for Panfrost Adrián Larumbe
2026-07-23 23:58 ` [PATCH v3 01/13] drm/panfrost: Check another bo field for cache option query Adrián Larumbe
2026-07-23 23:58 ` [PATCH v3 02/13] drm/panfrost: Prevent division by 0 Adrián Larumbe
2026-07-24 0:08 ` sashiko-bot
2026-07-23 23:58 ` [PATCH v3 03/13] drm/panfrost: Remove unnecessary header file include Adrián Larumbe
2026-07-23 23:58 ` [PATCH v3 04/13] drm/panfrost: Move shrinker initialization and unplug one level down Adrián Larumbe
2026-07-24 0:06 ` sashiko-bot
2026-07-23 23:58 ` [PATCH v3 05/13] drm/panfrost: Move all device power up and down into RPM callbacks Adrián Larumbe
2026-07-24 0:11 ` sashiko-bot
2026-07-23 23:58 ` [PATCH v3 06/13] drm/panfrost: Explicitly enable MMU interrupts at device init Adrián Larumbe
2026-07-24 0:13 ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 07/13] drm/panfrost: Sync with IRQ before MMU disable and reset Adrián Larumbe
2026-07-24 0:17 ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 08/13] drm/panfrost: Rewire reset sequence to avoid concurrent attempts Adrián Larumbe
2026-07-24 0:09 ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 09/13] drm/panfrost: Add debugfs knob for manually triggering a GPU reset Adrián Larumbe
2026-07-24 0:14 ` sashiko-bot [this message]
2026-07-23 23:59 ` [PATCH v3 10/13] drm/panfrost: Move perfcnt GPU disable sequence into a helper Adrián Larumbe
2026-07-23 23:59 ` [PATCH v3 11/13] drm/panfrost: Introduce a reset lock Adrián Larumbe
2026-07-24 0:16 ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 12/13] drm/panfrost: Fix races between perfcnt and reset sequence Adrián Larumbe
2026-07-24 0:12 ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 13/13] drm/panfrost: Bump driver minor to reflect new DUMP IOCTL req field Adrián Larumbe
2026-07-24 0:16 ` 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=20260724001406.52A8B1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=adrian.larumbe@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--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 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.