Skip to contentSkip to conversation

hw/arm/raspi4b: NOP all DTB nodes when removing unimplemented devices

PATCH Applied Osama Abdelkader 3 participants 4 messages Apr 20 – Apr 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm/raspi4b: NOP all DTB nodes when removing unimplemented devices

fdt_node_offset_by_compatible(fdt, -1, compat) only finds the first match. If the blob has more than one node with the same compatible string, extra nodes will remain active. using the same loop as imx8mp-evk.c

---
 hw/arm/raspi4b.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
hw/arm/raspi4b.c +6 -4
index 3eeb8f447e..06aeb8db01 100644
@@ -72,12 +72,14 @@ static void raspi4_modify_dtb(const struct arm_boot_info *info, void *fdt)
 
     for (int i = 0; i < ARRAY_SIZE(nodes_to_remove); i++) {
         const char *dev_str = nodes_to_remove[i];
+        int offset;
 
-        int offset = fdt_node_offset_by_compatible(fdt, -1, dev_str);
-        if (offset >= 0) {
-            if (!fdt_nop_node(fdt, offset)) {
-                warn_report("bcm2711 dtc: %s has been disabled!", dev_str);
+        offset = fdt_node_offset_by_compatible(fdt, -1, dev_str);
+        while (offset >= 0) {
+            if (fdt_nop_node(fdt, offset) == 0) {
+                warn_report("bcm2711 dtb: %s has been disabled!", dev_str);
             }
+            offset = fdt_node_offset_by_compatible(fdt, offset, dev_str);
         }
     }
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 7 lines · Osama Abdelkader

fdt_node_offset_by_compatible(fdt, -1, compat) only finds the first match. If the blob has more than one node with the same compatible string, extra nodes will remain active. using the same loop as imx8mp-evk.c

---

I wondered about whether it would be worth abstracting this out into a helper function, but it looks like at the moment only this raspi code and the imx8mp-evk do this. If we get more places we want this we might do that, but not worth it for two.

Applied to target-arm.next, thanks.

-- PMM

#2 lore raw
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Osama Abdelkader

fdt_node_offset_by_compatible(fdt, -1, compat) only finds the first match. If the blob has more than one node with the same compatible string, extra nodes will remain active. using the same loop as imx8mp-evk.c

Quoted 8 lines
Quoted 2 lines

---

I wondered about whether it would be worth abstracting this out into a helper function, but it looks like at the moment only this raspi code and the imx8mp-evk do this. If we get more places we want this we might do that, but not worth it for two.

IIRC you were first against the approach of "use a real world dtb and patch it", recommending to "generate a dtb with what we emulate"; and we merged that as 'temporary kludge until we properly emulate the missing device'.

#3 lore raw
Quoted 17 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Peter Maydell
Quoted 5 lines · Osama Abdelkader

fdt_node_offset_by_compatible(fdt, -1, compat) only finds the first match. If the blob has more than one node with the same compatible string, extra nodes will remain active. using the same loop as imx8mp-evk.c

Quoted 8 lines
Quoted 2 lines

---

I wondered about whether it would be worth abstracting this out into a helper function, but it looks like at the moment only this raspi code and the imx8mp-evk do this. If we get more places we want this we might do that, but not worth it for two.

Quoted 4 lines

IIRC you were first against the approach of "use a real world dtb and patch it", recommending to "generate a dtb with what we emulate"; and we merged that as 'temporary kludge until we properly emulate the missing device'.

Thanks Peter and Philippe for the clarification, I would be happy to participate in that solution too.

Best regards,
Osama