mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
To: "Damon Ding" <damon.ding@rock-chips.com>,
	"Luca Ceresoli" <luca.ceresoli@bootlin.com>,
	"Andrzej Hajda" <andrzej.hajda@intel.com>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Robert Foss" <rfoss@kernel.org>,
	"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Jessica Zhang" <jesszhan0024@gmail.com>,
	"Laurentiu Palcu" <laurentiu.palcu@oss.nxp.com>,
	"Lucas Stach" <l.stach@pengutronix.de>,
	"Frank Li" <Frank.Li@nxp.com>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Paul Cercueil" <paul@crapouillou.net>,
	"Paul Kocialkowski" <paulk@sys-base.io>,
	"Linus Walleij" <linusw@kernel.org>,
	"Inki Dae" <inki.dae@samsung.com>,
	"Jagan Teki" <jagan@amarulasolutions.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Sean Paul" <sean@poorly.run>, "Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Randy Dunlap" <rdunlap@infradead.org>
Cc: "Albert Esteve" <aesteve@redhat.com>,
	"Anusha Srivatsa" <asrivats@redhat.com>,
	"Dmitry Baryshkov" <dmitry.baryshkov@oss.qualcomm.com>,
	"Hui Pu" <Hui.Pu@gehealthcare.com>,
	"Ian Ray" <ian.ray@gehealthcare.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
	<imx@lists.linux.dev>, <linux-arm-kernel@lists.infradead.org>,
	<linux-mips@vger.kernel.org>,
	<linux-rockchip@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<asahi@lists.linux.dev>, <linux-arm-msm@vger.kernel.org>,
	<freedreno@lists.freedesktop.org>, <linux-tegra@vger.kernel.org>,
	<linux-doc@vger.kernel.org>, <linux-samsung-soc@vger.kernel.org>,
	"Heiko Stuebner" <heiko@sntech.de>
Subject: Re: [PATCH v3 19/19] drm/bridge: analogix_dp: don't create a panel_bridge
Date: Tue, 22 Sep 2026 10:12:41 +0200	[thread overview]
Message-ID: <DLLOZYM6YWJ3.6Q0LRD1WABGW@bootlin.com> (raw)
In-Reply-To: <975a4d45-9a61-4858-b498-8bc0a1e44746@rock-chips.com>

Hello Damon,

On Mon Sep 21, 2026 at 5:07 AM CEST, Damon Ding wrote:
> Hi Luca,
>
> On 9/16/2026 9:45 PM, Luca Ceresoli wrote:
>> Now a panel_bridge is automatically created for every drm_panel and the
>> panel-bridge API is just a deprecated wrapper to access it.
>>
>> Update and simplify the code by just getting a reference to the
>> already-existing bridge using of_drm_get_bridge_by_endpoint().
>>
>> As of_drm_get_bridge_by_endpoint() returns a refcounted bridge, take care
>> of putting the bridge reference. This is not easily done in the remove path
>> due to the different probe paths of the user drivers, so add a devm action
>> to ensure the reference is put only when it was taken.
>>
>> Assisted-by: opencode:deepseek-v4-flash-0731
>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>> ---
>>   drivers/gpu/drm/bridge/analogix/Kconfig            |  1 -
>>   drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 40 +++++++++++++---------
>>   drivers/gpu/drm/exynos/exynos_dp.c                 | 36 ++-----------------
>>   drivers/gpu/drm/rockchip/analogix_dp-rockchip.c    |  9 -----
>>   include/drm/bridge/analogix_dp.h                   |  1 -
>>   5 files changed, 25 insertions(+), 62 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
>> index da156fd15764..5672d83cb4a1 100644
>> --- a/drivers/gpu/drm/bridge/analogix/Kconfig
>> +++ b/drivers/gpu/drm/bridge/analogix/Kconfig
>> @@ -33,7 +33,6 @@ config DRM_ANALOGIX_DP
>>   	depends on DRM
>>   	depends on OF
>>   	select DRM_DISPLAY_DP_AUX_BUS
>> -	select DRM_PANEL
>>
>>   config DRM_ANALOGIX_ANX7625
>>   	tristate "Analogix Anx7625 MIPI to DP interface support"
>> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> index 18e76d1e78e1..6df6963740d2 100644
>> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
>> @@ -29,7 +29,6 @@
>>   #include <drm/drm_device.h>
>>   #include <drm/drm_edid.h>
>>   #include <drm/drm_of.h>
>> -#include <drm/drm_panel.h>
>>   #include <drm/drm_print.h>
>>   #include <drm/drm_probe_helper.h>
>>
>> @@ -1567,15 +1566,6 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
>>   	if (ret)
>>   		goto err_unregister_aux;
>>
>> -	if (dp->plat_data->panel) {
>> -		dp->plat_data->next_bridge = devm_drm_panel_bridge_add(dp->dev,
>> -								       dp->plat_data->panel);
>> -		if (IS_ERR(dp->plat_data->next_bridge)) {
>> -			ret = PTR_ERR(dp->plat_data->next_bridge);
>> -			goto err_unregister_aux;
>> -		}
>> -	}
>> -
>>   	ret = drm_bridge_attach(dp->encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
>>   	if (ret) {
>>   		DRM_ERROR("failed to create bridge (%d)\n", ret);
>> @@ -1647,6 +1637,11 @@ struct drm_dp_aux *analogix_dp_get_aux(struct analogix_dp_device *dp)
>>   }
>>   EXPORT_SYMBOL_GPL(analogix_dp_get_aux);
>>
>> +static void analogix_dp_put_bridge(void *data)
>> +{
>> +	drm_bridge_put(data);
>> +}
>> +
>>   static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)
>>   {
>>   	struct analogix_dp_device *dp = to_dp(aux);
>> @@ -1655,14 +1650,25 @@ static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)
>>   	int ret;
>>
>>   	/*
>> -	 * If drm_of_find_panel_or_bridge() returns -ENODEV, there may be no valid panel
>> -	 * or bridge nodes. The driver should go on for the driver-free bridge or the DP
>> -	 * mode applications.
>> +	 * If of_drm_get_bridge_by_endpoint() returns -ENODEV, there may be no
>> +	 * valid panel or bridge nodes. The driver should go on for the
>> +	 * driver-free bridge or the DP mode applications.
>>   	 */
>> -	ret = drm_of_find_panel_or_bridge(dp->dev->of_node, port, 0,
>> -					  &plat_data->panel, &plat_data->next_bridge);
>> -	if (ret && ret != -ENODEV)
>> -		return ret;
>> +	plat_data->next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node,
>> +							       port, 0);
>> +	if (IS_ERR(plat_data->next_bridge)) {
>> +		if (PTR_ERR(plat_data->next_bridge) == -ENODEV)
>> +			plat_data->next_bridge = NULL;
>> +		else
>> +			return PTR_ERR(plat_data->next_bridge);
>> +	}
>> +
>> +	if (plat_data->next_bridge) {
>> +		ret = devm_add_action_or_reset(dp->dev, analogix_dp_put_bridge,
>> +					       plat_data->next_bridge);
>> +		if (ret)
>> +			return ret;
>> +	}
>>
>>   	return component_add(dp->dev, plat_data->ops);
>>   }
>> diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
>> index e1c9e2946b8a..82c238829921 100644
>> --- a/drivers/gpu/drm/exynos/exynos_dp.c
>> +++ b/drivers/gpu/drm/exynos/exynos_dp.c
>> @@ -26,7 +26,6 @@
>>   #include <drm/drm_crtc.h>
>>   #include <drm/drm_encoder.h>
>>   #include <drm/drm_of.h>
>> -#include <drm/drm_panel.h>
>>   #include <drm/drm_print.h>
>>   #include <drm/drm_probe_helper.h>
>>   #include <drm/exynos_drm.h>
>> @@ -147,7 +146,6 @@ static const struct component_ops exynos_dp_ops = {
>>   static int exynos_dp_probe(struct platform_device *pdev)
>>   {
>>   	struct device *dev = &pdev->dev;
>> -	struct device_node *np;
>>   	struct exynos_dp_device *dp;
>>
>>   	dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
>> @@ -163,18 +161,6 @@ static int exynos_dp_probe(struct platform_device *pdev)
>>   	 */
>>   	platform_set_drvdata(pdev, dp);
>>
>> -	/* This is for the backward compatibility. */
>> -	np = of_parse_phandle(dev->of_node, "panel", 0);
>> -	if (np) {
>> -		dp->plat_data.panel = of_drm_find_panel(np);
>> -
>> -		of_node_put(np);
>> -		if (IS_ERR(dp->plat_data.panel))
>> -			return PTR_ERR(dp->plat_data.panel);
>> -
>> -		goto out;
>> -	}
>> -
>
> TIP: In my WIP v3 patch series, I use of_drm_find_panel() together with
> devm_drm_panel_bridge_add() to maintain this backward compatibility. But
> I also think this old approach should be deprecated now. Shall we add
> some notes in the commit message to mention the deprecation of this method?

What is the "WIP v3" series exactly? Do you have a link (to v2 in case v3
is not yet public)?

>>   	if (of_get_display_timings(dev->of_node)) {
>>   		dp->plat_data.next_bridge = devm_drm_of_display_mode_bridge(dp->dev,
>>   									dp->dev->of_node,
>> @@ -189,19 +175,11 @@ static int exynos_dp_probe(struct platform_device *pdev)
>>   	dp->plat_data.power_off = exynos_dp_poweroff;
>>   	dp->plat_data.ops = &exynos_dp_ops;
>>
>> -out:
>>   	dp->adp = analogix_dp_probe(dev, &dp->plat_data);
>> -	if (IS_ERR(dp->adp)) {
>> -		/*
>> -		 * The driver core does not invoke remove() for failed probes,
>> -		 * so release the probe-time panel reference here.
>> -		 */
>> -		if (dp->plat_data.panel)
>> -			drm_panel_put(dp->plat_data.panel);
>> +	if (IS_ERR(dp->adp))
>>   		return PTR_ERR(dp->adp);
>> -	}
>>
>> -	if (dp->plat_data.panel || dp->plat_data.next_bridge)
>> +	if (dp->plat_data.next_bridge)
>>   		return component_add(&pdev->dev, &exynos_dp_ops);
>>   	else
>>   		return analogix_dp_finish_probe(dp->adp);
>> @@ -209,16 +187,6 @@ static int exynos_dp_probe(struct platform_device *pdev)
>>
>>   static void exynos_dp_remove(struct platform_device *pdev)
>>   {
>> -	struct exynos_dp_device *dp = platform_get_drvdata(pdev);
>> -
>> -	/*
>> -	 * Release the probe-time reference from of_drm_find_panel(). If bind
>> -	 * ran, the panel_bridge holds a second reference that devm cleanup
>> -	 * will release when the bridge is destroyed after remove() returns.
>> -	 */
>> -	if (dp->plat_data.panel)
>> -		drm_panel_put(dp->plat_data.panel);
>> -
>>   	component_del(&pdev->dev, &exynos_dp_ops);
>>   }
>>
>> diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
>> index 587e60232ec7..071d31aa5288 100644
>> --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
>> +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
>> @@ -28,7 +28,6 @@
>>   #include <drm/drm_bridge_connector.h>
>>   #include <drm/bridge/analogix_dp.h>
>>   #include <drm/drm_of.h>
>> -#include <drm/drm_panel.h>
>>   #include <drm/drm_print.h>
>>   #include <drm/drm_probe_helper.h>
>>
>> @@ -488,14 +487,6 @@ static void rockchip_dp_remove(struct platform_device *pdev)
>>   {
>>   	struct rockchip_dp_device *dp = platform_get_drvdata(pdev);
>>
>> -	/*
>> -	 * Release the probe-time reference from of_drm_find_panel(). If bind
>> -	 * ran, the panel_bridge holds a second reference that devm cleanup
>> -	 * will release when the bridge is destroyed after remove() returns.
>> -	 */
>> -	if (dp->plat_data.panel)
>> -		drm_panel_put(dp->plat_data.panel);
>> -
>>   	component_del(&pdev->dev, &rockchip_dp_component_ops);
>>   }
>>
>> diff --git a/include/drm/bridge/analogix_dp.h b/include/drm/bridge/analogix_dp.h
>> index 0e0b87abee59..6033137b651e 100644
>> --- a/include/drm/bridge/analogix_dp.h
>> +++ b/include/drm/bridge/analogix_dp.h
>> @@ -35,7 +35,6 @@ static inline bool analogix_dp_is_rockchip(enum analogix_dp_devtype type)
>>
>>   struct analogix_dp_plat_data {
>>   	enum analogix_dp_devtype dev_type;
>> -	struct drm_panel *panel;
>>   	struct drm_bridge *next_bridge;
>>   	struct drm_encoder *encoder;
>>   	struct drm_connector *connector;
>>
>
> I apply this patch series with the related one[0], and the eDP work well
> on my RK3576 board.
>
> Tested-by: Damon Ding <damon.ding@rock-chips.com>
>
> In my patch series for Analogix DP HPD support, Heiko also pointed out
> that devm_drm_of_get_bridge()(deprecated now) can be used to get the
> panel bridge directly, and the redundant &analogix_dp_plat_data.panel
> can be removed[1]. Since your patch series already contains these
> optimizations, I will rebase my patch series on top of yours for
> subsequent updates.

Yes, I confirm with this series devm_drm_of_get_bridge() becomes a
complicated equivalent of of_drm_get_bridge_by_endpoint(). So what Heiko
suggested is correct for current upstream code, but this patch goes a step
further, using just the bridge API as the new recommended practice will be
as soon as this series is applied.

FYI this series is now fully acked, so I plan to apply it by the end of
this week or early next week.

> Reviewed-by: Damon Ding <damon.ding@rock-chips.com>
>
> [0]
> https://lore.kernel.org/all/20260915-drm-bridge-drm_panel-cleanup-v4-0-30401d9406f3@bootlin.com/
> [1] https://lore.kernel.org/all/5609825.iZASKD2KPV@diego/

Thanks for reviewing and testing!

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2026-09-22  8:13 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 13:45 [PATCH v3 00/19] drm/panel: embed a drm_bridge into every drm_panel Luca Ceresoli
2026-09-16 13:45 ` [PATCH v3 01/19] drm: of: move drm_of_find_panel_or_bridge() from drm_of.c to drm_panel.c Luca Ceresoli
2026-09-21 15:06   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 02/19] drm: of: remove now unnecessary forward declarations Luca Ceresoli
2026-09-21 15:06   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 03/19] drm/panel: move to a new module Luca Ceresoli
2026-09-16 13:45 ` [PATCH v3 04/19] drm/bridge: panel: move all code to drm_panel.c Luca Ceresoli
2026-09-21 15:08   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 05/19] drm/panel: embed a drm_bridge into every drm_panel Luca Ceresoli
2026-09-22  6:56   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 06/19] drm/bridge: remove devm_drm_put_bridge() Luca Ceresoli
2026-09-22  6:57   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 07/19] drm/panel: deprecate panel-bridge APIs Luca Ceresoli
2026-09-22  6:57   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 08/19] drm/todo: add entry for removing the panel_bridge API Luca Ceresoli
2026-09-22  6:58   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 09/19] drm/bridge: tc358767: don't create a panel_bridge Luca Ceresoli
2026-09-22  6:59   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 10/19] drm/bridge: waveshare-dsi: " Luca Ceresoli
2026-09-22  6:59   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 11/19] drm/mcde: dsi: remove unused includes Luca Ceresoli
2026-09-20 22:26   ` Linus Walleij
2026-09-22  6:59   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 12/19] drm/mcde: dsi: don't create a panel_bridge Luca Ceresoli
2026-09-20 22:26   ` Linus Walleij
2026-09-22  7:09   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 13/19] drm/bridge: fsl-ldb: " Luca Ceresoli
2026-09-21 14:22   ` Laurentiu Palcu
2026-09-22  7:09   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 14/19] drm/bridge: samsung-dsim: " Luca Ceresoli
2026-09-22  7:10   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 15/19] drm/bridge: tc358768: " Luca Ceresoli
2026-09-22  7:10   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 16/19] drm/bridge: ssd2825: " Luca Ceresoli
2026-09-22  7:21   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 17/19] drm/omap: dss: " Luca Ceresoli
2026-09-22  7:21   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 18/19] drm/tve200: " Luca Ceresoli
2026-09-17 15:14   ` Luca Ceresoli
2026-09-22  7:28   ` Maxime Ripard
2026-09-16 13:45 ` [PATCH v3 19/19] drm/bridge: analogix_dp: " Luca Ceresoli
2026-09-21  3:07   ` Damon Ding
2026-09-21  6:34     ` Damon Ding
2026-09-22  8:07       ` Luca Ceresoli
2026-09-22  8:54         ` Damon Ding
2026-09-22  8:12     ` Luca Ceresoli [this message]
2026-09-22  8:22       ` Heiko Stuebner
2026-09-22  8:57         ` Damon Ding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DLLOZYM6YWJ3.6Q0LRD1WABGW@bootlin.com \
    --to=luca.ceresoli@bootlin.com \
    --cc=Frank.Li@nxp.com \
    --cc=Hui.Pu@gehealthcare.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=aesteve@redhat.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=asahi@lists.linux.dev \
    --cc=asrivats@redhat.com \
    --cc=corbet@lwn.net \
    --cc=damon.ding@rock-chips.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=freedreno@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=ian.ray@gehealthcare.com \
    --cc=imx@lists.linux.dev \
    --cc=inki.dae@samsung.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jesszhan0024@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kernel@pengutronix.de \
    --cc=l.stach@pengutronix.de \
    --cc=laurentiu.palcu@oss.nxp.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=paul@crapouillou.net \
    --cc=paulk@sys-base.io \
    --cc=rdunlap@infradead.org \
    --cc=rfoss@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=skhan@linuxfoundation.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®