summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_pm.c
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2023-02-22 12:18:45 +0000
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-19 18:29:08 -0500
commit5b7e50e2ea1745bd09c3d99a4f7c49d630124825 (patch)
treee23cb8bb9ad6ddb3088a0171fb26891e4c465aad /drivers/gpu/drm/xe/xe_pm.c
parent84ff55006578d169b9331014bd34f0da2ca0616b (diff)
downloadlwn-5b7e50e2ea1745bd09c3d99a4f7c49d630124825.tar.gz
lwn-5b7e50e2ea1745bd09c3d99a4f7c49d630124825.zip
drm/xe/pm: fix unbalanced ref handling
In local_pci_probe() the core kernel increments the rpm for the device, just before calling into the probe hook. If the driver/device supports runtime pm it is then meant to put this ref during probe (like we do in xe_pm_runtime_init()). However when removing the device we then also need to take the reference back, otherwise the ref that is put in pci_device_remove() will be unbalanced when for example unloading the driver, leading to warnings like: [ 3808.596345] xe 0000:03:00.0: Runtime PM usage count underflow! Fix this by incrementing the rpm ref when removing the device. v2: - Improve the terminology in the commit message; s/drop/put/ etc (Lucas & Rodrigo) - Also call pm_runtime_forbid(dev) (Rodrigo) Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/193 Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_pm.c')
-rw-r--r--drivers/gpu/drm/xe/xe_pm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c
index fb0355530e7b..0ef92b746595 100644
--- a/drivers/gpu/drm/xe/xe_pm.c
+++ b/drivers/gpu/drm/xe/xe_pm.c
@@ -117,6 +117,14 @@ void xe_pm_runtime_init(struct xe_device *xe)
pm_runtime_put_autosuspend(dev);
}
+void xe_pm_runtime_fini(struct xe_device *xe)
+{
+ struct device *dev = xe->drm.dev;
+
+ pm_runtime_get_sync(dev);
+ pm_runtime_forbid(dev);
+}
+
int xe_pm_runtime_suspend(struct xe_device *xe)
{
struct xe_gt *gt;