devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Restore phandles from binary representations
@ 2025-08-20 13:11 Uwe Kleine-König
  2025-08-20 13:11 ` [PATCH 1/6] Emit /plugin/ when compiling to .dts with DTSF_PLUGIN set Uwe Kleine-König
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Uwe Kleine-König @ 2025-08-20 13:11 UTC (permalink / raw)
  To: devicetree-compiler

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


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

end of thread, other threads:[~2025-08-21  4:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 13:11 [PATCH 0/6] Restore phandles from binary representations Uwe Kleine-König
2025-08-20 13:11 ` [PATCH 1/6] Emit /plugin/ when compiling to .dts with DTSF_PLUGIN set Uwe Kleine-König
2025-08-21  4:24   ` David Gibson
2025-08-20 13:11 ` [PATCH 2/6] Set DTSF_PLUGIN if needed when compiling from dtb Uwe Kleine-König
2025-08-21  4:24   ` David Gibson
2025-08-20 13:11 ` [PATCH 3/6] Improve type guessing when compiling to dts format Uwe Kleine-König
2025-08-21  4:24   ` David Gibson
2025-08-20 13:11 ` [PATCH 4/6] Restore labels from __symbols__ node Uwe Kleine-König
2025-08-21  4:25   ` David Gibson
2025-08-20 13:11 ` [PATCH 5/6] Restore phandle references from __local_fixups__ node Uwe Kleine-König
2025-08-21  4:23   ` David Gibson
2025-08-20 13:11 ` [PATCH 6/6] Restore phandle references from __fixups__ node Uwe Kleine-König
2025-08-21  4:31   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).