[PATCH v3 01/14] drm/panfrost: Power the GPU up for a reset queued from the MMU code

From: Arun Iyengar via B4 Relay

Date: Fri Nov 13 2026 - 11:11:55 EST


From: Arun Iyengar <aiyengar1990@xxxxxxxxx>

panfrost_reset_work() calls panfrost_reset() without a runtime PM
reference. wait_ready() queues it when AS_ACTIVE is stuck, from MMU
operations whose callers drop their PM reference right after, and it
shares the ordered reset workqueue with the scheduler timeout handlers,
so it can run late. If the GPU was runtime suspended in between,
panfrost_reset() writes the registers of a powered-off GPU: a
synchronous external abort on arm64.

Take a runtime PM reference in the work. pm_runtime_force_suspend()
ignores the usage count, so also disable the work across system sleep
and queue it again on resume if a reset is still pending. If the GPU
cannot be resumed, no job is running on it and
panfrost_device_runtime_resume() resets it later, so just clear the
pending flag. Skipping the reset on a suspended GPU instead would leave
jobs that a concurrent resume queued behind the pending flag waiting.

Found by code review (Sashiko). Not reproduced.

Fixes: f9ab9c66f080 ("drm/panfrost: Reset the GPU when the AS_ACTIVE bit is stuck")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/sashiko-outbox-206548@xxxxxxxxxx/
Closes: https://lore.kernel.org/all/sashiko-outbox-210830@xxxxxxxxxx/
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
drivers/gpu/drm/panfrost/panfrost_device.c | 26 ++++++++++++++++++++++++--
drivers/gpu/drm/panfrost/panfrost_job.c | 11 +++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
index 40eda3612..2c11a6721 100644
--- a/drivers/gpu/drm/panfrost/panfrost_device.c
+++ b/drivers/gpu/drm/panfrost/panfrost_device.c
@@ -567,7 +567,7 @@ static int panfrost_device_runtime_suspend(struct device *dev)
return 0;
}

-static int panfrost_device_resume(struct device *dev)
+static int panfrost_device_power_up(struct device *dev)
{
struct panfrost_device *pfdev = dev_get_drvdata(dev);
int ret;
@@ -604,14 +604,36 @@ static int panfrost_device_resume(struct device *dev)
return ret;
}

+static void panfrost_device_enable_reset(struct panfrost_device *pfdev)
+{
+ enable_work(&pfdev->reset.work);
+ if (atomic_read(&pfdev->reset.pending))
+ queue_work(pfdev->reset.wq, &pfdev->reset.work);
+}
+
+static int panfrost_device_resume(struct device *dev)
+{
+ int ret = panfrost_device_power_up(dev);
+
+ panfrost_device_enable_reset(dev_get_drvdata(dev));
+ return ret;
+}
+
static int panfrost_device_suspend(struct device *dev)
{
struct panfrost_device *pfdev = dev_get_drvdata(dev);
int ret;

+ /* pm_runtime_force_suspend() ignores the reset work's runtime PM
+ * reference: keep the work off the GPU until resume.
+ */
+ disable_work_sync(&pfdev->reset.work);
+
ret = pm_runtime_force_suspend(dev);
- if (ret)
+ if (ret) {
+ panfrost_device_enable_reset(pfdev);
return ret;
+ }

if (pfdev->comp->pm_features & BIT(GPU_PM_CLK_DIS))
panfrost_clks_disable(pfdev, false);
diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
index 3a46dd61c..7319511db 100644
--- a/drivers/gpu/drm/panfrost/panfrost_job.c
+++ b/drivers/gpu/drm/panfrost/panfrost_job.c
@@ -810,7 +810,18 @@ static void panfrost_reset_work(struct work_struct *work)
struct panfrost_device *pfdev;

pfdev = container_of(work, struct panfrost_device, reset.work);
+
+ /* The GPU may have been runtime suspended since the work was queued.
+ * If it cannot be resumed, no job is on it, and
+ * panfrost_device_runtime_resume() resets it later.
+ */
+ if (pm_runtime_resume_and_get(pfdev->base.dev)) {
+ atomic_set(&pfdev->reset.pending, 0);
+ return;
+ }
+
panfrost_reset(pfdev, NULL);
+ pm_runtime_put_autosuspend(pfdev->base.dev);
}

static const struct drm_sched_backend_ops panfrost_sched_ops = {

--
2.55.0