* [PATCH v3] drm/msm/dp: hold one runtime PM reference per plugged state
@ 2026-10-24 5:19 Joonhoe Kim
0 siblings, 0 replies; only message in thread
From: Joonhoe Kim @ 2026-10-24 5:19 UTC (permalink / raw)
To: robin.clark, lumag
Cc: abhinav.kumar, jesszhan0024, sean, marijn.suijten, airlied,
simona, yongxing.mou, val, dmitry.baryshkov, linux-arm-msm,
dri-devel, freedreno, linux-kernel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-24 22:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-24 5:19 [PATCH v3] drm/msm/dp: hold one runtime PM reference per plugged state Joonhoe Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox