mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joonhoe Kim <26rote@gmail.com>
To: robin.clark@oss.qualcomm.com, lumag@kernel.org
Cc: abhinav.kumar@linux.dev, jesszhan0024@gmail.com, sean@poorly.run,
	marijn.suijten@somainline.org, airlied@gmail.com,
	simona@ffwll.ch, yongxing.mou@oss.qualcomm.com, val@packett.cool,
	dmitry.baryshkov@oss.qualcomm.com, linux-arm-msm@vger.kernel.org,
	dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3] drm/msm/dp: hold one runtime PM reference per plugged state
Date: Sat, 24 Oct 2026 14:19:52 +0900	[thread overview]
Message-ID: <20261024051952.2006-1-26rote@gmail.com> (raw)

msm_dp_bridge_detect() takes a runtime PM reference and keeps it when
it leaves the sink plugged, so that the plugged state keeps the
controller on. If the sink was plugged already, the plugged state holds
a reference, and the new one is leaked. If the sink was plugged and
detect() finds it gone, it drops only its own reference and clears the
plugged state, so the unplug handler skips the put and the plugged
state's reference is leaked as well.

detect() runs on every probe of the connector. When HPD comes from a
later bridge, such as a USB-C connector, nothing else keeps the
controller on, and the leaked references keep it and the MDSS core GDSC
powered after the display is unplugged.

Hold the function's own reference for the duration of the call, take
the plugged state's reference when detect() sets the plugged state and
drop it when detect() clears it.

Fixes: 3ea2d1c3d154 ("drm/msm/dp: turn link_ready into plugged")
Signed-off-by: Joonhoe Kim <26rote@gmail.com>
---
Depends on patch 6/9 of the IRQ_HPD series v8 [1], which stops the
plug handler from taking extra references; only detect() is left here.
Dmitry, feel free to fold this into that series if you prefer.

Tested on v7.3 with 6/9 of [1] and this patch on a Lenovo Y700 Gen 5
(TB323FU) with a USB-C display: booting with the display connected,
plug, unplug, quick replug and s2idle. The controller suspends after
unplug.

Changes in v3:
- Rebase on [1] and drop the plug handler part
- Hold detect()'s own reference with PM_RUNTIME_ACQUIRE_IF_ENABLED()
  and take or drop the plugged state's reference only when detect()
  changes the plugged state [Val]
- detect() now drops its last reference with pm_runtime_put() instead
  of pm_runtime_put_sync()
- Link to v2: https://lore.kernel.org/all/20261007155848.106-1-26rote@gmail.com/

[1] https://lore.kernel.org/all/20261024-hpd-irq-events-v8-0-6ee949e7a384@oss.qualcomm.com/

 drivers/gpu/drm/msm/dp/dp_display.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index ed899fcc9189..5f9402921efa 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -908,6 +908,7 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge,
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
 	struct drm_dp_desc desc;
 	bool phy_deinit;
+	bool was_plugged;
 	int ret;
 
 	dp = to_dp_bridge(bridge)->msm_dp_display;
@@ -915,12 +916,14 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge,
 	priv = container_of(dp, struct msm_dp_display_private, msm_dp_display);
 
 	guard(mutex)(&priv->plugged_lock);
-	ret = pm_runtime_resume_and_get(&dp->pdev->dev);
+	PM_RUNTIME_ACQUIRE_IF_ENABLED(&dp->pdev->dev, pm);
+	ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
 	if (ret) {
 		DRM_ERROR("failed to pm_runtime_resume\n");
 		return status;
 	}
 
+	was_plugged = priv->plugged;
 	phy_deinit = msm_dp_display_host_phy_init(priv);
 
 	msm_dp_aux_enable_xfers(priv->aux, true);
@@ -970,7 +973,10 @@ enum drm_connector_status msm_dp_bridge_detect(struct drm_bridge *bridge,
 			msm_dp_display_host_phy_exit(priv);
 		}
 
-		pm_runtime_put_sync(&dp->pdev->dev);
+		if (was_plugged)
+			pm_runtime_put_noidle(&dp->pdev->dev);
+	} else if (!was_plugged) {
+		pm_runtime_get_noresume(&dp->pdev->dev);
 	}
 
 	return status;

base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
prerequisite-patch-id: f2dbe1f42c357bb1d32081f58660ed1fac8f7777
prerequisite-patch-id: 358e5f35d442041b88e52d8e39a564a053a0f990
prerequisite-patch-id: 9860b9acb12b1c2652e4e9f4860968a2ca3361f0
prerequisite-patch-id: 53486e695198f785401740f7f4372bdf335fb620
prerequisite-patch-id: c8e551a07553f7dc107063a1dbec1d415184f97b
prerequisite-patch-id: 1a6251919897ca5e8b12a63774a833fd8460c67a
prerequisite-patch-id: 846ab694795c6bec123d1dc46d7a53097bf594bf
prerequisite-patch-id: 2a058aa8309016f424b1d4ca19a9b20e92f4d8b6
prerequisite-patch-id: 76ea1ecf4e1d83ce2e5730aa36ed1a4524f15e56
-- 
2.43.0


                 reply	other threads:[~2026-10-24  5:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261024051952.2006-1-26rote@gmail.com \
    --to=26rote@gmail.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=airlied@gmail.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=val@packett.cool \
    --cc=yongxing.mou@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®