On Wed, 13 Nov 2024 16:42:54 +0100 Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote: > @@ -74,7 +76,8 @@ void panthor_device_unplug(struct panthor_device *ptdev) > */ > mutex_unlock(&ptdev->unplug.lock); > > - drm_WARN_ON(&ptdev->base, pm_runtime_get_sync(ptdev->base.dev) < 0); > + ret = pm_runtime_get_sync(ptdev->base.dev); > + drm_WARN_ON(&ptdev->base, ret < 0); > > /* Now, try to cleanly shutdown the GPU before the device resources > * get reclaimed. > @@ -85,7 +88,10 @@ void panthor_device_unplug(struct panthor_device *ptdev) > panthor_gpu_unplug(ptdev); > > pm_runtime_dont_use_autosuspend(ptdev->base.dev); > - pm_runtime_put_sync_suspend(ptdev->base.dev); > + > + /* If the resume failed, we don't need to suspend here. */ > + if (!ret) > + pm_runtime_put_sync_suspend(ptdev->base.dev); Okay, I always get confused by pm_runtime_get_sync(). Turns out the refcount is incremented even if pm_runtime_get_sync() fails, so we should call pm_runtime_put_sync_suspend() unconditionally here.