[PATCH v2 24/28] drm/panthor: Quiesce scheduler tick during system suspend

From: Karunika Choo

Date: Tue Nov 10 2026 - 10:52:47 EST


A scheduler tick can run during forced system suspend and access GPU
registers after the clocks have been disabled.

Add system suspend callbacks that disable and drain tick work before
forced suspend. Re-enable and queue a fresh tick after forced resume or
when suspend fails.

Signed-off-by: Karunika Choo <karunika.choo@xxxxxxx>
---
drivers/gpu/drm/panthor/panthor_device.c | 26 ++++++++++++++++++++++++
drivers/gpu/drm/panthor/panthor_device.h | 3 +++
drivers/gpu/drm/panthor/panthor_drv.c | 8 ++++----
drivers/gpu/drm/panthor/panthor_sched.c | 15 ++++++++++++++
drivers/gpu/drm/panthor/panthor_sched.h | 2 ++
5 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
index 2ccd8ad6318d1..ba5252c27410f 100644
--- a/drivers/gpu/drm/panthor/panthor_device.c
+++ b/drivers/gpu/drm/panthor/panthor_device.c
@@ -662,3 +662,29 @@ int panthor_device_suspend(struct device *dev)
atomic_set(&ptdev->pm.state, PANTHOR_DEVICE_PM_STATE_SUSPENDED);
return 0;
}
+
+int panthor_device_system_suspend(struct device *dev)
+{
+ struct panthor_device *ptdev = dev_get_drvdata(dev);
+ int ret;
+
+ panthor_sched_pre_suspend(ptdev);
+
+ ret = pm_runtime_force_suspend(dev);
+ if (ret)
+ panthor_sched_post_resume(ptdev);
+
+ return ret;
+}
+
+int panthor_device_system_resume(struct device *dev)
+{
+ struct panthor_device *ptdev = dev_get_drvdata(dev);
+ int ret;
+
+ ret = pm_runtime_force_resume(dev);
+
+ panthor_sched_post_resume(ptdev);
+
+ return ret;
+}
diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h
index 025efb91c1a38..e002ebbc88579 100644
--- a/drivers/gpu/drm/panthor/panthor_device.h
+++ b/drivers/gpu/drm/panthor/panthor_device.h
@@ -448,6 +448,9 @@ int panthor_device_mmap_io(struct panthor_device *ptdev,
int panthor_device_resume(struct device *dev);
int panthor_device_suspend(struct device *dev);

+int panthor_device_system_resume(struct device *dev);
+int panthor_device_system_suspend(struct device *dev);
+
int panthor_device_suspend_hw_components(struct panthor_device *ptdev);
int panthor_device_resume_hw_components(struct panthor_device *ptdev);

diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index e9b71ff5ee53f..b92d600dc4764 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -1888,10 +1888,10 @@ static const struct of_device_id dt_match[] = {
};
MODULE_DEVICE_TABLE(of, dt_match);

-static DEFINE_RUNTIME_DEV_PM_OPS(panthor_pm_ops,
- panthor_device_suspend,
- panthor_device_resume,
- NULL);
+static const struct dev_pm_ops panthor_pm_ops = {
+ SYSTEM_SLEEP_PM_OPS(panthor_device_system_suspend, panthor_device_system_resume)
+ RUNTIME_PM_OPS(panthor_device_suspend, panthor_device_resume, NULL)
+};

static struct platform_driver panthor_driver = {
.probe = panthor_probe,
diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index a343c5180e01e..3b2ed4095f80e 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -4047,6 +4047,21 @@ void panthor_job_update_resvs(struct drm_exec *exec, struct drm_sched_job *sched
DMA_RESV_USAGE_BOOKKEEP, DMA_RESV_USAGE_BOOKKEEP);
}

+void panthor_sched_pre_suspend(struct panthor_device *ptdev)
+{
+ struct panthor_scheduler *sched = ptdev->scheduler;
+
+ disable_delayed_work_sync(&sched->tick_work);
+}
+
+void panthor_sched_post_resume(struct panthor_device *ptdev)
+{
+ struct panthor_scheduler *sched = ptdev->scheduler;
+
+ enable_delayed_work(&sched->tick_work);
+ panthor_sched_resume(ptdev);
+}
+
void panthor_sched_unplug(struct panthor_device *ptdev)
{
struct panthor_scheduler *sched = ptdev->scheduler;
diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h
index d87cbdba4d40b..af7ca62125ae8 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.h
+++ b/drivers/gpu/drm/panthor/panthor_sched.h
@@ -49,6 +49,8 @@ void panthor_sched_pre_reset(struct panthor_device *ptdev);
void panthor_sched_post_reset(struct panthor_device *ptdev, bool reset_failed);
void panthor_sched_suspend(struct panthor_device *ptdev);
void panthor_sched_resume(struct panthor_device *ptdev);
+void panthor_sched_pre_suspend(struct panthor_device *ptdev);
+void panthor_sched_post_resume(struct panthor_device *ptdev);

void panthor_sched_report_mmu_fault(struct panthor_device *ptdev);
void panthor_sched_prepare_for_vm_destruction(struct panthor_device *ptdev);
--
2.43.0