All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/bridge: analogix_dp: Hold runtime PM reference in bridge detect
       [not found] <CGME20261119103751eucas1p16485be9bf23e31909f3b2df7c1c9d43f@eucas1p1.samsung.com>
@ 2026-11-19 10:37 ` Marek Szyprowski
  2026-11-19 18:14   ` Brian Norris
  2026-11-20  2:07   ` Damon Ding
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Szyprowski @ 2026-11-19 10:37 UTC (permalink / raw)
  To: dri-devel
  Cc: Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Damon Ding,
	Dmitry Baryshkov, Heiko Stuebner, Douglas Anderson, Brian Norris

analogix_dp_bridge_detect() calls analogix_dp_detect_hpd() without
holding a runtime PM reference on the DP device. If there is no HPD
GPIO, analogix_dp_get_plug_in_status() reads ANALOGIX_DP_SYS_CTL_3 and,
with "force-hpd", analogix_dp_force_hpd() also writes to it. When the
display is disabled the controller is runtime suspended, so these are
accesses to an unclocked (and possibly unpowered) IP block.

The connector created by drm_bridge_connector is polled because the
bridge provides DRM_BRIDGE_OP_DETECT without DRM_BRIDGE_OP_HPD, and
userspace may also query the connector state at any time, so this path
is regularly executed with the device suspended. It affects only setups
without a next bridge or panel (e.g. a DP connector), as otherwise
detect returns early.

Take a runtime PM reference around the HPD check, the same way as
analogix_dpaux_transfer() and analogix_dpaux_wait_hpd_asserted() do,
and report the connector status as unknown if the device cannot be
resumed.

Fixes: 2b77a2918c5d ("drm: bridge: analogix/dp: move hpd detect to connector detect function")
Closes: https://sashiko.dev/#/bug/linux-ea09d64b-12cd-4301-bd54-12c515b01bde
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
Changelog:
v2:
- removed pm_runtime_mark_last_busy(), as it is not included in
  pm_runtime_put_autosuspend()

v1: https://lore.kernel.org/all/20261119092857.1158971-1-m.szyprowski@samsung.com/
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 84951413012b..664ee46c8e53 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -905,9 +905,14 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
 	if (dp->plat_data->next_bridge)
 		return connector_status_connected;
 
+	if (pm_runtime_resume_and_get(dp->dev) < 0)
+		return connector_status_unknown;
+
 	if (!analogix_dp_detect_hpd(dp))
 		status = connector_status_connected;
 
+	pm_runtime_put_autosuspend(dp->dev);
+
 	return status;
 }
 
-- 
2.43.0


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

* Re: [PATCH v2] drm/bridge: analogix_dp: Hold runtime PM reference in bridge detect
  2026-11-19 10:37 ` [PATCH v2] drm/bridge: analogix_dp: Hold runtime PM reference in bridge detect Marek Szyprowski
@ 2026-11-19 18:14   ` Brian Norris
  2026-11-20  2:07   ` Damon Ding
  1 sibling, 0 replies; 3+ messages in thread
From: Brian Norris @ 2026-11-19 18:14 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: dri-devel, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Damon Ding,
	Dmitry Baryshkov, Heiko Stuebner, Douglas Anderson

On Thu, Nov 19, 2026 at 11:37:41AM +0100, Marek Szyprowski wrote:
> analogix_dp_bridge_detect() calls analogix_dp_detect_hpd() without
> holding a runtime PM reference on the DP device. If there is no HPD
> GPIO, analogix_dp_get_plug_in_status() reads ANALOGIX_DP_SYS_CTL_3 and,
> with "force-hpd", analogix_dp_force_hpd() also writes to it. When the
> display is disabled the controller is runtime suspended, so these are
> accesses to an unclocked (and possibly unpowered) IP block.

If there *is* an HPD GPIO and no 'force-hpd' ... is this patch wasteful?
How much?

(Honest question. I don't remember all the details here, but you're
suggesting this can be poked by userspace any time, so it seems like it
might be relevant.)

Brian

> The connector created by drm_bridge_connector is polled because the
> bridge provides DRM_BRIDGE_OP_DETECT without DRM_BRIDGE_OP_HPD, and
> userspace may also query the connector state at any time, so this path
> is regularly executed with the device suspended. It affects only setups
> without a next bridge or panel (e.g. a DP connector), as otherwise
> detect returns early.
> 
> Take a runtime PM reference around the HPD check, the same way as
> analogix_dpaux_transfer() and analogix_dpaux_wait_hpd_asserted() do,
> and report the connector status as unknown if the device cannot be
> resumed.
> 
> Fixes: 2b77a2918c5d ("drm: bridge: analogix/dp: move hpd detect to connector detect function")
> Closes: https://sashiko.dev/#/bug/linux-ea09d64b-12cd-4301-bd54-12c515b01bde
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> Changelog:
> v2:
> - removed pm_runtime_mark_last_busy(), as it is not included in
>   pm_runtime_put_autosuspend()
> 
> v1: https://lore.kernel.org/all/20261119092857.1158971-1-m.szyprowski@samsung.com/
> ---
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 84951413012b..664ee46c8e53 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -905,9 +905,14 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
>  	if (dp->plat_data->next_bridge)
>  		return connector_status_connected;
>  
> +	if (pm_runtime_resume_and_get(dp->dev) < 0)
> +		return connector_status_unknown;
> +
>  	if (!analogix_dp_detect_hpd(dp))
>  		status = connector_status_connected;
>  
> +	pm_runtime_put_autosuspend(dp->dev);
> +
>  	return status;
>  }
>  
> -- 
> 2.43.0
> 

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

* Re: [PATCH v2] drm/bridge: analogix_dp: Hold runtime PM reference in bridge detect
  2026-11-19 10:37 ` [PATCH v2] drm/bridge: analogix_dp: Hold runtime PM reference in bridge detect Marek Szyprowski
  2026-11-19 18:14   ` Brian Norris
@ 2026-11-20  2:07   ` Damon Ding
  1 sibling, 0 replies; 3+ messages in thread
From: Damon Ding @ 2026-11-20  2:07 UTC (permalink / raw)
  To: Marek Szyprowski, dri-devel
  Cc: Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Luca Ceresoli, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, Dmitry Baryshkov,
	Heiko Stuebner, Douglas Anderson, Brian Norris

Hi Marek,

On 11/19/2026 6:37 PM, Marek Szyprowski wrote:
> analogix_dp_bridge_detect() calls analogix_dp_detect_hpd() without
> holding a runtime PM reference on the DP device. If there is no HPD
> GPIO, analogix_dp_get_plug_in_status() reads ANALOGIX_DP_SYS_CTL_3 and,
> with "force-hpd", analogix_dp_force_hpd() also writes to it. When the
> display is disabled the controller is runtime suspended, so these are
> accesses to an unclocked (and possibly unpowered) IP block.
> 
> The connector created by drm_bridge_connector is polled because the
> bridge provides DRM_BRIDGE_OP_DETECT without DRM_BRIDGE_OP_HPD, and
> userspace may also query the connector state at any time, so this path
> is regularly executed with the device suspended. It affects only setups
> without a next bridge or panel (e.g. a DP connector), as otherwise
> detect returns early.
> 
> Take a runtime PM reference around the HPD check, the same way as
> analogix_dpaux_transfer() and analogix_dpaux_wait_hpd_asserted() do,
> and report the connector status as unknown if the device cannot be
> resumed.
> 
> Fixes: 2b77a2918c5d ("drm: bridge: analogix/dp: move hpd detect to connector detect function")
> Closes: https://sashiko.dev/#/bug/linux-ea09d64b-12cd-4301-bd54-12c515b01bde
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
> Changelog:
> v2:
> - removed pm_runtime_mark_last_busy(), as it is not included in
>    pm_runtime_put_autosuspend()
> 
> v1: https://lore.kernel.org/all/20261119092857.1158971-1-m.szyprowski@samsung.com/
> ---
>   drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 84951413012b..664ee46c8e53 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -905,9 +905,14 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
>   	if (dp->plat_data->next_bridge)
>   		return connector_status_connected;
>   
> +	if (pm_runtime_resume_and_get(dp->dev) < 0)
> +		return connector_status_unknown;
> +
>   	if (!analogix_dp_detect_hpd(dp))
>   		status = connector_status_connected;
>   
> +	pm_runtime_put_autosuspend(dp->dev);
> +
>   	return status;
>   }
>   

Aha, Sashiko also spotted this same issue in the review for my v4 
series[0]. I added the runtime PM reference handling in 
analogix_dp_bridge_detect() starting from v5, and this logic is present 
in my current v6 series[1].

As Laurent noted earlier, pm_runtime_put_autosuspend() already 
incorporates pm_runtime_mark_last_busy(). I will include an extra patch 
in my upcoming v7 series to remove the redundant 
pm_runtime_mark_last_busy() call, including the leftover instance in 
analogix_dp_bridge_detect() from [1].

[0] https://lore.kernel.org/all/sashiko-outbox-176895@kernel.org/
[1] 
https://lore.kernel.org/all/20261113082305.541652-4-damon.ding@rock-chips.com/

Best regards,
Damon


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

end of thread, other threads:[~2026-11-20  2:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20261119103751eucas1p16485be9bf23e31909f3b2df7c1c9d43f@eucas1p1.samsung.com>
2026-11-19 10:37 ` [PATCH v2] drm/bridge: analogix_dp: Hold runtime PM reference in bridge detect Marek Szyprowski
2026-11-19 18:14   ` Brian Norris
2026-11-20  2:07   ` Damon Ding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.