[PATCH] accel/ivpu: fix usage_count leak when autosuspend_delay is negative

From: Guangshuo Li

Date: Fri Aug 07 2026 - 11:33:31 EST


ivpu_pm_init() calls pm_runtime_use_autosuspend(), but the autosuspend
setting is not disabled when the device is removed or when
initialization fails after runtime PM setup.

When the autosuspend delay is negative, the runtime PM core increments
usage_count to prevent runtime suspend. Without a matching
pm_runtime_dont_use_autosuspend(), this reference is not dropped and
usage_count remains unbalanced.

Call pm_runtime_dont_use_autosuspend() from ivpu_pm_disable() to clean
up the autosuspend state during normal device teardown. Also undo the
autosuspend setting when ivpu_boot() fails after ivpu_pm_init().

This issue was found by manual code inspection.

Fixes: 852be13f3bd3 ("accel/ivpu: Add PM support")
Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
---
drivers/accel/ivpu/ivpu_drv.c | 4 +++-
drivers/accel/ivpu/ivpu_pm.c | 1 +
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
index 35e506074d5f..633c90e73f2c 100644
--- a/drivers/accel/ivpu/ivpu_drv.c
+++ b/drivers/accel/ivpu/ivpu_drv.c
@@ -756,13 +756,15 @@ static int ivpu_dev_init(struct ivpu_device *vdev)

ret = ivpu_boot(vdev);
if (ret)
- goto err_ipc_fini;
+ goto err_pm_fini;

ivpu_job_done_consumer_init(vdev);
ivpu_pm_enable(vdev);

return 0;

+err_pm_fini:
+ pm_runtime_dont_use_autosuspend(vdev->drm.dev);
err_ipc_fini:
ivpu_ipc_fini(vdev);
err_fw_fini:
diff --git a/drivers/accel/ivpu/ivpu_pm.c b/drivers/accel/ivpu/ivpu_pm.c
index c1ce8329790e..20dc8ec7d70a 100644
--- a/drivers/accel/ivpu/ivpu_pm.c
+++ b/drivers/accel/ivpu/ivpu_pm.c
@@ -445,6 +445,7 @@ void ivpu_pm_enable(struct ivpu_device *vdev)

void ivpu_pm_disable(struct ivpu_device *vdev)
{
+ pm_runtime_dont_use_autosuspend(vdev->drm.dev);
pm_runtime_get_noresume(vdev->drm.dev);
pm_runtime_forbid(vdev->drm.dev);
}
--
2.43.0