drm/v3d/v3d_drv: Fix PM disable depth imbalance
Subsystems (3)
PATCH v3 1/1 drm/v3d/v3d_drv: Fix PM disable depth imbalance
The pm_runtime_enable will increase power disable depth. If the probe fails, we should use pm_runtime_disable() to balance pm_runtime_enable().
Also call disable function in remove function.
---
Changes in v3:
- call pm_runtime_disable() in v3d_platform_drm_remove
- update commit message
Changes in v2
- put pm_runtime_disable before dma_free_wc
- rename dma_free to pm_disable
v1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
--- drivers/gpu/drm/v3d/v3d_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/v3d/v3d_drv.c +4 -2
@@ -286,7 +286,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ret =v3d_gem_init (drm);if (ret) - goto dma_free; + goto pm_disable; ret =v3d_irq_init (v3d);if (ret)
@@ -302,7 +302,8 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)v3d_irq_disable (v3d); gem_destroy:v3d_gem_destroy (drm); -dma_free: +pm_disable: +pm_runtime_disable (dev);dma_free_wc (dev,4096 , v3d->mmu_scratch, v3d->mmu_scratch_paddr);return ret; }
@@ -316,6 +317,7 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)v3d_gem_destroy (drm); +pm_runtime_disable (&pdev->dev);dma_free_wc (v3d->drm.dev,4096 , v3d->mmu_scratch, v3d->mmu_scratch_paddr);
Signature · 1 line
2.25.1
Quoted 12 lines · Miaoqian Lin
The
pm_runtime_enablewill increase power disable depth. If the probe fails, we should usepm_runtime_disable()to balancepm_runtime_enable().
Also call disable function in remove function.Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")Signed-off-by Miaoqian Lin <[email protected]>---
Changes in v3:
- callpm_runtime_disable()inv3d_platform_drm_remove
- update commit message
Quoted 6 lines
Changes in v2
- putpm_runtime_disablebeforedma_free_wc
- renamedma_freetopm_disablev1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
Maybe a bit late since we're at v3 already, but are there no devm_ functions here that would dtrt automatically? Or is there another reason we can't use them?
-Daniel
Quoted 38 lines
--- drivers/gpu/drm/v3d/v3d_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/v3d/v3d_drv.c +4
-2@@ -286,7 +286,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ret =v3d_gem_init (drm);if (ret) - goto dma_free; + goto pm_disable; ret =v3d_irq_init (v3d);if (ret)@@ -302,7 +302,8 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)v3d_irq_disable (v3d); gem_destroy:v3d_gem_destroy (drm); -dma_free: +pm_disable: +pm_runtime_disable (dev);dma_free_wc (dev,4096 , v3d->mmu_scratch, v3d->mmu_scratch_paddr);return ret; }@@ -316,6 +317,7 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)v3d_gem_destroy (drm); +pm_runtime_disable (&pdev->dev);dma_free_wc (v3d->drm.dev,4096 , v3d->mmu_scratch, v3d->mmu_scratch_paddr);Signature · 1 line
2.25.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Hi, Daniel
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Miaoqian Lin
The
pm_runtime_enablewill increase power disable depth. If the probe fails, we should usepm_runtime_disable()to balancepm_runtime_enable().
Also call disable function in remove function.Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")Signed-off-by Miaoqian Lin <[email protected]>---
Changes in v3:
- callpm_runtime_disable()inv3d_platform_drm_remove
- update commit message
Quoted 8 lines
Quoted 6 lines
Changes in v2
- putpm_runtime_disablebeforedma_free_wc
- renamedma_freetopm_disablev1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]Maybe a bit late since we're at v3 already, but are there no
devm_functions here that would dtrt automatically?
Sorry I don't see one, or we can use devm_add_action_or_reset() to add handling
action. something like disp_cc_sm8250_probe() in drivers/clk/qcom/dispcc-sm8250.c
How do you think?
Quoted 41 lines
Or is there another reason
we can't use them?
-DanielQuoted 38 lines
--- drivers/gpu/drm/v3d/v3d_drv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/v3d/v3d_drv.c +4
-2@@ -286,7 +286,7 @@ static int v3d_platform_drm_probe(struct platform_device *pdev) ret =v3d_gem_init (drm);if (ret) - goto dma_free; + goto pm_disable; ret =v3d_irq_init (v3d);if (ret)@@ -302,7 +302,8 @@ static int v3d_platform_drm_probe(struct platform_device *pdev)v3d_irq_disable (v3d); gem_destroy:v3d_gem_destroy (drm); -dma_free: +pm_disable: +pm_runtime_disable (dev);dma_free_wc (dev,4096 , v3d->mmu_scratch, v3d->mmu_scratch_paddr);return ret; }@@ -316,6 +317,7 @@ static int v3d_platform_drm_remove(struct platform_device *pdev)v3d_gem_destroy (drm); +pm_runtime_disable (&pdev->dev);dma_free_wc (v3d->drm.dev,4096 , v3d->mmu_scratch, v3d->mmu_scratch_paddr);Signature · 1 line
2.25.1
Quoted 22 lines · Miaoqian Lin
Hi, Daniel
Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Miaoqian Lin
The
pm_runtime_enablewill increase power disable depth. If the probe fails, we should usepm_runtime_disable()to balancepm_runtime_enable().
Also call disable function in remove function.Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")Signed-off-by Miaoqian Lin <[email protected]>---
Changes in v3:
- callpm_runtime_disable()inv3d_platform_drm_remove
- update commit messageChanges in v2
- putpm_runtime_disablebeforedma_free_wc
- renamedma_freetopm_disablev1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]
Quoted 8 lines
Quoted 2 lines
Maybe a bit late since we're at v3 already, but are there no
devm_functions here that would dtrt automatically?Sorry I don't see one, or we can use
devm_add_action_or_reset()to add handlingaction. something like
disp_cc_sm8250_probe()indrivers/clk/qcom/dispcc-sm8250.cHow do you think?
Looks like there's a devm_pm_runtime_enable() helper that does exactly that. See commit b3636a3a2c51 ("PM: runtime: add devm_pm_runtime_enable helper"). I haven't seen any large janitorial series yet for that, so perhaps it's just not widely known yet.
Thierry
Hi, Thierry
Quoted 27 lines · Thierry Reding
Quoted 26 lines · Miaoqian Lin
Hi, Daniel
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Miaoqian Lin
The
pm_runtime_enablewill increase power disable depth. If the probe fails, we should usepm_runtime_disable()to balancepm_runtime_enable().
Also call disable function in remove function.Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")Signed-off-by Miaoqian Lin <[email protected]>---
Changes in v3:
- callpm_runtime_disable()inv3d_platform_drm_remove
- update commit messageQuoted 8 lines
Quoted 6 lines
Changes in v2
- putpm_runtime_disablebeforedma_free_wc
- renamedma_freetopm_disablev1: https://lore.kernel.org/r/[email protected]
v2: https://lore.kernel.org/r/[email protected]Maybe a bit late since we're at v3 already, but are there no
devm_functions here that would dtrt automatically?Sorry I don't see one, or we can use
devm_add_action_or_reset()to add handling
Quoted 7 lines
Quoted 3 lines
action. something like
disp_cc_sm8250_probe()indrivers/clk/qcom/dispcc-sm8250.cHow do you think?
Looks like there's a
devm_pm_runtime_enable()helper that does exactly that. See commitb3636a3a2c51("PM: runtime: adddevm_pm_runtime_enablehelper"). I haven't seen any large janitorial series yet for that, so perhaps it's just not widely known yet.
Great, very helpful. Thanks for your kind reminder.
Quoted 1 line
Thierry