From nobody Tue Apr 7 20:07:40 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A37F13A7F5F for ; Tue, 7 Apr 2026 12:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775564750; cv=none; b=V8YKPEAA6RcrqPfJo2VJQrJ/eJzcdk/XX65pkOrYwzs/Wu++/ltejW2i7dW4L/ciwDorbjL6qePojmx2fNbxOgv1Ih1NslPeu3wYSfme9r6L/gkH/HvSr0i/w88g6CynWhl2z3G8TQ4XF5ffVeJeI3oP+z/V+r+55cf2xQAYMXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775564750; c=relaxed/simple; bh=kzRJ0oJa/Zcsh1hbeO9DstRQpwVqFH/JmMMnA1SD13o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OH3o++BPf/Jrev0fC04aGPiDD/cY3X5m0Zg7NZ4/y8CAGP26/1kOvG2RmQ5H3y549SoqLOUmtciTUbgL7N2KYJJRx3ka+6bvgWBSaZ3rS1jFCNDUxRY4Jwg73omyuJrixuYTIO2pz3agr2x3E3p1+SMPpq0UAkPDkquP2t9H12M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=RS8jJlaR; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RS8jJlaR" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 5BA0CC5B19A; Tue, 7 Apr 2026 12:26:21 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 9022E603C7; Tue, 7 Apr 2026 12:25:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id CD56810450161; Tue, 7 Apr 2026 14:25:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775564745; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=pzQa4LFTxQ05HmhgeiPTDH3E+TPAwdvNa3fkB5+WstU=; b=RS8jJlaRarHgZkUDtAZwbgLS5sixZJ/iGe/5J7CahR8oPw6OLR2eBpqoaRyswbAXjjbMah bxWRGMAk5glJx/M+DxjsHb11779OYLOOnQOw4jw9PjYpBATOTAvdKahbrkSCyvSJj3BosC clTvN7w5Wj2Fqe3YLsJlBGzfLZDJNoOw6O1yzAGK01uyHNaIY2JQJr69JhxazbxGmJP1F9 MqjUFkA4EHCUWz7KUeIYTaeksonLm6CLFm2N+hfcbRaCUUaMGHXHbMhsaDdl5eHRIrNLYa 7nVpHQ4oGkSf8B3PK8UWfRi7tBWvVPYLVq8LP2iA7qwHBRsG1GT6NYWrUgiAbg== From: Luca Ceresoli Date: Tue, 07 Apr 2026 14:24:21 +0200 Subject: [PATCH v4 07/11] drm/bridge: dw-hdmi: move next_bridge lookup to attach time Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260407-drm-lcdif-dbanc-v4-7-247a16e61ef9@bootlin.com> References: <20260407-drm-lcdif-dbanc-v4-0-247a16e61ef9@bootlin.com> In-Reply-To: <20260407-drm-lcdif-dbanc-v4-0-247a16e61ef9@bootlin.com> To: Marek Vasut , Stefan Agner , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Liu Ying , Rob Herring , Saravana Kannan Cc: Damon Ding , "Kory Maincent (TI.com)" , =?utf-8?q?Herv=C3=A9_Codina?= , Hui Pu , Ian Ray , Thomas Petazzoni , dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Adam Ford , Alexander Stein , Christopher Obbard , Daniel Scally , Emanuele Ghidoli , Fabio Estevam , Francesco Dolcini , Frieder Schrempf , Gilles Talis , =?utf-8?q?Goran_Ra=C4=91enovi=C4=87?= , Heiko Schocher , Josua Mayer , Kieran Bingham , Marco Felsch , Martyn Welch , Oleksij Rempel , Peng Fan , Richard Hu , Shengjiu Wang , Stefan Eichenberger , Vitor Soares , Luca Ceresoli X-Mailer: b4 0.15.1 X-Last-TLS-Session-Version: TLSv1.3 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. Tested-by: Martyn Welch Tested-by: Alexander Stein # TQMa8MPxL/MB= a8MPxL Acked-by: Liu Ying Tested-by: Damon Ding # rk3399 Signed-off-by: Luca Ceresoli --- Changes in v2: - Fix returned error codes - Added missing cleanup.h include --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 45 +++++++++++----------------= ---- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/br= idge/synopsys/dw-hdmi.c index ab1a6a8783cd..f4a1ebb79716 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -6,6 +6,8 @@ * Copyright (C) 2011-2013 Freescale Semiconductor, Inc. * Copyright (C) 2010, Guennadi Liakhovetski */ + +#include #include #include #include @@ -2914,9 +2916,20 @@ 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; =20 - 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) =3D + of_graph_get_remote_node(hdmi->dev->of_node, + hdmi->plat_data->output_port, -1); + if (!remote) + return -ENODEV; + + struct drm_bridge *next_bridge __free(drm_bridge_put) =3D + of_drm_find_and_get_bridge(remote); + if (!next_bridge) + return -EPROBE_DEFER; + + return drm_bridge_attach(encoder, next_bridge, bridge, flags); + } =20 return dw_hdmi_connector_create(hdmi); } @@ -3307,28 +3320,6 @@ static void dw_hdmi_init_hw(struct dw_hdmi *hdmi) * Probe/remove API, used from platforms based on the DRM bridge API. */ =20 -static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi) -{ - struct device_node *remote; - - if (!hdmi->plat_data->output_port) - return 0; - - - remote =3D of_graph_get_remote_node(hdmi->dev->of_node, - hdmi->plat_data->output_port, - -1); - if (!remote) - return -ENODEV; - - hdmi->bridge.next_bridge =3D of_drm_find_and_get_bridge(remote); - of_node_put(remote); - if (!hdmi->bridge.next_bridge) - return -EPROBE_DEFER; - - return 0; -} - bool dw_hdmi_bus_fmt_is_420(struct dw_hdmi *hdmi) { return hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format); @@ -3373,10 +3364,6 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device= *pdev, mutex_init(&hdmi->cec_notifier_mutex); spin_lock_init(&hdmi->audio_lock); =20 - ret =3D dw_hdmi_parse_dt(hdmi); - if (ret < 0) - return ERR_PTR(ret); - ddc_node =3D of_parse_phandle(np, "ddc-i2c-bus", 0); if (ddc_node) { hdmi->ddc =3D of_get_i2c_adapter_by_node(ddc_node); --=20 2.53.0