Skip to contentSkip to conversation

drm/lcdif: Do not disable clocks on already suspended hardware

PATCH Superseded Marek Vasut 2 participants 2 messages Feb 26, 2024

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Marek Vasut

author maintainer
#0 lore raw

PATCH v2 1/1 drm/lcdif: Do not disable clocks on already suspended hardware

In case the LCDIF is enabled in DT but unused, the clocks used by the LCDIF are not enabled. Those clocks may even have a use count of 0 in case there are no other users of those clocks. This can happen e.g. in case the LCDIF drives HDMI bridge which has no panel plugged into the HDMI connector.

Do not attempt to disable clocks in the suspend callback and re-enable clocks in the resume callback unless the LCDIF is enabled and was in use before the system entered suspend, otherwise the driver might end up trying to disable clocks which are already disabled with use count 0, and would trigger a warning from clocks core about this condition.

Note that the lcdif_rpm_suspend() and lcdif_rpm_resume() functions internally perform the clocks disable and enable operations and act as runtime PM hooks too.

Fixes 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant")

---
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: NXP Linux Team <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: - s@clock@clocks@g in commit message
- Add RB from Liu

---
 drivers/gpu/drm/mxsfb/lcdif_drv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/mxsfb/lcdif_drv.c +5 -1
index 18de2f17e2491..6494e82707569 100644
@@ -340,6 +340,9 @@ static int __maybe_unused lcdif_suspend(struct device *dev)
 	if (ret)
 		return ret;
 
+	if (pm_runtime_suspended(dev))
+		return 0;
+
 	return lcdif_rpm_suspend(dev);
 }
 
@@ -347,7 +350,8 @@ static int __maybe_unused lcdif_resume(struct device *dev)
 {
 	struct drm_device *drm = dev_get_drvdata(dev);
 
-	lcdif_rpm_resume(dev);
+	if (!pm_runtime_suspended(dev))
+		lcdif_rpm_resume(dev);
 
 	return drm_mode_config_helper_resume(drm);
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 1 line · Marek Vasut

0, and would trigger a warning from clocks core about this condition.

s/clocks/clock/

Liu Ying