kbuild: Ignore phandle property when diffing base and U-Boot augmented DTs
PATCH 1/1 kbuild: Ignore phandle property when diffing base and U-Boot augmented DTs
From: Quentin Schulz <[email protected]>
The phandle property is a unique numerical identifier for a given node such that it can be referenced by other nodes (Device Tree Specification 2.3.3 phandle).
Considering that when we generate the base and U-Boot augmented DTSes for diffing, we actually resolve the phandle with dtc such that the symbol is used instead of the phandle value. This means the phandle value is now unused and unnecessary.
The issue with the phandle property is that it is not necessarily the same between the base and U-Boot augmented DTs. For example, any new Device Tree node with a label inserted in the U-Boot augmented DT before the last (after sorting!) shared (with base DT) labeled Device Tree node, will increment the phandle identifier by one for all nodes after itself, meaning we now have a diff churn between base and U-Boot augmented DTs only for the phandle property. This is typically the case for binman-supporting architectures like Rockchip where the binman node has a label for easy overriding from SoC/board DTSes and since /binman appears pretty early in the DT when sorted, this means many phandle properties are different.
This gets rid of all phandle = <0x>; properties before passing it to the diff tool such that they aren't even taken into account.
Note the double dollar sign in the regex, this is due to Make special meaning for $ which needs to be escaped such that it's passed to the shell as a dollar sign.
---
The BRE (Basic Regular Expression) is quite awkward, but I think we could simply ignore most [[:space:]]* if the output of dtc is guaranteed stable.
Something like
'^[[:space:]]*phandle = <0x[[:xdigit:]]\+>;$$'
probably would be enough I guess?
--- scripts/Makefile.lib | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/Makefile.lib +3 -1
@@ -437,7 +437,9 @@ cmd_dtc_diff = \ $(DTC) -s -O dts -o [email protected] -b 0 \ -i $(dir $<) -i $(u_boot_dtsi_loc) $(DTC_FLAGS) $(dtc-tmp) || \ (echo "Check $(shell pwd)/$(pre-tmp) for errors" && false); \ - (diff -Naru [email protected] [email protected] > [email protected] || true) + grep --invert-match '^[[:space:]]*phandle[[:space:]]*=[[:space:]]<[[:space:]]*0x[[:xdigit:]]\+[[:space:]]*>[[:space:]]*;[[:space:]]*$$' [email protected] > [email protected]; \ + grep --invert-match '^[[:space:]]*phandle[[:space:]]*=[[:space:]]<[[:space:]]*0x[[:xdigit:]]\+[[:space:]]*>[[:space:]]*;[[:space:]]*$$' [email protected] > [email protected]; \ + (diff -Naru [email protected] [email protected] > [email protected] || true) dtn-tmp = $(subst $(comma),_,$(dot-target).dtn.tmp) else
---
base-commit: cc5550e494693ee56e36ffd119523eeed427dfc2
change-id: 20260224-device-tree-debug-no-phandle-caf33b3bffa7
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
Hi all,
Please drop this patch.
Marek had sent a patch 10 days ago on the ML already, see https://lore.kernel.org/u-boot/[email protected]/
Cheers,
Quentin