linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX
@ 2022-02-17 22:41 Brian Norris
  2022-02-17 22:41 ` [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend Brian Norris
  2022-02-22 22:10 ` [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX Doug Anderson
  0 siblings, 2 replies; 5+ messages in thread
From: Brian Norris @ 2022-02-17 22:41 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong
  Cc: linux-kernel, linux-rockchip, Doug Anderson, Sean Paul,
	Jernej Skrabec, dri-devel, Laurent Pinchart, Jonas Karlman,
	Brian Norris, stable, Tomeu Vizoso

If the display is not enable()d, then we aren't holding a runtime PM
reference here. Thus, it's easy to accidentally cause a hang, if user
space is poking around at /dev/drm_dp_aux0 at the "wrong" time.

Let's get a runtime PM reference, and check that we "see" the panel.
Don't force any panel power-up, etc., because that can be intrusive, and
that's not what other drivers do (see
drivers/gpu/drm/bridge/ti-sn65dsi86.c and
drivers/gpu/drm/bridge/parade-ps8640.c.)

Fixes: 0d97ad03f422 ("drm/bridge: analogix_dp: Remove duplicated code")
Cc: <stable@vger.kernel.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Brian Norris <briannorris@chromium.org>
---

Changes in v3:
- Avoid panel power-up; just check for HPD state, and let the rest
  happen "as-is" (e.g., time out, if the caller hasn't prepared things
  properly)

Changes in v2:
- Fix spelling in Subject
- DRM_DEV_ERROR() -> drm_err()
- Propagate errors from un-analogix_dp_prepare_panel()

 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index b7d2e4449cfa..16be279aed2c 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1632,8 +1632,19 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 				       struct drm_dp_aux_msg *msg)
 {
 	struct analogix_dp_device *dp = to_dp(aux);
+	int ret;
+
+	pm_runtime_get_sync(dp->dev);
+
+	ret = analogix_dp_detect_hpd(dp);
+	if (ret)
+		goto out;
 
-	return analogix_dp_transfer(dp, msg);
+	ret = analogix_dp_transfer(dp, msg);
+out:
+	pm_runtime_put(dp->dev);
+
+	return ret;
 }
 
 struct analogix_dp_device *
-- 
2.35.1.265.g69c8d7142f-goog


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

end of thread, other threads:[~2022-03-02  2:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-17 22:41 [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX Brian Norris
2022-02-17 22:41 ` [PATCH v3 2/2] drm/bridge: analogix_dp: Enable autosuspend Brian Norris
2022-02-22 22:09   ` Doug Anderson
2022-03-02  2:03     ` Brian Norris
2022-02-22 22:10 ` [PATCH v3 1/2] drm/bridge: analogix_dp: Grab runtime PM reference for DP-AUX Doug Anderson

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