Skip to contentSkip to conversation

drm/rcar-du: Convert to of_drm_find_and_get_bridge()

PATCH In review Amin GATTOUT 3 participants 6 messages Mar 26 – Mar 27

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/rcar-du: Convert to of_drm_find_and_get_bridge()

of_drm_find_bridge() is deprecated.
Replace it with of_drm_find_and_get_bridge() which increments the bridge refcount as required.

---
 drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +1 -1
index 7ecec7b04a8d..42253c1251b5 100644
@@ -72,7 +72,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 		if (IS_ERR(bridge))
 			return PTR_ERR(bridge);
 	} else {
-		bridge = of_drm_find_bridge(enc_node);
+		bridge = of_drm_find_and_get_bridge(enc_node);
 		if (!bridge)
 			return -EPROBE_DEFER;
 

---
base-commit: d813f421930c5b01b9f61043932de02602dd6ae3
change-id: 20260326-bridge-43ecbef9d39f

Best regards,

Signature · 1 line
Amin GATTOUT <[email protected]>
#1 lore raw

Hello Amin,

Quoted 14 lines · Amin GATTOUT

of_drm_find_bridge() is deprecated.
Replace it with of_drm_find_and_get_bridge() which increments the bridge refcount as required.

---
 drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +0 -0
index 7ecec7b04a8d..42253c1251b5 100644

drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c int rcar_du_encoder_init(struct rcar_du_device *rcdu, · line 75

Quoted 5 lines
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +1 -1
@@ -72,7 +72,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 		if (IS_ERR(bridge))
 			return PTR_ERR(bridge);
 	} else {
-		bridge = of_drm_find_bridge(enc_node);
+		bridge = of_drm_find_and_get_bridge(enc_node);

How did you test this ?

Quoted 7 lines
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +0 -1
 		if (!bridge)
 			return -EPROBE_DEFER;
 
 
---

base-commit: d813f421930c5b01b9f61043932de02602dd6ae3
change-id: 20260326-bridge-43ecbef9d39f

Signature · 3 lines
Regards,

Laurent Pinchart
#2 lore raw
In reply to Amin GATTOUT

Hello Amin,

Quoted 3 lines · Amin GATTOUT

of_drm_find_bridge() is deprecated.
Replace it with of_drm_find_and_get_bridge() which increments the bridge refcount as required.

Thanks for taking care of the conversion to the new API!

drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c int rcar_du_encoder_init(struct rcar_du_device *rcdu, · line 75

Quoted 8 lines
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +1 -1
@@ -72,7 +72,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 		if (IS_ERR(bridge))
 			return PTR_ERR(bridge);
 	} else {
-		bridge = of_drm_find_bridge(enc_node);
+		bridge = of_drm_find_and_get_bridge(enc_node);

This change alone is not correct I'm afraid. The difference between of_drm_find_bridge() and of_drm_find_and_get_bridge() is the latter get a reference to the bridge, so you have to put that reference when the bridge pointer is no more accessible.

Have a look at previous commits doing the same API replacement, you can find examples similar to this one, where:

* the bridge pointer is stored in a local variable (not saved in a struct)
* the bridge pointer could be set wither by of_drm_find_bridge() or a function adding a panel bridge

Luca

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

#3 lore raw

Hi Luca,

Quoted 6 lines · Luca Ceresoli
Quoted 3 lines · Amin GATTOUT

of_drm_find_bridge() is deprecated.
Replace it with of_drm_find_and_get_bridge() which increments the bridge refcount as required.

Thanks for taking care of the conversion to the new API!

I suspect you may be talking to a machine (possibly through a human proxy).

Quoted 22 lines

drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c int rcar_du_encoder_init(struct rcar_du_device *rcdu, · line 75

Quoted 8 lines
drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +1 -1
@@ -72,7 +72,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu,
 		if (IS_ERR(bridge))
 			return PTR_ERR(bridge);
 	} else {
-		bridge = of_drm_find_bridge(enc_node);
+		bridge = of_drm_find_and_get_bridge(enc_node);

This change alone is not correct I'm afraid. The difference between of_drm_find_bridge() and of_drm_find_and_get_bridge() is the latter get a reference to the bridge, so you have to put that reference when the bridge pointer is no more accessible.

Have a look at previous commits doing the same API replacement, you can find examples similar to this one, where:

* the bridge pointer is stored in a local variable (not saved in a struct)
* the bridge pointer could be set wither by of_drm_find_bridge() or a function adding a panel bridge

Luca

Signature · 3 lines
Regards,

Laurent Pinchart
author
#4 lore raw

Hi

Thanks for the feedback. I did reference commit 7282066e55347 (Luca's earlier conversion) but I should have been more cautious since the patch I submitted was a bit too simple/"dummy".

To answer Laurent's question: I did not test this on hardware. I was working through the deprecated API TODO list and made the mistake of treating this as a simple find-and-replace.

I'll send a v2.
Thanks for the patience...

Regards,
Amin

#5 lore raw
Quoted 11 lines · Amin

Hi

Thanks for the feedback. I did reference commit 7282066e55347 (Luca's earlier conversion) but I should have been more cautious since the patch I submitted was a bit too simple/"dummy".

To answer Laurent's question: I did not test this on hardware. I was working through the deprecated API TODO list and made the mistake of treating this as a simple find-and-replace.

I'll send a v2.

Luca has already submitted a patch, see
https://lore.kernel.org/dri-devel/20260318-drm-bridge-alloc-getput-drm_of_find_bridge-4-v3-3-10f502520357@bootlin.com/

Signature · 3 lines
Regards,

Laurent Pinchart