[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250210-bronze-copperhead-of-faith-12d0a9@houat>
Date: Mon, 10 Feb 2025 19:23:47 +0100
From: Maxime Ripard <mripard@...nel.org>
To: Luca Ceresoli <luca.ceresoli@...tlin.com>
Cc: Simona Vetter <simona@...ll.ch>, Inki Dae <inki.dae@...sung.com>,
Jagan Teki <jagan@...rulasolutions.com>, Marek Szyprowski <m.szyprowski@...sung.com>,
Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>, Shawn Guo <shawnguo@...nel.org>,
Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>,
Fabio Estevam <festevam@...il.com>, Daniel Thompson <danielt@...nel.org>,
Andrzej Hajda <andrzej.hajda@...el.com>, Jonathan Corbet <corbet@....net>,
Sam Ravnborg <sam@...nborg.org>, Boris Brezillon <bbrezillon@...nel.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>, Alexandre Belloni <alexandre.belloni@...tlin.com>,
Claudiu Beznea <claudiu.beznea@...on.dev>, Jessica Zhang <quic_jesszhan@...cinc.com>,
Paul Kocialkowski <contact@...lk.fr>, Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Neil Armstrong <neil.armstrong@...aro.org>, Robert Foss <rfoss@...nel.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>, Jonas Karlman <jonas@...boo.se>,
Jernej Skrabec <jernej.skrabec@...il.com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Thomas Zimmermann <tzimmermann@...e.de>, David Airlie <airlied@...il.com>,
Hervé Codina <herve.codina@...tlin.com>, Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org, linux-doc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, Paul Kocialkowski <paul.kocialkowski@...tlin.com>
Subject: Re: [PATCH v6 11/26] drm/bridge: samsung-dsim: use
devm_drm_of_get_bridge[_by_node] to find the out_bridge
On Thu, Feb 06, 2025 at 07:14:26PM +0100, Luca Ceresoli wrote:
> In order to support panels described either via graph links or via a
> subnode (e.g. "panel@0"), this driver uses low-level deprecated functions
> to find the next bridge. The resulting logic is complex and duplicates code
> already present in the DRM bridge core. Switch to the new APIs in DRM
> bridge core that allow to do the same in a much cleaner way.
>
> Note there are two slight changes in the new logic intended to improve the
> final result:
>
> * the old code looks for a subnode with any name except "port" or "ports",
> while the new code uses the node passed as a parameter
>
> * the old code looks for a subnode first and falls back to a graph link,
> while the new code uses the reverse order because graph links are the
> recommended device tree representation now
>
> The first change makes the code more robust by avoiding the risk of using
> an unrelated node which is not describing a panel and not names "port" or
> "ports".
>
> The second change is not expected to expose regressions because, in the
> cases where both a subnode and a graph link are used to describe a panel,
> the graph link should point to the subnode itself, such as in
> arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
>
> As a further cleanup, use a temporary variable to assign dsi->out_bridge
> only on success. This avoids the risk of leaving a non-NULL value in
> dsi->out_bridge when samsung_dsim_host_attach() fails.
>
> Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@...aro.org>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@...tlin.com>
>
> ---
>
> This patch was added in v6.
> ---
> drivers/gpu/drm/bridge/samsung-dsim.c | 55 ++++++-----------------------------
> 1 file changed, 9 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index f8b4fb8357659018ec0db65374ee5d05330639ae..bbd0a4f5a3f52b61bf48f10d6e8ca741bffa5e46 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -1704,55 +1704,16 @@ static int samsung_dsim_host_attach(struct mipi_dsi_host *host,
> const struct samsung_dsim_plat_data *pdata = dsi->plat_data;
> struct device *dev = dsi->dev;
> struct device_node *np = dev->of_node;
> - struct device_node *remote;
> - struct drm_panel *panel;
> + struct drm_bridge *out_bridge;
> int ret;
>
> - /*
> - * Devices can also be child nodes when we also control that device
> - * through the upstream device (ie, MIPI-DCS for a MIPI-DSI device).
> - *
> - * Lookup for a child node of the given parent that isn't either port
> - * or ports.
> - */
> - for_each_available_child_of_node(np, remote) {
> - if (of_node_name_eq(remote, "port") ||
> - of_node_name_eq(remote, "ports"))
> - continue;
> + out_bridge = devm_drm_of_get_bridge(dev, np, 1, 0);
> + if (IS_ERR(out_bridge) && PTR_ERR(out_bridge) != -EPROBE_DEFER)
> + out_bridge = devm_drm_of_get_bridge_by_node(dev, device->dev.of_node);
>
For the same reason I mentioned earlier, this is inherently unsafe if
the bridge device goes away but the DRM device doesn't.
Maxime
Download attachment "signature.asc" of type "application/pgp-signature" (274 bytes)
Powered by blists - more mailing lists