Blob Blame History Raw
From 9984d6664ce9dcbbc713962539eaf7636ea246c2 Mon Sep 17 00:00:00 2001
From: Maxime Ripard <maxime@cerno.tech>
Date: Tue, 25 May 2021 11:10:59 +0200
Subject: drm/vc4: hdmi: Make sure the controller is powered in detect
Git-commit: 9984d6664ce9dcbbc713962539eaf7636ea246c2
Patch-mainline: v5.13
References: bsc#1152489

If the HPD GPIO is not available and drm_probe_ddc fails, we end up
reading the HDMI_HOTPLUG register, but the controller might be powered
off resulting in a CPU hang. Make sure we have the power domain and the
HSM clock powered during the detect cycle to prevent the hang from
happening.

Fixes: 4f6e3d66ac52 ("drm/vc4: Add runtime PM support to the HDMI encoder driver")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210525091059.234116-4-maxime@cerno.tech
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/drm/vc4/vc4_hdmi.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -200,6 +200,8 @@ vc4_hdmi_connector_detect(struct drm_con
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	bool connected = false;
 
+	WARN_ON(pm_runtime_resume_and_get(&vc4->hdmi->pdev->dev));
+
 	if (vc4->hdmi->hpd_gpio) {
 		if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio) ^
 		    vc4->hdmi->hpd_active_low)
@@ -220,10 +222,12 @@ vc4_hdmi_connector_detect(struct drm_con
 			}
 		}
 
+		pm_runtime_put(&vc4->hdmi->pdev->dev);
 		return connector_status_connected;
 	}
 
 	cec_phys_addr_invalidate(vc4->hdmi->cec_adap);
+	pm_runtime_put(&vc4->hdmi->pdev->dev);
 	return connector_status_disconnected;
 }