Skip to contentSkip to conversation

drm/vc4: crtc: Fix runtime_pm reference counting

PATCH Applied Maxime Ripard 2 participants 3 messages Feb 3, 2022 – Feb 17, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vc4: crtc: Fix runtime_pm reference counting

At boot on the BCM2711, if the HDMI controllers are running, the CRTC driver will disable itself and its associated HDMI controller to work around a hardware bug that would leave some pixels stuck in a FIFO.

In order to avoid that issue, we need to run some operations in lockstep between the CRTC and HDMI controller, and we need to make sure the HDMI controller will be powered properly.

However, since we haven't enabled it through KMS, the runtime_pm state is off at this point so we need to make sure the device is powered through pm_runtime_resume_and_get, and once the operations are complete, we call pm_runtime_put.

However, the HDMI controller will do that itself in its post_crtc_powerdown, which means we'll end up calling pm_runtime_put for a single pm_runtime_get, throwing the reference counting off. Let's remove the pm_runtime_put call in the CRTC code in order to have the proper counting.

Fixes bca10db67bda ("drm/vc4: crtc: Make sure the HDMI controller is powered when disabling")
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
index 287dbc89ad64..799aaf8c1abf 100644
@@ -525,9 +525,11 @@ int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
 	if (ret)
 		return ret;
 
-	ret = pm_runtime_put(&vc4_hdmi->pdev->dev);
-	if (ret)
-		return ret;
+	/*
+	 * post_crtc_powerdown will have called pm_runtime_put, so we
+	 * don't need it here otherwise we'll get the reference counting
+	 * wrong.
+	 */
 
 	return 0;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw

Hello Maxime,

Quoted 32 lines · Maxime Ripard

At boot on the BCM2711, if the HDMI controllers are running, the CRTC driver will disable itself and its associated HDMI controller to work around a hardware bug that would leave some pixels stuck in a FIFO.

In order to avoid that issue, we need to run some operations in lockstep between the CRTC and HDMI controller, and we need to make sure the HDMI controller will be powered properly.

However, since we haven't enabled it through KMS, the runtime_pm state is off at this point so we need to make sure the device is powered through pm_runtime_resume_and_get, and once the operations are complete, we call pm_runtime_put.

However, the HDMI controller will do that itself in its post_crtc_powerdown, which means we'll end up calling pm_runtime_put for a single pm_runtime_get, throwing the reference counting off. Let's remove the pm_runtime_put call in the CRTC code in order to have the proper counting.

Fixes bca10db67bda ("drm/vc4: crtc: Make sure the HDMI controller is powered when disabling")
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/vc4/vc4_crtc.c +0 -0
index 287dbc89ad64..799aaf8c1abf 100644
@@ -525,9 +525,11 @@ int vc4_crtc_disable_at_boot(struct drm_crtc *crtc)
 	if (ret)
 		return ret;

drivers/gpu/drm/vc4/vc4_crtc.c int vc4_crtc_disable_at_boot(struct drm_crtc *crtc) · line 533

Quoted 10 lines
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
 
-	ret = pm_runtime_put(&vc4_hdmi->pdev->dev);
-	if (ret)
-		return ret;
+	/*
+	 * post_crtc_powerdown will have called pm_runtime_put, so we
+	 * don't need it here otherwise we'll get the reference counting
+	 * wrong.
+	 */
 

I'm not familiar with the BCM2711 SoC nor its HDMI controller but your commit message clearly explain the issue and is nice to have a comment here, to avoid someone trying to do a pm_runtime_put() again.

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Linux Engineering
Red Hat
author Applied
#2 lore raw

Re: (subset) [PATCH] drm/vc4: crtc: Fix runtime_pm reference counting

In reply to Maxime Ripard
Quoted 9 lines · Maxime Ripard

At boot on the BCM2711, if the HDMI controllers are running, the CRTC driver will disable itself and its associated HDMI controller to work around a hardware bug that would leave some pixels stuck in a FIFO.

In order to avoid that issue, we need to run some operations in lockstep between the CRTC and HDMI controller, and we need to make sure the HDMI controller will be powered properly.

[...]

Applied to drm/drm-misc (drm-misc-fixes).

Thanks!
Maxime