Re: [PATCH 6/8] drm/bridge: dw-hdmi: move next_bridge lookup to attach time

Liu Ying
2026-03-26T07:49:06Z

Hi Luca,

On Fri, Mar 20, 2026 at 11:46:17AM +0100, Luca Ceresoli wrote:
> This driver looks up the next_bridge at probe time and stores it in
> hdmi->bridge.next_bridge, but only uses the stored value when attaching,
> and only in the DRM_BRIDGE_ATTACH_NO_CONNECTOR case.
>
> This will be problematic with an upcoming change, adding an hdmi-connector
> using a device tree overlay when not present. That change is in turn
> necessary to migrate the i.MX LCDIF driver to the bridge-connector.
>
> The problem is that, adding the hdmi-connector via an overlay, devlink
> considers hdmi-connector a consumer of the dw-hdmi device, generating a
> chicken-egg problem:
>
> * hdmi-connector probe won't be tried until dw-hdmi is probed (devlink)
> * dw-hdmi probe will defer until it finds the next_bridge (the
> hdmi-connector wrapper bridge)
>
> In preparation for those changes, move the next_bridge lookup from probe to
> attach, when it is actually used. This allows dw-hdmi to probe, so that the
> hdmi-connector can probe as well.
>
> Also avoid storing the pointer in hdmi->bridge.next_bridge: the value is
> computed when needed, thus a local variable is enough.
>
> Finally, this also allows to slightly improve the code by not doing any DT
> lookup in the !DRM_BRIDGE_ATTACH_NO_CONNECTOR case.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> ---
> drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 41 +++++++++----------------------
> 1 file changed, 12 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index a668d66aeece..4ee865a1a6c8 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -2914,9 +2914,18 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge,
> if (WARN_ON((flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) && !hdmi->plat_data->output_port))
> return -EINVAL;
>
> - if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
> - return drm_bridge_attach(encoder, hdmi->bridge.next_bridge,
> - bridge, flags);
> + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
> + struct device_node *remote __free(device_node) =

Include linux/cleanup.h as __free() is used.

> + of_graph_get_remote_node(hdmi->dev->of_node,
> + hdmi->plat_data->output_port, -1);
> + if (!remote)
> + return -EPROBE_DEFER;

Should return -ENODEV instead?

> +
> + struct drm_bridge *next_bridge __free(drm_bridge_put) =
> + of_drm_find_and_get_bridge(remote);
> +
> + return drm_bridge_attach(encoder, next_bridge, bridge, flags);
> + }
>
> return dw_hdmi_connector_create(hdmi);
> }

--
Regards,
Liu Ying