dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/lcdif: Do not disable clocks on already suspended hardware
@ 2024-02-26  7:28 Marek Vasut
  2024-02-26  7:45 ` Ying Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Marek Vasut @ 2024-02-26  7:28 UTC (permalink / raw)
  To: dri-devel
  Cc: Marek Vasut, Liu Ying, Daniel Vetter, David Airlie,
	Fabio Estevam, Maarten Lankhorst, Maxime Ripard, NXP Linux Team,
	Pengutronix Kernel Team, Sascha Hauer, Shawn Guo, Stefan Agner,
	Thomas Zimmermann, linux-arm-kernel

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.

Reviewed-by: Liu Ying <victor.liu@nxp.com>
Fixes: 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant")
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Liu Ying <victor.liu@nxp.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: NXP Linux Team <linux-imx@nxp.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Cc: linux-arm-kernel@lists.infradead.org
---
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(-)

diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
index 18de2f17e2491..6494e82707569 100644
--- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
+++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
@@ -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);
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH v2] drm/lcdif: Do not disable clocks on already suspended hardware
  2024-02-26  7:28 [PATCH v2] drm/lcdif: Do not disable clocks on already suspended hardware Marek Vasut
@ 2024-02-26  7:45 ` Ying Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Ying Liu @ 2024-02-26  7:45 UTC (permalink / raw)
  To: Marek Vasut, dri-devel
  Cc: Daniel Vetter, David Airlie, Fabio Estevam, Maarten Lankhorst,
	Maxime Ripard, dl-linux-imx, Pengutronix Kernel Team,
	Sascha Hauer, Shawn Guo, Stefan Agner, Thomas Zimmermann,
	linux-arm-kernel

On Monday, February 26, 2024 3:28 PM, Marek Vasut <marex@denx.de> wrote:
> 0, and would trigger a warning from clocks core about this condition.

s/clocks/clock/

Liu Ying

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-26  7:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-26  7:28 [PATCH v2] drm/lcdif: Do not disable clocks on already suspended hardware Marek Vasut
2024-02-26  7:45 ` Ying Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).