drm/xe/pm: give the core kernel its rpm ref back
Subsystems (2)
PATCH 1/1 drm/xe/pm: give the core kernel its rpm ref back
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 drop this ref during probe (like we do in xe_pm_runtime_init()). However when removing the device we then also need to give the reference back, otherwise the ref that is dropped 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.
--- drivers/gpu/drm/xe/xe_pci.c | 1 + drivers/gpu/drm/xe/xe_pm.c | 7 +++++++ drivers/gpu/drm/xe/xe_pm.h | 1 + 3 files changed, 9 insertions(+)
drivers/gpu/drm/xe/xe_pci.c +1 -0
@@ -441,6 +441,7 @@ static void xe_pci_remove(struct pci_dev *pdev)return ;xe_device_remove (xe); +xe_pm_runtime_fini (xe);pci_set_drvdata (pdev,NULL ); }
drivers/gpu/drm/xe/xe_pm.c +7 -0
@@ -128,6 +128,13 @@ 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); +} +int xe_pm_runtime_suspend (struct xe_device *xe) {struct xe_gt *gt;
drivers/gpu/drm/xe/xe_pm.h +1 -0
@@ -14,6 +14,7 @@ int xe_pm_suspend(struct xe_device *xe);int xe_pm_resume (struct xe_device *xe);void xe_pm_runtime_init (struct xe_device *xe); +void xe_pm_runtime_fini (struct xe_device *xe);int xe_pm_runtime_suspend (struct xe_device *xe);int xe_pm_runtime_resume (struct xe_device *xe);int xe_pm_runtime_get (struct xe_device *xe);
Signature · 1 line
2.39.1
Quoted 3 lines · Matthew Auld
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 drop this ref during probe (like we do in
s/drop/put/ to be consistent with the terminology?
Quoted 2 lines
xe_pm_runtime_init()). However when removing the device we then also need to give the reference back, otherwise the ref that is dropped in
give? we are calling pm_runtime_get_sync(), which would be "take".
Quoted 23 lines
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.
Signed-off-by Matthew Auld <[email protected]>Cc Lucas De Marchi <[email protected]>Cc Matthew Brost <[email protected]>Cc Rodrigo Vivi <[email protected]>---
drivers/gpu/drm/xe/xe_pci.c | 1 + drivers/gpu/drm/xe/xe_pm.c | 7 +++++++ drivers/gpu/drm/xe/xe_pm.h | 1 + 3 files changed, 9 insertions(+)drivers/gpu/drm/xe/xe_pci.c +0
-0
drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 444
Quoted 4 lines
drivers/gpu/drm/xe/xe_pci.c +1
-0@@ -441,6 +441,7 @@ static void xe_pci_remove(struct pci_dev *pdev)return ;xe_device_remove (xe); +xe_pm_runtime_fini (xe);
after xe_device_remove()? Wouldn't that end up calling the last drm_dev_put() and thus triggering all the drmm_* releases?
Lucas De Marchi
Quoted 36 lines
drivers/gpu/drm/xe/xe_pci.c +0
-0pci_set_drvdata (pdev,NULL ); }drivers/gpu/drm/xe/xe_pm.c +7
-0@@ -128,6 +128,13 @@ 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); +} +int xe_pm_runtime_suspend (struct xe_device *xe) {struct xe_gt *gt;drivers/gpu/drm/xe/xe_pm.h +1
-0@@ -14,6 +14,7 @@ int xe_pm_suspend(struct xe_device *xe);int xe_pm_resume (struct xe_device *xe);void xe_pm_runtime_init (struct xe_device *xe); +void xe_pm_runtime_fini (struct xe_device *xe);int xe_pm_runtime_suspend (struct xe_device *xe);int xe_pm_runtime_resume (struct xe_device *xe);int xe_pm_runtime_get (struct xe_device *xe);Signature · 1 line
2.39.1
Quoted 6 lines · Lucas De Marchi
Quoted 3 lines · Matthew Auld
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 drop this ref during probe (like we do ins/drop/put/ to be consistent with the terminology?
yeap, put is better...
Quoted 5 lines
Quoted 3 lines
xe_pm_runtime_init()). However when removing the device we then also need to give the reference back, otherwise the ref that is dropped ingive? we are calling
pm_runtime_get_sync(), which would be "take".
and get here...
Quoted 9 lines
Quoted 9 lines
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.
Thank you!
Quoted 36 lines
Quoted 15 lines
Signed-off-by Matthew Auld <[email protected]>Cc Lucas De Marchi <[email protected]>Cc Matthew Brost <[email protected]>Cc Rodrigo Vivi <[email protected]>---
drivers/gpu/drm/xe/xe_pci.c | 1 + drivers/gpu/drm/xe/xe_pm.c | 7 +++++++ drivers/gpu/drm/xe/xe_pm.h | 1 + 3 files changed, 9 insertions(+)drivers/gpu/drm/xe/xe_pci.c +0
-0drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 444
Quoted 4 lines
drivers/gpu/drm/xe/xe_pci.c +1
-0@@ -441,6 +441,7 @@ static void xe_pci_remove(struct pci_dev *pdev)return ;xe_device_remove (xe); +xe_pm_runtime_fini (xe);after
xe_device_remove()? Wouldn't that end up calling the lastdrm_dev_put()and thus triggering all the drmm_* releases?Lucas De Marchi
Quoted 11 lines
drivers/gpu/drm/xe/xe_pci.c +0
-0pci_set_drvdata (pdev,NULL ); }drivers/gpu/drm/xe/xe_pm.c +0
-0@@ -128,6 +128,13 @@ void xe_pm_runtime_init(struct xe_device *xe)pm_runtime_put_autosuspend (dev); }
Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c void xe_pm_runtime_init(struct xe_device *xe) · line 135
Quoted 5 lines
drivers/gpu/drm/xe/xe_pm.c +5
-0+void xe_pm_runtime_fini (struct xe_device *xe) +{ +struct device *dev = xe->drm.dev; + +pm_runtime_get_sync (dev);
please also add:pm_runtime_forbid(dev);
then
Quoted 20 lines
Quoted 20 lines
drivers/gpu/drm/xe/xe_pm.c +2
-0+} +int xe_pm_runtime_suspend (struct xe_device *xe) {struct xe_gt *gt;drivers/gpu/drm/xe/xe_pm.h +1
-0@@ -14,6 +14,7 @@ int xe_pm_suspend(struct xe_device *xe);int xe_pm_resume (struct xe_device *xe);void xe_pm_runtime_init (struct xe_device *xe); +void xe_pm_runtime_fini (struct xe_device *xe);int xe_pm_runtime_suspend (struct xe_device *xe);int xe_pm_runtime_resume (struct xe_device *xe);int xe_pm_runtime_get (struct xe_device *xe);Signature · 1 line
2.39.1
Quoted 37 lines · Lucas De Marchi
Quoted 3 lines · Matthew Auld
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 drop this ref during probe (like we do ins/drop/put/ to be consistent with the terminology?
Quoted 2 lines
xe_pm_runtime_init()). However when removing the device we then also need to give the reference back, otherwise the ref that is dropped ingive? we are calling
pm_runtime_get_sync(), which would be "take".Quoted 25 lines
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.
Signed-off-by Matthew Auld <[email protected]>Cc Lucas De Marchi <[email protected]>Cc Matthew Brost <[email protected]>Cc Rodrigo Vivi <[email protected]>---
drivers/gpu/drm/xe/xe_pci.c| 1 +
drivers/gpu/drm/xe/xe_pm.c | 7 +++++++
drivers/gpu/drm/xe/xe_pm.h | 1 +3 files changed, 9 insertions(+)drivers/gpu/drm/xe/xe_pci.c +0
-0@@ -441,6 +441,7 @@ static void xe_pci_remove(struct pci_dev *pdev) return;
Quoted 5 lines
drivers/gpu/drm/xe/xe_pci.c static void xe_pci_remove(struct pci_dev *pdev) · line 444
Quoted 2 lines
drivers/gpu/drm/xe/xe_pci.c +1
-0xe_device_remove(xe); + xe_pm_runtime_fini(xe);after
xe_device_remove()? Wouldn't that end up calling the lastdrm_dev_put()and thus triggering all the drmm_* releases?
In __device_release_driver() it will call device_remove() first, which eventually calls our xe_pci_remove() hook. A little further down it then calls device_unbind_cleanup(), which in turn calls devres_release_all(), which eventually calls into drm_managed_release() and handles all the drmm_* stuff, AFAICT.
Quoted 39 lines
Lucas De Marchi
Quoted 36 lines
drivers/gpu/drm/xe/xe_pci.c +0
-0pci_set_drvdata(pdev, NULL); }drivers/gpu/drm/xe/xe_pm.c +7
-0@@ -128,6 +128,13 @@ 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); +} +int xe_pm_runtime_suspend (struct xe_device *xe) { struct xe_gt *gt;drivers/gpu/drm/xe/xe_pm.h +1
-0@@ -14,6 +14,7 @@ int xe_pm_suspend(struct xe_device *xe);int xe_pm_resume (struct xe_device *xe);void xe_pm_runtime_init (struct xe_device *xe); +void xe_pm_runtime_fini (struct xe_device *xe);int xe_pm_runtime_suspend (struct xe_device *xe);int xe_pm_runtime_resume (struct xe_device *xe);int xe_pm_runtime_get (struct xe_device *xe);Signature · 1 line
2.39.1