Skip to contentSkip to conversation

drm/v3d/v3d_drv: Fix PM disable depth imbalance

PATCH Superseded Miaoqian Lin 3 participants 5 messages Jun 1, 2022 – Jun 2, 2022

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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.

Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

---
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
index 1afcd54fbbd5..f3380399fe17 100644
@@ -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
#1 lore raw
Quoted 12 lines · Miaoqian Lin

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.

Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

---
Changes in v3:
- call pm_runtime_disable() in v3d_platform_drm_remove
- update commit message

Quoted 6 lines

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]

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
index 1afcd54fbbd5..f3380399fe17 100644
@@ -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
#2 lore raw

Hi, Daniel

Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Miaoqian Lin

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.

Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

---
Changes in v3:
- call pm_runtime_disable() in v3d_platform_drm_remove
- update commit message

Quoted 8 lines
Quoted 6 lines

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]

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?
-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
index 1afcd54fbbd5..f3380399fe17 100644
@@ -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
#3 lore raw
Quoted 22 lines · Miaoqian Lin

Hi, Daniel

Quoted 19 lines · Daniel Vetter
Quoted 18 lines · Miaoqian Lin

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.

Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

---
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]

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 handling

action. something like disp_cc_sm8250_probe() in drivers/clk/qcom/dispcc-sm8250.c

How 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

#4 lore raw

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_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.

Fixes 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+")

---
Changes in v3:
- call pm_runtime_disable() in v3d_platform_drm_remove
- update commit message

Quoted 8 lines
Quoted 6 lines

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]

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() in drivers/clk/qcom/dispcc-sm8250.c

How 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.

Great, very helpful. Thanks for your kind reminder.

Quoted 1 line

Thierry