From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Liu Ying <victor.liu@nxp.com>
Cc: 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>,
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>,
Jagan Teki <jagan@amarulasolutions.com>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Douglas Anderson <dianders@chromium.org>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>,
Anusha Srivatsa <asrivats@redhat.com>,
Paul Kocialkowski <paulk@sys-base.io>,
Dmitry Baryshkov <lumag@kernel.org>,
Hui Pu <Hui.Pu@gehealthcare.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
dri-devel@lists.freedesktop.org, asahi@lists.linux.dev,
linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev,
imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
linux-amlogic@lists.infradead.org,
linux-renesas-soc@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org,
freedreno@lists.freedesktop.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
Date: Mon, 26 May 2025 09:20:24 +0200 [thread overview]
Message-ID: <20250526092024.48cae4ae@booty> (raw)
In-Reply-To: <67252c36-8b31-4c40-9d89-4f502da4a087@nxp.com>
Hello Liu,
On Thu, 22 May 2025 11:01:13 +0800
Liu Ying <victor.liu@nxp.com> wrote:
> On 05/07/2025, Luca Ceresoli wrote:
>
> [...]
>
> >> After looking into this patch and patch 31(though I've already provided my A-b)
> >> more closely, I think the imx8qxp_pc and imx8{qm,qxp}_ldb main structures
> >> should have the same life time with the embedded DRM bridges, because for
> >> example the clk_apb clock in struct imx8qxp_pc would be accessed by the
> >> imx8qxp_pc_bridge_mode_set DRM bridge callback. But, IIUC, your patches extend
> >> the life time for the embedded channel/bridge structures only, but not for the
> >> main structures. What do you think ?
> >
> > I see you concern, but I'm sure the change I'm introducing is not
> > creating the problem you are concerned about.
> >
> > The key aspect is that my patch is merely changing the lifetime of the
> > _allocation_ of the drm_bridge, not its usage. On drm_bridge_remove()
> > the bridge is removed from its encoder chain and it is completely not
> > reachable, both before and after my patch. With my patch it is not
>
> drm_bridge_remove() only removes a bridge from the global bridge_list defined
> in drm_bridge.c. drm_bridge_detach() is the one which removes a bridge from
> it's encoder chain. It looks like you wrongly thought drm_bridge_remove()
> is drm_bridge_detach().
Indeed my sentence was inaccurate, sorry about that.
> So, even if drm_bridge_remove() is called, the removed
> bridge could still be in it's encoder chain, hence an atomic commit could still
> access the allocated bridge(with lifetime extended) and the clock_apb clock
> for example in struct imx8qxp_pc could also be accessed. That's why I think
> the main structures should have the same lifetime with the allocated bridge.
As the long-term goal is to allow bridges to be hot-removable,
decoupling the lifetime of the various components is a necessary step.
Definitely it will open other issues, and especially the removal during
atomic updates. This has been discussed already, and there is a
proposed plan to handle it.
First, here is the grand plan (mentioned in the v3 cover letter):
1. ➜ add refcounting to DRM bridges (struct drm_bridge)
2. handle gracefully atomic updates during bridge removal
3. avoid DSI host drivers to have dangling pointers to DSI devices
4. finally, let bridges be removable (depends on 1+2+3)
We are now at step 1. Your concern, as I understand it, will be
addressed at step 2. Bridges won't be removable until step 4, so the
current changes are not introducing a misbehavior but rather preparing
the ground with all the necessary infrastructure changes.
Step 2 was discussed in the past [0], and the idea proposed by Maxime
is to introduce a "gone" or "unplugged" flag and drm_bridge_enter() /
drm_bridge_exit() functions. The principle is the same as struct
drm_device.unplugged and drm_dev_enter/exit().
In a nutshell the idea is:
- drm_bridge.unplugged is initialized to false
- drm_bridge_enter() returns false if drm_bridge.unplugged == true
- any code holding a pointer to the bridge (including the bridge driver
itself) and operating on the bridge (including removal) needs to do:
if (drm_bridge_enter()) {
do something;
drm_bridge_exit();
}
- when the bridge is removed, the driver removal function sets
dev_bridge.unplugged = true
The "do something" above includes any access to device resources,
including clocks (and clk_apb).
In other words, two pieces of code can not access the bridge structure
at the same time. This includes bridge removal VS any atomic operations.
Do you think this addresses your concern?
For you to have a better picture of the path, here's an additional
clarification about drm_bridge_attach/detach() and
drm_bridge_add/remove(). As part of step 1 of the grand plan, both of
them will drm_bridge_get/put() the bridge, so that no bridge is freed
if it is either in the global bridge_list or in any encoder chain.
Patches for this are already approved by Maxime [1][2]. They cannot be
applied until all bridge drivers have been converted to the new
devm_drm_bridge_alloc() API, so they depend on this series to be
completely applied. We are getting pretty close: as of now the entire
series has been applied except for this and another driver.
[0] https://lore.kernel.org/all/20250129125153.35d0487a@booty/t/#u
[1] https://patchwork.freedesktop.org/patch/643095/
[2] https://patchwork.freedesktop.org/patch/643096/
Best regards,
Luca
--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-05-26 7:20 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 12:44 ` Andy Yan
2025-04-28 15:00 ` [PATCH " Luca Ceresoli
2025-04-28 20:59 ` Doug Anderson
2025-04-30 10:35 ` Luca Ceresoli
2025-04-30 15:51 ` Doug Anderson
2025-04-30 16:42 ` Luca Ceresoli
2025-04-29 2:19 ` Liu Ying
2025-04-29 7:07 ` Luca Ceresoli
2025-04-30 9:42 ` Manikandan.M
2025-04-30 10:36 ` Luca Ceresoli
2025-05-05 5:20 ` Manikandan.M
2025-04-24 18:59 ` [PATCH v2 02/34] platform: arm64: acer-aspire1-ec: convert " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
2025-04-28 12:29 ` Andy Yan
2025-04-24 18:59 ` [PATCH v2 04/34] drm/bridge: anx7625: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 05/34] drm/bridge: cdns-dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 06/34] drm/bridge: display-connector: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
2025-04-29 12:09 ` Dmitry Baryshkov
2025-04-24 18:59 ` [PATCH v2 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 09/34] drm/bridge: nxp-ptn3460: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 10/34] drm/bridge: sii902x: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
2025-04-24 19:16 ` Cristian Ciocaltea
2025-04-24 18:59 ` [PATCH v2 12/34] drm/bridge: tda998x: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
2025-04-28 20:53 ` Doug Anderson
2025-04-24 18:59 ` [PATCH v2 14/34] drm/exynos: mic: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 15/34] drm/mcde: " Luca Ceresoli
2025-04-29 8:40 ` Linus Walleij
2025-04-24 18:59 ` [PATCH v2 16/34] drm/msm/dp: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 17/34] drm/msm/dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 18/34] drm/msm/hdmi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 19/34] drm/omap: dss: dpi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 20/34] drm/omap: dss: dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 21/34] drm/omap: dss: hdmi4: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 22/34] drm/omap: dss: hdmi5: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 23/34] drm/omap: dss: sdi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 24/34] drm/omap: dss: venc: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 25/34] drm/rcar-du: dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 26/34] drm/bridge: stm_lvds: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 27/34] drm/vc4: " Luca Ceresoli
2025-04-28 15:45 ` Dave Stevenson
2025-04-24 18:59 ` [PATCH v2 28/34] drm/sti: dvo: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 29/34] drm: zynqmp_dp: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
2025-04-29 2:10 ` Liu Ying
2025-04-30 9:29 ` Luca Ceresoli
2025-05-06 2:24 ` Liu Ying
2025-05-06 20:47 ` Luca Ceresoli
2025-05-07 2:10 ` Liu Ying
2025-05-07 7:12 ` Luca Ceresoli
2025-05-07 10:16 ` Liu Ying
2025-05-07 14:13 ` Luca Ceresoli
2025-05-22 3:01 ` Liu Ying
2025-05-26 7:20 ` Luca Ceresoli [this message]
2025-05-27 1:42 ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
2025-04-29 2:35 ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 32/34] drm/bridge: tc358767: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 33/34] drm/bridge: add devm_drm_put_bridge() Luca Ceresoli
2025-04-24 20:05 ` [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 11:39 ` Maxime Ripard
2025-04-28 15:25 ` Luca Ceresoli
2025-05-05 6:23 ` Maxime Ripard
2025-05-05 15:20 ` Luca Ceresoli
2025-04-28 15:24 ` [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-28 15:42 ` Maxime Ripard
2025-04-28 16:33 ` Luca Ceresoli
2025-04-29 9:27 ` (subset) " Louis Chauvet
2025-04-29 12:41 ` Louis Chauvet
2025-04-30 8:08 ` Maxime Ripard
2025-05-05 11:06 ` Luca Ceresoli
2025-05-05 11:58 ` Dmitry Baryshkov
2025-05-05 12:31 ` Luca Ceresoli
2025-04-29 14:42 ` Dmitry Baryshkov
2025-04-30 8:21 ` Louis Chauvet
2025-04-30 10:39 ` Maxime Ripard
2025-04-30 15:30 ` Louis Chauvet
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=20250526092024.48cae4ae@booty \
--to=luca.ceresoli@bootlin.com \
--cc=Hui.Pu@gehealthcare.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=andrzej.hajda@intel.com \
--cc=asahi@lists.linux.dev \
--cc=asrivats@redhat.com \
--cc=chrome-platform@lists.linux.dev \
--cc=chunkuang.hu@kernel.org \
--cc=dianders@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=festevam@gmail.com \
--cc=freedreno@lists.freedesktop.org \
--cc=imx@lists.linux.dev \
--cc=jagan@amarulasolutions.com \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=kernel@pengutronix.de \
--cc=krzk@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=lumag@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=paulk@sys-base.io \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rfoss@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
--cc=victor.liu@nxp.com \
/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;
as well as URLs for NNTP newsgroup(s).