[PATCH 0/6] Restore phandles from binary representations
Uwe Kleine-König <[email protected]>
| Newsgroups | org.kernel.vger.devicetree-compiler |
|---|---|
| Message-ID | <[email protected]> |
Hello,
this is a followup to https://github.com/dgibson/dtc/pull/151, but I
switched to submission by mail because the workflow is (at least
subjectively for me) better suited for such a big and long living patch
set. Parts of the patches discussed on github were already applied.
Sample output to show the benefit:
$ cat a.dts
/dts-v1/;
/ {
node1 {
node2 = <&node2>;
};
node2: node2 {
property = "somevalue";
};
};
$ cat b.dts
/dts-v1/;
/ {
node0: node0 {
self = <&node0>;
};
node1 {
node2 = <&node2>;
};
node2: node2 {
property = "somevalue";
};
};
So b.dts just added a node0 over a.dts, node1 and node2 didn't change at
all.
$ dtc -L -@ a.dts > a.dtb
$ dtc -L -@ b.dts > b.dtb
Now using dtc without this patch set I get:
$ dtdiff a.dtb b.dtb
--- /dev/fd/63 2025-08-20 14:55:37.253413183 +0200
+++ /dev/fd/62 2025-08-20 14:55:37.253413183 +0200
@@ -4,21 +4,31 @@
__local_fixups__ {
+ node0 {
+ self = <0x00>;
+ };
+
node1 {
node2 = <0x00>;
};
};
__symbols__ {
+ node0 = "/node0";
node2 = "/node2";
};
+ node0 {
+ phandle = <0x01>;
+ self = <0x01>;
+ };
+
node1 {
- node2 = <0x01>;
+ node2 = <0x02>;
};
node2 {
- phandle = <0x01>;
+ phandle = <0x02>;
property = "somevalue";
};
};
With this series applied the output becomes:
$ dtdiff a.dtb b.dtb
--- /dev/fd/63 2025-08-20 14:56:02.585884273 +0200
+++ /dev/fd/62 2025-08-20 14:56:02.589884347 +0200
@@ -5,21 +5,31 @@
__local_fixups__ {
+ node0 {
+ self = <0x00>;
+ };
+
node1 {
node2 = <0x00>;
};
};
__symbols__ {
+ node0 = "/node0";
node2 = "/node2";
};
+ node0: node0 {
+ phandle = <0x01>;
+ self = <&node0>;
+ };
+
node1 {
node2 = <&node2>;
};
node2: node2 {
- phandle = <0x01>;
+ phandle = <0x02>;
property = "somevalue";
};
};
The relevant difference here is that the renumbering of phandles that
affects /node2 doesn't result in noise in /node1, so it's easily visible
that /node1/node2 still points to the same node that just got a new
phandle value.
In this minimal example the signal to noise ratio is bad, with bigger
device trees the improvement is much more relevant. (Think 50 nodes that
are not affected by renumbering and the noise being concentrated to
__local_fixups__, __fixups__ and the changes of the actual phandle
properties but not their usage.)
Best regards
Uwe
Uwe Kleine-König (6):
Emit /plugin/ when compiling to .dts with DTSF_PLUGIN set
Set DTSF_PLUGIN if needed when compiling from dtb
Improve type guessing when compiling to dts format
Restore labels from __symbols__ node
Restore phandle references from __local_fixups__ node
Restore phandle references from __fixups__ node
dtc.c | 5 ++
dtc.h | 6 ++
flattree.c | 6 +-
livetree.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++
treesource.c | 114 ++++++++++++++++++++++++---------
5 files changed, 273 insertions(+), 32 deletions(-)
base-commit: e1284ee5dc20f94097bc6424ede9c3e433dba77d
--
2.50.1