linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [boot-wrapper PATCH v3] Makefile: avoid dtc warnings on re-compiling DTB
@ 2022-01-31 16:31 Andre Przywara
  2022-01-31 17:33 ` Vladimir Murzin
  2022-02-01 12:14 ` Mark Rutland
  0 siblings, 2 replies; 3+ messages in thread
From: Andre Przywara @ 2022-01-31 16:31 UTC (permalink / raw)
  To: Mark Rutland; +Cc: Jaxson Han, linux-arm-kernel, Vladimir Murzin

When we add the PSCI nodes to the provided DTB, we use dtc to de-compile
the blob first, then re-compile it with our nodes and properties added.

In our input DTB the proper phandle references have already been lost,
all we see in the DTB is phandle properties in the target node, and some
numbers in the clocks and gpios properties:
===========
	clk24mhz {
		compatible = "fixed-clock";
		#clock-cells = <0x00>;
		clock-frequency = <0x16e3600>;
		clock-output-names = "v2m:clk24mhz";
->		phandle = <0x05>;
	};
	...
	serial@90000 {
		compatible = "arm,pl011", "arm,primecell";
		reg = <0x90000 0x1000>;
		interrupts = <0x05>;
->		clocks = <0x05 0x05>;
		clock-names = "uartclk", "apb_pclk";
	};
===========
dtc warns that those numbers might be wrong:
=========
<stdin>:177.6-27: Warning (clocks_property):
 /bus@8000000/motherboard-bus@8000000/iofpga-bus@300000000/serial@90000:
   clocks: cell 0 is not a phandle reference
....
=========
The proper solution would be to use references (&v2m_clk24mhz) instead,
as there are in the source .dts file, but we don't have that information
anymore, and cannot easily recover it.

To avoid the lengthy list of warnings, just drop those checks from the
dtc compilation run. This disables more checks than we want or need, but
we somewhat trust in the original DTB to be sane, so that should be
fine.
Since those warning options are not supported by older dtc versions,
introduce a compatiblity check before using them.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi,

this replaces the reverted version of the patch, adding runtime detection
of dtc's compatibility.
Works fine with a clueless dtc 1.4.1.

Cheers,
Andre

 Makefile.am | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 40bc5d6..08e304a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -162,8 +162,16 @@ $(COMMON_SRC):
 model.lds: $(LD_SCRIPT) Makefile
 	$(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) $(XEN) -DXEN_OFFSET=$(XEN_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $<
 
+# Run dtc with an given command line option to check support for it.
+define test-dtc-option
+$(if $(shell echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null 2>&1),,$(1))
+endef
+
+DTC_NOWARN  = $(call test-dtc-option,-Wno-clocks_property)
+DTC_NOWARN += $(call test-dtc-option,-Wno-gpios_property)
+
 fdt.dtb: $(KERNEL_DTB) Makefile
-	( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) }; $(CPU_NODES)" ) | $(DTC) -O dtb -o $@ -
+	( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) }; $(CPU_NODES)" ) | $(DTC) -O dtb -o $@ $(DTC_NOWARN) -
 
 # The filesystem archive might not exist if INITRD is not being used
 .PHONY: all clean $(FILESYSTEM)
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [boot-wrapper PATCH v3] Makefile: avoid dtc warnings on re-compiling DTB
  2022-01-31 16:31 [boot-wrapper PATCH v3] Makefile: avoid dtc warnings on re-compiling DTB Andre Przywara
@ 2022-01-31 17:33 ` Vladimir Murzin
  2022-02-01 12:14 ` Mark Rutland
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Murzin @ 2022-01-31 17:33 UTC (permalink / raw)
  To: Andre Przywara, Mark Rutland; +Cc: Jaxson Han, linux-arm-kernel

On 1/31/22 4:31 PM, Andre Przywara wrote:
> When we add the PSCI nodes to the provided DTB, we use dtc to de-compile
> the blob first, then re-compile it with our nodes and properties added.
> 
> In our input DTB the proper phandle references have already been lost,
> all we see in the DTB is phandle properties in the target node, and some
> numbers in the clocks and gpios properties:
> ===========
> 	clk24mhz {
> 		compatible = "fixed-clock";
> 		#clock-cells = <0x00>;
> 		clock-frequency = <0x16e3600>;
> 		clock-output-names = "v2m:clk24mhz";
> ->		phandle = <0x05>;
> 	};
> 	...
> 	serial@90000 {
> 		compatible = "arm,pl011", "arm,primecell";
> 		reg = <0x90000 0x1000>;
> 		interrupts = <0x05>;
> ->		clocks = <0x05 0x05>;
> 		clock-names = "uartclk", "apb_pclk";
> 	};
> ===========
> dtc warns that those numbers might be wrong:
> =========
> <stdin>:177.6-27: Warning (clocks_property):
>  /bus@8000000/motherboard-bus@8000000/iofpga-bus@300000000/serial@90000:
>    clocks: cell 0 is not a phandle reference
> ....
> =========
> The proper solution would be to use references (&v2m_clk24mhz) instead,
> as there are in the source .dts file, but we don't have that information
> anymore, and cannot easily recover it.
> 
> To avoid the lengthy list of warnings, just drop those checks from the
> dtc compilation run. This disables more checks than we want or need, but
> we somewhat trust in the original DTB to be sane, so that should be
> fine.
> Since those warning options are not supported by older dtc versions,
> introduce a compatiblity check before using them.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> Hi,
> 
> this replaces the reverted version of the patch, adding runtime detection
> of dtc's compatibility.
> Works fine with a clueless dtc 1.4.1.
> 
> Cheers,
> Andre
> 
>  Makefile.am | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile.am b/Makefile.am
> index 40bc5d6..08e304a 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -162,8 +162,16 @@ $(COMMON_SRC):
>  model.lds: $(LD_SCRIPT) Makefile
>  	$(CPP) $(CPPFLAGS) -ansi -DPHYS_OFFSET=$(PHYS_OFFSET) -DMBOX_OFFSET=$(MBOX_OFFSET) -DKERNEL_OFFSET=$(KERNEL_OFFSET) -DFDT_OFFSET=$(FDT_OFFSET) -DFS_OFFSET=$(FS_OFFSET) $(XEN) -DXEN_OFFSET=$(XEN_OFFSET) -DKERNEL=$(KERNEL_IMAGE) -DFILESYSTEM=$(FILESYSTEM) -DTEXT_LIMIT=$(TEXT_LIMIT) -P -C -o $@ $<
>  
> +# Run dtc with an given command line option to check support for it.
> +define test-dtc-option
> +$(if $(shell echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null 2>&1),,$(1))
> +endef
> +
> +DTC_NOWARN  = $(call test-dtc-option,-Wno-clocks_property)
> +DTC_NOWARN += $(call test-dtc-option,-Wno-gpios_property)
> +
>  fdt.dtb: $(KERNEL_DTB) Makefile
> -	( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) }; $(CPU_NODES)" ) | $(DTC) -O dtb -o $@ -
> +	( $(DTC) -O dts -I dtb $(KERNEL_DTB) ; echo "/ { $(CHOSEN_NODE) $(PSCI_NODE) }; $(CPU_NODES)" ) | $(DTC) -O dtb -o $@ $(DTC_NOWARN) -
>  
>  # The filesystem archive might not exist if INITRD is not being used
>  .PHONY: all clean $(FILESYSTEM)
> 

FWIW, 

Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>

Thanks
Vladimir

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [boot-wrapper PATCH v3] Makefile: avoid dtc warnings on re-compiling DTB
  2022-01-31 16:31 [boot-wrapper PATCH v3] Makefile: avoid dtc warnings on re-compiling DTB Andre Przywara
  2022-01-31 17:33 ` Vladimir Murzin
@ 2022-02-01 12:14 ` Mark Rutland
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Rutland @ 2022-02-01 12:14 UTC (permalink / raw)
  To: Andre Przywara; +Cc: Jaxson Han, linux-arm-kernel, Vladimir Murzin

On Mon, Jan 31, 2022 at 04:31:22PM +0000, Andre Przywara wrote:

[...]

> To avoid the lengthy list of warnings, just drop those checks from the
> dtc compilation run. This disables more checks than we want or need, but
> we somewhat trust in the original DTB to be sane, so that should be
> fine.
> Since those warning options are not supported by older dtc versions,
> introduce a compatiblity check before using them.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
> Hi,
> 
> this replaces the reverted version of the patch, adding runtime detection
> of dtc's compatibility.
> Works fine with a clueless dtc 1.4.1.

Thanks; applied.

Mark.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-01 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-31 16:31 [boot-wrapper PATCH v3] Makefile: avoid dtc warnings on re-compiling DTB Andre Przywara
2022-01-31 17:33 ` Vladimir Murzin
2022-02-01 12:14 ` Mark Rutland

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).