All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes
@ 2025-05-16 11:41 Moteen Shah
  2025-05-16 11:41 ` [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes Moteen Shah
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Moteen Shah @ 2025-05-16 11:41 UTC (permalink / raw)
  To: u-boot
  Cc: trini, sjg, alpernebiyasak, quentin.schulz, m-chawdhry, n-francis,
	vigneshr, u-kumar1, m-shah

In the U-Boot pre-relocation stage, if the parent node lacks
bootph-all/bootph-some-ram property and the driver lacks a pre-reloc
flag, all of its subsequent subnodes gets skipped over from driver
binding—even if they have a bootph* property.

This series addresses the issue by scanning through all the nodes during
build time and propagating the applicable  property to all of its supernode.

Changes since v1: 
- Carry reviewed-by from Simon
- Add a subnode-4 in testcase
- Change commit message and comments in control.py

Link to v1:
https://lore.kernel.org/u-boot/20250512115028.1783305-1-m-shah@ti.com/

Moteen Shah (2):
  tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes
  tools: binman: ftest.py: Add testcase for bootph-* propagation

 tools/binman/control.py               | 54 +++++++++++++++++++++++++++
 tools/binman/ftest.py                 | 24 ++++++++++++
 tools/binman/test/347_bootph_prop.dts | 21 +++++++++++
 3 files changed, 99 insertions(+)
 create mode 100644 tools/binman/test/347_bootph_prop.dts

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes
  2025-05-16 11:41 [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
@ 2025-05-16 11:41 ` Moteen Shah
  2025-05-16 13:34   ` Quentin Schulz
  2025-05-16 11:41 ` [PATCH 2/2 v2] tools: binman: ftest.py: Add testcase for bootph-* propagation Moteen Shah
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Moteen Shah @ 2025-05-16 11:41 UTC (permalink / raw)
  To: u-boot
  Cc: trini, sjg, alpernebiyasak, quentin.schulz, m-chawdhry, n-francis,
	vigneshr, u-kumar1, m-shah

As per bootph schema, bootph-* property in child node should be
implied in their parent, but this feature is not implemented in
the U-Boot proper stage (before relocation) resulting in devices
not being bound because of the missing bootph-all or bootph-some-ram
property in the parent node.

To mitigate this issue, add a function to scan through all the nodes
in the device-tree for bootph-all and bootph-some-ram properties. If
found, propagate it to all of its parent nodes up the hierarchy.

Signed-off-by: Moteen Shah <m-shah@ti.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Simon Glass <sjg@chromium.org>

---
 tools/binman/control.py | 54 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tools/binman/control.py b/tools/binman/control.py
index 81f61e3e152..dcbc028adcc 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -530,6 +530,57 @@ def _RemoveTemplates(parent):
     for node in del_nodes:
         node.Delete()
 
+def propagate_prop(node, prop):
+    """Propagate the provided property to all the parent nodes up the hierarchy
+
+    Args:
+        node (fdt.Node): Node and all its parent nodes up to the root to
+            propagate the property.
+        prop (str): Boolean property to propagate
+
+    Return:
+        True if any change was made, else False
+    """
+    changed = False
+    while node:
+        if prop not in node.props:
+            node.AddEmptyProp(prop, 0)
+            changed = True
+        node = node.parent
+    return changed
+
+def scan_and_prop_bootph(node):
+    """Propagate bootph properties from children to parents
+
+    The bootph schema indicates that bootph properties in children should be
+    implied in their parents, all the way up the hierarchy. This is expensive
+    to implement in U-Boot before relocation at runtime, so this function
+    explicitly propagates these bootph properties upwards during build time.
+
+    This is used to set the bootph-all, bootph-some-ram property in the parent
+    node if the respective property is found in any of the parent's subnodes.
+    The other bootph-* properties are associated with the SPL stage and hence
+    handled by fdtgrep.c.
+
+    Args:
+        node (fdt.Node): Node to scan for bootph-all and bootph-some-ram
+            property
+
+    Return:
+        True if any change was made, else False
+
+    """
+    bootph_prop = {'bootph-all', 'bootph-some-ram'}
+
+    changed = False
+    for prop in bootph_prop:
+        if prop in node.props:
+            changed |= propagate_prop(node.parent, prop)
+
+    for subnode in node.subnodes:
+        changed |= scan_and_prop_bootph(subnode)
+    return changed
+
 def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, indir):
     """Prepare the images to be processed and select the device tree
 
@@ -589,6 +640,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         fname = tools.get_output_filename('u-boot.dtb.tmpl2')
         tools.write_file(fname, dtb.GetContents())
 
+    if scan_and_prop_bootph(dtb.GetRoot()):
+        dtb.Sync(True)
+
     images = _ReadImageDesc(node, use_expanded)
 
     if select_images:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2 v2] tools: binman: ftest.py: Add testcase for bootph-* propagation
  2025-05-16 11:41 [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
  2025-05-16 11:41 ` [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes Moteen Shah
@ 2025-05-16 11:41 ` Moteen Shah
  2025-06-09  6:22 ` [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
  2025-06-26 17:56 ` Tom Rini
  3 siblings, 0 replies; 7+ messages in thread
From: Moteen Shah @ 2025-05-16 11:41 UTC (permalink / raw)
  To: u-boot
  Cc: trini, sjg, alpernebiyasak, quentin.schulz, m-chawdhry, n-francis,
	vigneshr, u-kumar1, m-shah

Add a testcase to ensure that scan_and_prop_bootph() actually
propagates bootph-* properties to supernodes.

Signed-off-by: Moteen Shah <m-shah@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

---
 tools/binman/ftest.py                 | 24 ++++++++++++++++++++++++
 tools/binman/test/347_bootph_prop.dts | 21 +++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 tools/binman/test/347_bootph_prop.dts

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index fa174900014..8c37c0c95f6 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -8011,5 +8011,29 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         self._DoTestFile('346_remove_template.dts',
                          force_missing_bintools='openssl',)
 
+    def testBootphPropagation(self):
+        """Test that bootph-* properties are propagated correctly to supernodes"""
+        _, _, _, out_dtb_fname = self._DoReadFileDtb(
+                '347_bootph_prop.dts', use_real_dtb=True, update_dtb=True)
+        dtb = fdt.Fdt(out_dtb_fname)
+        dtb.Scan()
+        root = dtb.GetRoot()
+        parent_node = root.FindNode('dummy-parent')
+        subnode1 = parent_node.FindNode('subnode-1')
+        subnode2 = subnode1.FindNode('subnode-2')
+        subnode3 = subnode1.FindNode('subnode-3')
+        subnode4 = subnode3.FindNode('subnode-4')
+ 
+        self.assertIn('bootph-some-ram', subnode1.props,
+                      "Child node is missing 'bootph-some-ram' property")
+        self.assertIn('bootph-all', subnode1.props,
+                      "Child node is missing 'bootph-all' property")
+        self.assertIn('bootph-some-ram', parent_node.props,
+                      "Parent node is missing 'bootph-some-ram' property")
+        self.assertIn('bootph-all', parent_node.props,
+                      "Parent node is missing 'bootph-all' property")
+        self.assertEqual(len(subnode4.props), 0,
+                        "subnode shouldn't have any properties")
+        
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/347_bootph_prop.dts b/tools/binman/test/347_bootph_prop.dts
new file mode 100644
index 00000000000..91d4e4ad600
--- /dev/null
+++ b/tools/binman/test/347_bootph_prop.dts
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+/ {
+	dummy-parent {
+		subnode-1 {
+			subnode-2 {
+				bootph-all;
+			};
+			subnode-3 {
+				bootph-some-ram;
+				subnode-4 {
+				};
+			};
+		};
+	};
+
+	binman: binman {
+	};
+};
+
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes
  2025-05-16 11:41 ` [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes Moteen Shah
@ 2025-05-16 13:34   ` Quentin Schulz
  0 siblings, 0 replies; 7+ messages in thread
From: Quentin Schulz @ 2025-05-16 13:34 UTC (permalink / raw)
  To: Moteen Shah, u-boot
  Cc: trini, sjg, alpernebiyasak, m-chawdhry, n-francis, vigneshr,
	u-kumar1

Hi Moteen,

On 5/16/25 1:41 PM, Moteen Shah wrote:
> As per bootph schema, bootph-* property in child node should be
> implied in their parent, but this feature is not implemented in
> the U-Boot proper stage (before relocation) resulting in devices
> not being bound because of the missing bootph-all or bootph-some-ram
> property in the parent node.
> 
> To mitigate this issue, add a function to scan through all the nodes
> in the device-tree for bootph-all and bootph-some-ram properties. If
> found, propagate it to all of its parent nodes up the hierarchy.
> 
> Signed-off-by: Moteen Shah <m-shah@ti.com>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 

Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>

Thanks!
Quentin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes
  2025-05-16 11:41 [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
  2025-05-16 11:41 ` [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes Moteen Shah
  2025-05-16 11:41 ` [PATCH 2/2 v2] tools: binman: ftest.py: Add testcase for bootph-* propagation Moteen Shah
@ 2025-06-09  6:22 ` Moteen Shah
  2025-06-26  8:51   ` Moteen Shah
  2025-06-26 17:56 ` Tom Rini
  3 siblings, 1 reply; 7+ messages in thread
From: Moteen Shah @ 2025-06-09  6:22 UTC (permalink / raw)
  To: u-boot
  Cc: trini, sjg, alpernebiyasak, quentin.schulz, m-chawdhry, n-francis,
	vigneshr, u-kumar1

Hello all,

On 16/05/25 17:11, Moteen Shah wrote:
> In the U-Boot pre-relocation stage, if the parent node lacks
> bootph-all/bootph-some-ram property and the driver lacks a pre-reloc
> flag, all of its subsequent subnodes gets skipped over from driver
> binding—even if they have a bootph* property.
>
> This series addresses the issue by scanning through all the nodes during
> build time and propagating the applicable  property to all of its supernode.
>
> Changes since v1:
> - Carry reviewed-by from Simon
> - Add a subnode-4 in testcase
> - Change commit message and comments in control.py
>
> Link to v1:
> https://lore.kernel.org/u-boot/20250512115028.1783305-1-m-shah@ti.com/
>
> Moteen Shah (2):
>    tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes
>    tools: binman: ftest.py: Add testcase for bootph-* propagation
>
>   tools/binman/control.py               | 54 +++++++++++++++++++++++++++
>   tools/binman/ftest.py                 | 24 ++++++++++++
>   tools/binman/test/347_bootph_prop.dts | 21 +++++++++++
>   3 files changed, 99 insertions(+)
>   create mode 100644 tools/binman/test/347_bootph_prop.dts
>

A gentle ping on this. Does this series requires any further changes?

Regards,
Moteen


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes
  2025-06-09  6:22 ` [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
@ 2025-06-26  8:51   ` Moteen Shah
  0 siblings, 0 replies; 7+ messages in thread
From: Moteen Shah @ 2025-06-26  8:51 UTC (permalink / raw)
  To: u-boot, Tom Rini
  Cc: sjg, alpernebiyasak, quentin.schulz, m-chawdhry, n-francis,
	vigneshr, u-kumar1

Hey Tom,
Just wanted to have a check on the patch series.
Is there any change expected on this or is it good to go?

Regards,
Moteen

On 09/06/25 11:52, Moteen Shah wrote:
> Hello all,
>
> On 16/05/25 17:11, Moteen Shah wrote:
>> In the U-Boot pre-relocation stage, if the parent node lacks
>> bootph-all/bootph-some-ram property and the driver lacks a pre-reloc
>> flag, all of its subsequent subnodes gets skipped over from driver
>> binding—even if they have a bootph* property.
>>
>> This series addresses the issue by scanning through all the nodes during
>> build time and propagating the applicable  property to all of its 
>> supernode.
>>
>> Changes since v1:
>> - Carry reviewed-by from Simon
>> - Add a subnode-4 in testcase
>> - Change commit message and comments in control.py
>>
>> Link to v1:
>> https://lore.kernel.org/u-boot/20250512115028.1783305-1-m-shah@ti.com/
>>
>> Moteen Shah (2):
>>    tools: binman: control.py: Propagate bootph-all/bootph-some-ram 
>> properties to supernodes
>>    tools: binman: ftest.py: Add testcase for bootph-* propagation
>>
>>   tools/binman/control.py               | 54 +++++++++++++++++++++++++++
>>   tools/binman/ftest.py                 | 24 ++++++++++++
>>   tools/binman/test/347_bootph_prop.dts | 21 +++++++++++
>>   3 files changed, 99 insertions(+)
>>   create mode 100644 tools/binman/test/347_bootph_prop.dts
>>
>
> A gentle ping on this. Does this series requires any further changes?
>
> Regards,
> Moteen
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes
  2025-05-16 11:41 [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
                   ` (2 preceding siblings ...)
  2025-06-09  6:22 ` [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
@ 2025-06-26 17:56 ` Tom Rini
  3 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2025-06-26 17:56 UTC (permalink / raw)
  To: u-boot, Moteen Shah
  Cc: sjg, alpernebiyasak, quentin.schulz, m-chawdhry, n-francis,
	vigneshr, u-kumar1

On Fri, 16 May 2025 17:11:46 +0530, Moteen Shah wrote:

> In the U-Boot pre-relocation stage, if the parent node lacks
> bootph-all/bootph-some-ram property and the driver lacks a pre-reloc
> flag, all of its subsequent subnodes gets skipped over from driver
> binding—even if they have a bootph* property.
> 
> This series addresses the issue by scanning through all the nodes during
> build time and propagating the applicable  property to all of its supernode.
> 
> [...]

Applied to u-boot/next, thanks!

[1/2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes
      commit: d85d15fdfebd040e58bdf80e40ef09d67a8ac808
[2/2] tools: binman: ftest.py: Add testcase for bootph-* propagation
      commit: 1b5e41964c34ee062fe9932ef5f9ccc747c50ea1
-- 
Tom



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-06-26 17:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-16 11:41 [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
2025-05-16 11:41 ` [PATCH 1/2 v2] tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties to supernodes Moteen Shah
2025-05-16 13:34   ` Quentin Schulz
2025-05-16 11:41 ` [PATCH 2/2 v2] tools: binman: ftest.py: Add testcase for bootph-* propagation Moteen Shah
2025-06-09  6:22 ` [PATCH 0/2 v2] Propagate bootph-all and bootph-some-ram property to all supernodes Moteen Shah
2025-06-26  8:51   ` Moteen Shah
2025-06-26 17:56 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.