linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] dtc: enable use of pre-processor
@ 2012-09-28 19:32 Stephen Warren
  2012-09-28 19:32 ` [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule Stephen Warren
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stephen Warren @ 2012-09-28 19:32 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger, Grant Likely, Rob Herring,
	Scott Wood, Mark Brown, Jean-Christophe PLAGNIOL-VILLARD
  Cc: devicetree-discuss, linux-kernel, linux-arch, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

This series adds some build rules to run cpp on *.dtsp prior to
invoking dtc, and converts Tegra to the new rule as an example. What do
people think?

I assume that you've applied the dtc patches I sent yesterday. They
aren't in this series. See:

https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-September/020182.html
https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-September/020183.html
https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-September/020181.html
https://lists.ozlabs.org/pipermail/devicetree-discuss/2012-September/020387.html

Note: those patches are against upstream dtc. If you wish to test this
series, apply the dtc patches to upstream dtc, build it, and copy the
resultant dtc binary over the top of scripts/dtc/dtc.

I'll post a patch to update the in-kernel dtc to the upstream dtc as
soon as one final dtc patch has been applied, and this series will then
depend on that patch.

Stephen Warren (2):
  kbuild: centralize .dts->.dtb rule
  kbuild: introduce cmd_dtc_cpp

 arch/arm/boot/Makefile           |    4 ----
 arch/arm/boot/dts/skeleton.dtsip |   13 +++++++++++++
 arch/c6x/boot/Makefile           |    3 ---
 arch/openrisc/boot/Makefile      |    3 ---
 arch/powerpc/boot/Makefile       |    4 ----
 scripts/Makefile.lib             |    9 +++++++++
 6 files changed, 22 insertions(+), 14 deletions(-)
 create mode 100644 arch/arm/boot/dts/skeleton.dtsip


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

* [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule
  2012-09-28 19:32 [RFC PATCH 0/2] dtc: enable use of pre-processor Stephen Warren
@ 2012-09-28 19:32 ` Stephen Warren
  2012-09-29 20:08   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-28 19:32 ` [RFC PATCH 2/2] kbuild: introduce cmd_dtc_cpp Stephen Warren
  2012-09-28 20:39 ` [RFC PATCH 0/2] dtc: enable use of pre-processor Jon Loeliger
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2012-09-28 19:32 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger, Grant Likely, Rob Herring,
	Scott Wood, Mark Brown, Jean-Christophe PLAGNIOL-VILLARD
  Cc: devicetree-discuss, linux-kernel, linux-arch, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

All architectures that use cmd_dtc do so in the same way. Move the build
rule to a central location to avoid duplication.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Jean-Christophe,
Moving the build rule to Makefile.lib rather than Makefile.build seems
reasonable to me; the dtc-related logic is already in Makefile.lib, and
for features where cmd_* is defined in Makefile.lib, the associated
build rule is also defined there. I see no reason for this patch series
to move all the dtc-related logic into Makefile.build.

 arch/arm/boot/Makefile      |    4 ----
 arch/c6x/boot/Makefile      |    3 ---
 arch/openrisc/boot/Makefile |    3 ---
 arch/powerpc/boot/Makefile  |    4 ----
 scripts/Makefile.lib        |    3 +++
 5 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 3fdab01..da33331 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -61,10 +61,6 @@ endif
 
 targets += $(dtb-y)
 
-# Rule to build device tree blobs
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
-	$(call if_changed_dep,dtc)
-
 $(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y))
 
 clean-files := *.dtb
diff --git a/arch/c6x/boot/Makefile b/arch/c6x/boot/Makefile
index 6891257..ad605fb 100644
--- a/arch/c6x/boot/Makefile
+++ b/arch/c6x/boot/Makefile
@@ -12,9 +12,6 @@ ifneq ($(DTB),)
 obj-y += linked_dtb.o
 endif
 
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
-	$(call if_changed_dep,dtc)
-
 quiet_cmd_cp = CP      $< $@$2
 	cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
 
diff --git a/arch/openrisc/boot/Makefile b/arch/openrisc/boot/Makefile
index 0995835..fd329bd 100644
--- a/arch/openrisc/boot/Makefile
+++ b/arch/openrisc/boot/Makefile
@@ -10,6 +10,3 @@ obj-y += $(BUILTIN_DTB)
 clean-files := *.dtb.S
 
 #DTC_FLAGS ?= -p 1024
-
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
-	$(call if_changed_dep,dtc)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 6a15c96..90206f2 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -356,10 +356,6 @@ $(obj)/treeImage.initrd.%: vmlinux $(obj)/%.dtb $(wrapperbits)
 $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits)
 	$(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb)
 
-# Rule to build device tree blobs
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
-	$(call if_changed_dep,dtc)
-
 # If there isn't a platform selected then just strip the vmlinux.
 ifeq (,$(image-y))
 image-y := vmlinux.strip
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0be6f11..425578e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -266,6 +266,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
 quiet_cmd_dtc = DTC     $@
 cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $<
 
+$(obj)/%.dtb: $(src)/dts/%.dts FORCE
+	$(call if_changed_dep,dtc)
+
 # Bzip2
 # ---------------------------------------------------------------------------
 
-- 
1.7.0.4


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

* [RFC PATCH 2/2] kbuild: introduce cmd_dtc_cpp
  2012-09-28 19:32 [RFC PATCH 0/2] dtc: enable use of pre-processor Stephen Warren
  2012-09-28 19:32 ` [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule Stephen Warren
@ 2012-09-28 19:32 ` Stephen Warren
  2012-09-29 20:02   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-09-28 20:39 ` [RFC PATCH 0/2] dtc: enable use of pre-processor Jon Loeliger
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Warren @ 2012-09-28 19:32 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger, Grant Likely, Rob Herring,
	Scott Wood, Mark Brown, Jean-Christophe PLAGNIOL-VILLARD
  Cc: devicetree-discuss, linux-kernel, linux-arch, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

cmd_dtc_cpp runs the C pre-processor on the input .dts file before
passing it to dtc for final compilation. This allows used of #define
within the .dts file.

Introduce a new rule for %.dtsp -> %.dtb, which uses cmd_dtc_cpp. A new
file extension is introduced for this purpose, since use of the pre-
processor must be optional; any property or node name that starts with
"#" must be escaped to prevent the pre-processor attempting to interpret
it as a directive. For this reason, skeleton.dtsi-cpp is introduced for
*.dts-cpp to include.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 arch/arm/boot/dts/skeleton.dtsip |   13 +++++++++++++
 scripts/Makefile.lib             |    6 ++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/skeleton.dtsip

diff --git a/arch/arm/boot/dts/skeleton.dtsip b/arch/arm/boot/dts/skeleton.dtsip
new file mode 100644
index 0000000..8bf6729
--- /dev/null
+++ b/arch/arm/boot/dts/skeleton.dtsip
@@ -0,0 +1,13 @@
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
+ * add a compatible value.  The bootloader will typically populate the memory
+ * node.
+ */
+
+/ {
+	\#address-cells = <1>;
+	\#size-cells = <1>;
+	chosen { };
+	aliases { };
+	memory { device_type = "memory"; reg = <0 0>; };
+};
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 425578e..9dd81c0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -269,6 +269,12 @@ cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile
 $(obj)/%.dtb: $(src)/dts/%.dts FORCE
 	$(call if_changed_dep,dtc)
 
+quiet_cmd_dtc_cpp = DTC+CPP $@
+cmd_dtc_cpp = $(CC) -E -Wp,-MD,$(depfile) -xc $< | $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -
+
+$(obj)/%.dtb: $(src)/dts/%.dtsp FORCE
+	$(call if_changed_dep,dtc_cpp)
+
 # Bzip2
 # ---------------------------------------------------------------------------
 
-- 
1.7.0.4


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

* Re: [RFC PATCH 0/2] dtc: enable use of pre-processor
  2012-09-28 19:32 [RFC PATCH 0/2] dtc: enable use of pre-processor Stephen Warren
  2012-09-28 19:32 ` [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule Stephen Warren
  2012-09-28 19:32 ` [RFC PATCH 2/2] kbuild: introduce cmd_dtc_cpp Stephen Warren
@ 2012-09-28 20:39 ` Jon Loeliger
  2 siblings, 0 replies; 7+ messages in thread
From: Jon Loeliger @ 2012-09-28 20:39 UTC (permalink / raw)
  To: Stephen Warren
  Cc: David Gibson, Grant Likely, Rob Herring, Scott Wood, Mark Brown,
	Jean-Christophe PLAGNIOL-VILLARD, devicetree-discuss,
	linux-kernel, linux-arch, Stephen Warren

> From: Stephen Warren <swarren@nvidia.com>
> 
> I'll post a patch to update the in-kernel dtc to the upstream dtc as
> soon as one final dtc patch has been applied, and this series will then
> depend on that patch.

And that patch, I think, has just been applied to the 
upstream DTC repo at git.jdl.com:

    commit 317a5d92bc357aba2c993ee78b4c089b7539fcc6
    Author: Stephen Warren <swarren@nvidia.com>
    Date:   Fri Sep 28 12:39:22 2012 -0600

    dtc: zero out new label objects
    
    Without this, new->deleted may be left set to some random value, which
    may then cause future label references to fail to locate the label. The
    code that allocates properties and nodes already contains the equivalent
    memset().
    
    Signed-off-by: Stephen Warren <swarren@nvidia.com>

HTH,
jdl

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

* Re: [RFC PATCH 2/2] kbuild: introduce cmd_dtc_cpp
  2012-09-28 19:32 ` [RFC PATCH 2/2] kbuild: introduce cmd_dtc_cpp Stephen Warren
@ 2012-09-29 20:02   ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-29 20:02 UTC (permalink / raw)
  To: Stephen Warren
  Cc: David Gibson, Jon Loeliger, Grant Likely, Rob Herring,
	Scott Wood, Mark Brown, devicetree-discuss, linux-kernel,
	linux-arch, Stephen Warren

On 13:32 Fri 28 Sep     , Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> cmd_dtc_cpp runs the C pre-processor on the input .dts file before
> passing it to dtc for final compilation. This allows used of #define
> within the .dts file.
> 
> Introduce a new rule for %.dtsp -> %.dtb, which uses cmd_dtc_cpp. A new
> file extension is introduced for this purpose, since use of the pre-
> processor must be optional; any property or node name that starts with
> "#" must be escaped to prevent the pre-processor attempting to interpret
> it as a directive. For this reason, skeleton.dtsi-cpp is introduced for
> *.dts-cpp to include.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  arch/arm/boot/dts/skeleton.dtsip |   13 +++++++++++++
>  scripts/Makefile.lib             |    6 ++++++
>  2 files changed, 19 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/boot/dts/skeleton.dtsip
> 
> diff --git a/arch/arm/boot/dts/skeleton.dtsip b/arch/arm/boot/dts/skeleton.dtsip
> new file mode 100644
> index 0000000..8bf6729
> --- /dev/null
> +++ b/arch/arm/boot/dts/skeleton.dtsip
> @@ -0,0 +1,13 @@
> +/*
> + * Skeleton device tree; the bare minimum needed to boot; just include and
> + * add a compatible value.  The bootloader will typically populate the memory
> + * node.
> + */
> +
> +/ {
> +	\#address-cells = <1>;
> +	\#size-cells = <1>;
> +	chosen { };
> +	aliases { };
> +	memory { device_type = "memory"; reg = <0 0>; };
> +};
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 425578e..9dd81c0 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -269,6 +269,12 @@ cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile
>  $(obj)/%.dtb: $(src)/dts/%.dts FORCE
>  	$(call if_changed_dep,dtc)
>  
> +quiet_cmd_dtc_cpp = DTC+CPP $@
> +cmd_dtc_cpp = $(CC) -E -Wp,-MD,$(depfile) -xc $< | $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -
> +
> +$(obj)/%.dtb: $(src)/dts/%.dtsp FORCE
> +	$(call if_changed_dep,dtc_cpp)
> +
here no this is build stuff move it to Makefile.build

Best Regards,
J.

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

* Re: [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule
  2012-09-28 19:32 ` [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule Stephen Warren
@ 2012-09-29 20:08   ` Jean-Christophe PLAGNIOL-VILLARD
  2012-10-01 15:36     ` Stephen Warren
  0 siblings, 1 reply; 7+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-09-29 20:08 UTC (permalink / raw)
  To: Stephen Warren
  Cc: David Gibson, Jon Loeliger, Grant Likely, Rob Herring,
	Scott Wood, Mark Brown, devicetree-discuss, linux-kernel,
	linux-arch, Stephen Warren

On 13:32 Fri 28 Sep     , Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> All architectures that use cmd_dtc do so in the same way. Move the build
> rule to a central location to avoid duplication.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
> Jean-Christophe,
> Moving the build rule to Makefile.lib rather than Makefile.build seems
> reasonable to me; the dtc-related logic is already in Makefile.lib, and
> for features where cmd_* is defined in Makefile.lib, the associated
> build rule is also defined there. I see no reason for this patch series
> to move all the dtc-related logic into Makefile.build.

build rules are in Makefile.build c to o , s to o etc...

so put it in Makefile.build is the correct place ditto fot the dtc cmd

Best Regards,
J.

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

* Re: [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule
  2012-09-29 20:08   ` Jean-Christophe PLAGNIOL-VILLARD
@ 2012-10-01 15:36     ` Stephen Warren
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Warren @ 2012-10-01 15:36 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD
  Cc: David Gibson, Jon Loeliger, Grant Likely, Rob Herring,
	Scott Wood, Mark Brown, devicetree-discuss, linux-kernel,
	linux-arch, Stephen Warren

On 09/29/2012 02:08 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 13:32 Fri 28 Sep     , Stephen Warren wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> All architectures that use cmd_dtc do so in the same way. Move the build
>> rule to a central location to avoid duplication.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> ---
>> Jean-Christophe,
>> Moving the build rule to Makefile.lib rather than Makefile.build seems
>> reasonable to me; the dtc-related logic is already in Makefile.lib, and
>> for features where cmd_* is defined in Makefile.lib, the associated
>> build rule is also defined there. I see no reason for this patch series
>> to move all the dtc-related logic into Makefile.build.
> 
> build rules are in Makefile.build c to o , s to o etc...

As I explicitly pointed out above, your statement is simply not true;
there are many build rules in Makefile.lib.

> so put it in Makefile.build is the correct place ditto fot the dtc cmd

As such, I'm just going to ignore that feedback. Perhaps the kbuild
maintainer (oops, who I forgot to CC; I'll forward him the patches) can
weigh in though.

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

end of thread, other threads:[~2012-10-01 15:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-28 19:32 [RFC PATCH 0/2] dtc: enable use of pre-processor Stephen Warren
2012-09-28 19:32 ` [RFC PATCH 1/2] kbuild: centralize .dts->.dtb rule Stephen Warren
2012-09-29 20:08   ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-01 15:36     ` Stephen Warren
2012-09-28 19:32 ` [RFC PATCH 2/2] kbuild: introduce cmd_dtc_cpp Stephen Warren
2012-09-29 20:02   ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-28 20:39 ` [RFC PATCH 0/2] dtc: enable use of pre-processor Jon Loeliger

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