[PATCH 3/6] drm/mcde: dsi: warn in case of multiple subnodes

Luca Ceresoli posted 6 patches 3 weeks, 3 days ago
There is a newer version of this series
[PATCH 3/6] drm/mcde: dsi: warn in case of multiple subnodes
Posted by Luca Ceresoli 3 weeks, 3 days ago
mcde_dsi_bind() has a loop over all subnodes looking for a panel, but does
not exit when a match is found and only stores the last match. However this
will be problematic when introducing refcounting on the struct drm_device
pointer in a following commit, because of_drm_find_and_get_bridge() would
get a reference to multiple bridges.

Assuming there is no real reason for looking for multiple panels, add a
warning so it gets noticed in case the assumption is wrong.

Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

---

I think the correct thing to do would be adding a break statement when
there is a match. However I don't have knowledge of this driver and the
hardware, thus this patch is a prudential alternative, not changing the
behaviour.
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index a3423459dd7a..3faebe571fc2 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -1103,6 +1103,9 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 
 	/* Look for a panel as a child to this node */
 	for_each_available_child_of_node(dev->of_node, child) {
+		/* There should be only one panel subnode */
+		WARN_ON(panel || bridge);
+
 		panel = of_drm_find_panel(child);
 		if (IS_ERR(panel)) {
 			dev_err(dev, "failed to find panel try bridge (%ld)\n",

-- 
2.52.0
Re: [PATCH 3/6] drm/mcde: dsi: warn in case of multiple subnodes
Posted by Linus Walleij 3 weeks ago
On Fri, Jan 16, 2026 at 6:33 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:

> mcde_dsi_bind() has a loop over all subnodes looking for a panel, but does
> not exit when a match is found and only stores the last match. However this
> will be problematic when introducing refcounting on the struct drm_device
> pointer in a following commit, because of_drm_find_and_get_bridge() would
> get a reference to multiple bridges.
>
> Assuming there is no real reason for looking for multiple panels, add a
> warning so it gets noticed in case the assumption is wrong.
>
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>
> ---
>
> I think the correct thing to do would be adding a break statement when
> there is a match. However I don't have knowledge of this driver and the
> hardware, thus this patch is a prudential alternative, not changing the
> behaviour.

Go ahead and insert a break when the panel is found, there is
no MCDE-attached device with more than one panel.

There *exist* the Samsung Gavini device which has a
LED panel, *and* the same lines attached to a mini-projector
so these two can be used at the same time. I have no idea
how to actually deal with that if someone one day want to
support it. Probably by putting the projector as a side thing
and not deal with the video stream in the device tree.

Yours,
Linus Walleij
Re: [PATCH 3/6] drm/mcde: dsi: warn in case of multiple subnodes
Posted by Luca Ceresoli 1 week, 2 days ago
Hello Linus,

On Mon Jan 19, 2026 at 9:54 AM CET, Linus Walleij wrote:
> On Fri, Jan 16, 2026 at 6:33 PM Luca Ceresoli <luca.ceresoli@bootlin.com> wrote:
>
>> mcde_dsi_bind() has a loop over all subnodes looking for a panel, but does
>> not exit when a match is found and only stores the last match. However this
>> will be problematic when introducing refcounting on the struct drm_device
>> pointer in a following commit, because of_drm_find_and_get_bridge() would
>> get a reference to multiple bridges.
>>
>> Assuming there is no real reason for looking for multiple panels, add a
>> warning so it gets noticed in case the assumption is wrong.
>>
>> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
>>
>> ---
>>
>> I think the correct thing to do would be adding a break statement when
>> there is a match. However I don't have knowledge of this driver and the
>> hardware, thus this patch is a prudential alternative, not changing the
>> behaviour.
>
> Go ahead and insert a break when the panel is found, there is
> no MCDE-attached device with more than one panel.
>
> There *exist* the Samsung Gavini device which has a
> LED panel, *and* the same lines attached to a mini-projector
> so these two can be used at the same time. I have no idea
> how to actually deal with that if someone one day want to
> support it. Probably by putting the projector as a side thing
> and not deal with the video stream in the device tree.

Thanks for sharing these info! I'm very happy to know I can break instead
of warning here. Change queued for v2.

Luca

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