linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: "Simona Vetter" <simona@ffwll.ch>,
	"Inki Dae" <inki.dae@samsung.com>,
	"Jagan Teki" <jagan@amarulasolutions.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Will Deacon" <will@kernel.org>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Daniel Thompson" <danielt@kernel.org>,
	"Andrzej Hajda" <andrzej.hajda@intel.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Paul Kocialkowski" <contact@paulk.fr>,
	"Maxime Ripard" <mripard@kernel.org>,
	"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>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Hervé Codina" <herve.codina@bootlin.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-doc@vger.kernel.org,
	"Paul Kocialkowski" <paul.kocialkowski@bootlin.com>
Subject: Re: [PATCH v5 08/10] drm/bridge: samsung-dsim: use supporting variable for out_bridge
Date: Tue, 21 Jan 2025 12:27:18 +0100	[thread overview]
Message-ID: <20250121122718.48502262@booty> (raw)
In-Reply-To: <emuj2innmp6zmzd7pyakqzjqpdzhly6qfhakya3ydwmd63pl26@5jwxaidpikjw>

Hi Dmitry,

On Thu, 16 Jan 2025 12:56:25 +0200
Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote:

[...]

> > Idea 3: 
> > 
> > The idea is that if the panel driver framework always creates a panel
> > bridge, it will never need to be created on the fly automagically by
> > its consumers, so the whole problem would disappear. It also would be
> > better modeling the hardware: still wrapping a panel with a drm_bridge
> > that does not exist in the hardware, but at least having it created by
> > the provider driver and not by the consumer driver which happens to
> > look for it.  
> 
> I think this is the best option up to now.

Thanks for sharing your opinion. However a few points are not clear to
me, see below.

> > This looks like a promising and simple idea, so I tried a quick
> > implementation:
> > 
> >  void drm_panel_init(struct drm_panel *panel, struct device *dev,
> >                     const struct drm_panel_funcs *funcs, int connector_type)
> >  {
> > +       struct drm_bridge *bridge;
> > +
> >         INIT_LIST_HEAD(&panel->list);
> >         INIT_LIST_HEAD(&panel->followers);
> >         mutex_init(&panel->follower_lock);
> >         panel->dev = dev;
> >         panel->funcs = funcs;
> >         panel->connector_type = connector_type;
> > +
> > +       bridge = devm_drm_panel_bridge_add(panel->dev, panel);
> > +       WARN_ON(!bridge);
> >  }
> > 
> > This is somewhat working but it requires more work because:
> > 
> >  * as it is, it creates a circular dependency between drm_panel and the
> >    panel bridge, and modular builds will fail:
> > 
> >      depmod: ERROR: Cycle detected: drm -> drm_kms_helper -> drm
> > 
> >  * The panel bridge implementation should be made private to the panel
> >    driver only (possibly helping to solve the previous issue?)  
> 
> Or merge drm_panel.c into bridge/panel.c.

Not sure here you mean exactly what you wrote, or the other way around.
It looks more correct to me that the panel core (drm_panel.c) starts
exposing a bridge now, and not that the panel bridge which is just one
of many bridge drivers starts handling all the panel-related stuff.

> The panel bridge already
> exports non-standard API, so it should be fine to extend / change that
> API. Likewise we might move drm_panel.c to drm_kms_helper.o, also
> resolving the loop.

Again I'm not following I'm afraid. It would seem more logical to me to
move things from the helper into drm.o as they become more necessary
for common cases, rather than moving things out to a helper module and
then force all panel drivers to depend on the helper module.

Apologies, I'm perhaps not following your reasoning here. :(

> There will be a need for a Kconfig update in both
> cases.
> 
> >  * Many drivers currently call devm_drm_panel_bridge_add() directly,
> >    they should probably call drm_of_get_bridge instead  
> 
> I'd say, make it a stub that calls drm_of_get_bridge() with a possible
> deprecation warning.

I get the idea, but it would need to be implemented differently because
drm_of_get_bridge() calls devm_drm_panel_bridge_add(). They would loop
into each other. I think we might simply add a check at the beginning
of drm_panel_bridge_add_typed(), as in (pseudocode):

drm_panel_bridge_add_typed(struct drm_panel *panel, ...)
{
    if (panel_has_a_panel_bridge(panel))
        return panel->panel_bridge.bridge;

    // existing code
}

But that reopens the same issue: drm_panel_bridge_add_typed() would not
always call drm_bridge_add(), so the caller doesn't know how to dispose
of the returned pointer.

I think idea 3 can only work if the code understands that the panel
bridge is created by the panel and they _never_ have to create it
themselves. So handling the transition for all drivers would be quite
painful.

> >  * drm_of_find_panel_or_bridge() should disappear: other drivers would
> >    just look for a bridge  
> 
> Please keep it for now.
> 
> Some of the drivers think that it returns literally panel-or-bridge (but
> not both). However if panel bridge is already created, it will return
> both. So those drivers need to be updated.

I really believe it never returns both. The *bridge is set only when
ret != 0 here [0], which can happen only if a panel was not found.
Despite the slightly intricate logic of that function, I don't see how
it could return both in its current implementation.

[0]
https://elixir.bootlin.com/linux/v6.13-rc3/source/drivers/gpu/drm/drm_of.c#L273

Luca

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

  reply	other threads:[~2025-01-21 11:27 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-31 10:39 [PATCH v5 00/10] Add support for hot-pluggable DRM bridges Luca Ceresoli
2024-12-31 10:39 ` [PATCH v5 01/10] drm/bridge: allow bridges to be informed about added and removed bridges Luca Ceresoli
2024-12-31 10:39 ` [PATCH v5 02/10] drm/encoder: add drm_encoder_cleanup_from() Luca Ceresoli
2024-12-31 10:39 ` [PATCH v5 03/10] drm/bridge: add support for refcounted DRM bridges Luca Ceresoli
2024-12-31 11:11   ` Jani Nikula
2025-01-02 12:03     ` Luca Ceresoli
2025-01-03  9:36       ` Jani Nikula
2024-12-31 10:39 ` [PATCH v5 04/10] drm/bridge: add documentation of refcounted bridges Luca Ceresoli
2024-12-31 17:54   ` Randy Dunlap
2025-01-02 12:02     ` Luca Ceresoli
2025-01-06 10:39   ` Maxime Ripard
2025-01-06 12:24     ` Dmitry Baryshkov
2025-01-06 14:49       ` Maxime Ripard
2025-01-07 10:35         ` Dmitry Baryshkov
2025-01-07 15:12           ` Maxime Ripard
2025-01-08 15:24           ` Luca Ceresoli
2025-01-08 15:24       ` Luca Ceresoli
2025-01-08 16:02         ` Maxime Ripard
2025-01-22 16:12           ` Luca Ceresoli
2025-01-28 14:49             ` Maxime Ripard
2025-01-29 11:51               ` Luca Ceresoli
2025-01-29 12:22                 ` Dmitry Baryshkov
2025-01-29 13:11                   ` Luca Ceresoli
2024-12-31 10:39 ` [PATCH v5 05/10] drm/tests: bridge: add KUnit tests for DRM bridges (init and destroy) Luca Ceresoli
2024-12-31 10:40 ` [PATCH v5 06/10] drm/bridge: ti-sn65dsi83: use dynamic lifetime management Luca Ceresoli
2024-12-31 10:40 ` [PATCH v5 07/10] drm/bridge: panel: " Luca Ceresoli
2024-12-31 10:40 ` [PATCH v5 08/10] drm/bridge: samsung-dsim: use supporting variable for out_bridge Luca Ceresoli
2024-12-31 14:57   ` Dmitry Baryshkov
2025-01-02 12:01     ` Luca Ceresoli
2025-01-03  6:00       ` Dmitry Baryshkov
2025-01-10 10:58       ` Luca Ceresoli
2025-01-16 10:32         ` Luca Ceresoli
2025-01-16 10:56           ` Dmitry Baryshkov
2025-01-21 11:27             ` Luca Ceresoli [this message]
2025-01-21 11:57               ` Dmitry Baryshkov
2025-01-28 15:52                 ` Maxime Ripard
2025-01-16 12:26           ` Maxime Ripard
2025-01-21 11:27             ` Luca Ceresoli
2025-01-28 15:09               ` Maxime Ripard
2025-01-29 11:51                 ` Luca Ceresoli
2025-02-04 15:44                   ` Maxime Ripard
2024-12-31 10:40 ` [PATCH v5 09/10] drm/bridge: samsung-dsim: refcount the out_bridge Luca Ceresoli
2024-12-31 14:58   ` Dmitry Baryshkov
2024-12-31 10:40 ` [PATCH v5 10/10] drm/bridge: hotplug-bridge: add driver to support hot-pluggable DSI bridges Luca Ceresoli
2024-12-31 15:29   ` Dmitry Baryshkov
2025-01-02 12:01     ` Luca Ceresoli
2025-09-09 15:29       ` Luca Ceresoli
2025-09-09 15:39         ` Luca Ceresoli

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=20250121122718.48502262@booty \
    --to=luca.ceresoli@bootlin.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=catalin.marinas@arm.com \
    --cc=contact@paulk.fr \
    --cc=corbet@lwn.net \
    --cc=danielt@kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=herve.codina@bootlin.com \
    --cc=inki.dae@samsung.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kernel@pengutronix.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@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.kocialkowski@bootlin.com \
    --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=will@kernel.org \
    /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).