Discussion:
[ORLinux] [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule
Stephen Warren
2012-11-27 23:29:10 UTC
Permalink
From: Stephen Warren <swarren at nvidia.com>

All architectures that use cmd_dtc do so in almost the same way. Create
a central build rule to avoid duplication. The one difference is that
most current uses of dtc build $(obj)/%.dtb from $(src)/dts/%.dts rather
than building the .dtb in the same directory as the .dts file. This
difference will be eliminated arch-by-arch in future patches.

MIPS is the exception here; it already uses the exact same rule as the
new common rule, so the duplicate is removed in this patch to avoid any
conflict. arch/mips changes courtesy of Ralf Baechle.

Update Documentation/kbuild to remove the explicit call to cmd_dtc from
the example, now that the rule exists in a centralized location.

Cc: Arnd Bergmann <arnd at arndb.de>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Olof Johansson <olof at lixom.net>
Cc: Russell King <linux at arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
Cc: Aurelien Jacquiot <a-jacquiot at ti.com>
Cc: linux-c6x-dev at linux-c6x.org
Cc: Mark Salter <msalter at redhat.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Chris Zankel <chris at zankel.net>
Cc: linux-xtensa at linux-xtensa.org
Cc: Max Filippov <jcmvbkbc at gmail.com>
Signed-off-by: Ralf Baechle <ralf at linux-mips.org>
Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
This is based on next-20121126.

I've split out this dtc rule cleanup as a separate patch series.
Hopefully it can be applied without too much controversy, then I'll move
back to discussing running cpp over *.dts.

v7:
* Build *.dtb from *.dts not src/*.dts.
* Removed all arch/ updates except MIPS.
v6: Added arch/{arm64,microblaze,mips} updates.
v5: Updated Documentation/kbuild.
v4: No change.
v3: No change.
v2: New patch.
---
Documentation/kbuild/makefiles.txt | 15 ++++++++-------
arch/mips/cavium-octeon/Makefile | 3 ---
arch/mips/lantiq/dts/Makefile | 3 ---
arch/mips/netlogic/dts/Makefile | 3 ---
scripts/Makefile.lib | 3 +++
5 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index ec9ae67..14c3f4f 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1175,15 +1175,16 @@ When kbuild executes, the following steps are followed (roughly):
in an init section in the image. Platform code *must* copy the
blob to non-init memory prior to calling unflatten_device_tree().

- Example:
- #arch/x86/platform/ce4100/Makefile
- clean-files := *dtb.S
+ To use this command, simply add *.dtb into obj-y or targets, or make
+ some other target depend on %.dtb

- DTC_FLAGS := -p 1024
- obj-y += foo.dtb.o
+ A central rule exists to create $(obj)/%.dtb from $(src)/%.dts;
+ architecture Makefiles do no need to explicitly write out that rule.

- $(obj)/%.dtb: $(src)/%.dts
- $(call cmd,dtc)
+ Example:
+ targets += $(dtb-y)
+ clean-files += *.dtb
+ DTC_FLAGS ?= -p 1024

--- 6.8 Custom kbuild commands

diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index bc96e29..6e927cf 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -24,9 +24,6 @@ DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES))

obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES))

-$(obj)/%.dtb: $(src)/%.dts FORCE
- $(call if_changed_dep,dtc)
-
# Let's keep the .dtb files around in case we want to look at them.
.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES))

diff --git a/arch/mips/lantiq/dts/Makefile b/arch/mips/lantiq/dts/Makefile
index 674fca4..6fa72dd 100644
--- a/arch/mips/lantiq/dts/Makefile
+++ b/arch/mips/lantiq/dts/Makefile
@@ -1,4 +1 @@
obj-$(CONFIG_DT_EASY50712) := easy50712.dtb.o
-
-$(obj)/%.dtb: $(obj)/%.dts
- $(call if_changed,dtc)
diff --git a/arch/mips/netlogic/dts/Makefile b/arch/mips/netlogic/dts/Makefile
index 67ae3fe2..d117d46 100644
--- a/arch/mips/netlogic/dts/Makefile
+++ b/arch/mips/netlogic/dts/Makefile
@@ -1,4 +1 @@
obj-$(CONFIG_DT_XLP_EVP) := xlp_evp.dtb.o
-
-$(obj)/%.dtb: $(obj)/%.dts
- $(call if_changed,dtc)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0be6f11..bdf42fd 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 FORCE
+ $(call if_changed_dep,dtc)
+
# Bzip2
# ---------------------------------------------------------------------------
--
1.7.10.4
Stephen Warren
2012-11-27 23:29:13 UTC
Permalink
From: Stephen Warren <swarren at nvidia.com>

The current rules have the .dtb files build in a different directory
from the .dts files. This patch changes openrisc to use the generic dtb
rule which builds .dtb files in the same directory as the source .dts.

This requires renaming arch/openrisc/boot/Makefile to
arch/openrisc/boot/dts/Makefile, and updating arch/openrisc/Makefile to
call the new Makefile.

Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
v7: New patch.
---
arch/openrisc/Makefile | 2 +-
arch/openrisc/boot/{ => dts}/Makefile | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
rename arch/openrisc/boot/{ => dts}/Makefile (75%)

diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile
index 966886c..4739b83 100644
--- a/arch/openrisc/Makefile
+++ b/arch/openrisc/Makefile
@@ -50,6 +50,6 @@ BUILTIN_DTB := y
else
BUILTIN_DTB := n
endif
-core-$(BUILTIN_DTB) += arch/openrisc/boot/
+core-$(BUILTIN_DTB) += arch/openrisc/boot/dts/

all: vmlinux
diff --git a/arch/openrisc/boot/Makefile b/arch/openrisc/boot/dts/Makefile
similarity index 75%
rename from arch/openrisc/boot/Makefile
rename to arch/openrisc/boot/dts/Makefile
index 0995835..b092d30 100644
--- a/arch/openrisc/boot/Makefile
+++ b/arch/openrisc/boot/dts/Makefile
@@ -1,5 +1,3 @@
-
-
ifneq '$(CONFIG_OPENRISC_BUILTIN_DTB)' '""'
BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_OPENRISC_BUILTIN_DTB)).dtb.o
else
@@ -10,6 +8,3 @@ obj-y += $(BUILTIN_DTB)
clean-files := *.dtb.S

#DTC_FLAGS ?= -p 1024
-
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
- $(call if_changed_dep,dtc)
--
1.7.10.4
Catalin Marinas
2012-11-28 17:44:26 UTC
Permalink
Post by Stephen Warren
From: Stephen Warren <swarren at nvidia.com>
All architectures that use cmd_dtc do so in almost the same way. Create
a central build rule to avoid duplication. The one difference is that
most current uses of dtc build $(obj)/%.dtb from $(src)/dts/%.dts rather
than building the .dtb in the same directory as the .dts file. This
difference will be eliminated arch-by-arch in future patches.
MIPS is the exception here; it already uses the exact same rule as the
new common rule, so the duplicate is removed in this patch to avoid any
conflict. arch/mips changes courtesy of Ralf Baechle.
Update Documentation/kbuild to remove the explicit call to cmd_dtc from
the example, now that the rule exists in a centralized location.
Cc: Arnd Bergmann <arnd at arndb.de>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Olof Johansson <olof at lixom.net>
Cc: Russell King <linux at arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
Cc: Aurelien Jacquiot <a-jacquiot at ti.com>
Cc: linux-c6x-dev at linux-c6x.org
Cc: Mark Salter <msalter at redhat.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Chris Zankel <chris at zankel.net>
Cc: linux-xtensa at linux-xtensa.org
Cc: Max Filippov <jcmvbkbc at gmail.com>
Signed-off-by: Ralf Baechle <ralf at linux-mips.org>
Signed-off-by: Stephen Warren <swarren at nvidia.com>
Acked-by: Catalin Marinas <catalin.marinas at arm.com>
Rob Herring
2012-11-30 16:01:50 UTC
Permalink
Post by Stephen Warren
From: Stephen Warren <swarren at nvidia.com>
All architectures that use cmd_dtc do so in almost the same way. Create
a central build rule to avoid duplication. The one difference is that
most current uses of dtc build $(obj)/%.dtb from $(src)/dts/%.dts rather
than building the .dtb in the same directory as the .dts file. This
difference will be eliminated arch-by-arch in future patches.
MIPS is the exception here; it already uses the exact same rule as the
new common rule, so the duplicate is removed in this patch to avoid any
conflict. arch/mips changes courtesy of Ralf Baechle.
Update Documentation/kbuild to remove the explicit call to cmd_dtc from
the example, now that the rule exists in a centralized location.
Cc: Arnd Bergmann <arnd at arndb.de>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Olof Johansson <olof at lixom.net>
Cc: Russell King <linux at arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
Cc: Aurelien Jacquiot <a-jacquiot at ti.com>
Cc: linux-c6x-dev at linux-c6x.org
Cc: Mark Salter <msalter at redhat.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Chris Zankel <chris at zankel.net>
Cc: linux-xtensa at linux-xtensa.org
Cc: Max Filippov <jcmvbkbc at gmail.com>
Signed-off-by: Ralf Baechle <ralf at linux-mips.org>
Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
This is based on next-20121126.
I'll apply the series but I need a stable base. Looks like xtensa has
the dependency. Or I can just drop xtensa.

Rob
Post by Stephen Warren
I've split out this dtc rule cleanup as a separate patch series.
Hopefully it can be applied without too much controversy, then I'll move
back to discussing running cpp over *.dts.
* Build *.dtb from *.dts not src/*.dts.
* Removed all arch/ updates except MIPS.
v6: Added arch/{arm64,microblaze,mips} updates.
v5: Updated Documentation/kbuild.
v4: No change.
v3: No change.
v2: New patch.
---
Documentation/kbuild/makefiles.txt | 15 ++++++++-------
arch/mips/cavium-octeon/Makefile | 3 ---
arch/mips/lantiq/dts/Makefile | 3 ---
arch/mips/netlogic/dts/Makefile | 3 ---
scripts/Makefile.lib | 3 +++
5 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index ec9ae67..14c3f4f 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
in an init section in the image. Platform code *must* copy the
blob to non-init memory prior to calling unflatten_device_tree().
- #arch/x86/platform/ce4100/Makefile
- clean-files := *dtb.S
+ To use this command, simply add *.dtb into obj-y or targets, or make
+ some other target depend on %.dtb
- DTC_FLAGS := -p 1024
- obj-y += foo.dtb.o
+ A central rule exists to create $(obj)/%.dtb from $(src)/%.dts;
+ architecture Makefiles do no need to explicitly write out that rule.
- $(obj)/%.dtb: $(src)/%.dts
- $(call cmd,dtc)
+ targets += $(dtb-y)
+ clean-files += *.dtb
+ DTC_FLAGS ?= -p 1024
--- 6.8 Custom kbuild commands
diff --git a/arch/mips/cavium-octeon/Makefile b/arch/mips/cavium-octeon/Makefile
index bc96e29..6e927cf 100644
--- a/arch/mips/cavium-octeon/Makefile
+++ b/arch/mips/cavium-octeon/Makefile
@@ -24,9 +24,6 @@ DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES))
obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES))
-$(obj)/%.dtb: $(src)/%.dts FORCE
- $(call if_changed_dep,dtc)
-
# Let's keep the .dtb files around in case we want to look at them.
.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES))
diff --git a/arch/mips/lantiq/dts/Makefile b/arch/mips/lantiq/dts/Makefile
index 674fca4..6fa72dd 100644
--- a/arch/mips/lantiq/dts/Makefile
+++ b/arch/mips/lantiq/dts/Makefile
@@ -1,4 +1 @@
obj-$(CONFIG_DT_EASY50712) := easy50712.dtb.o
-
-$(obj)/%.dtb: $(obj)/%.dts
- $(call if_changed,dtc)
diff --git a/arch/mips/netlogic/dts/Makefile b/arch/mips/netlogic/dts/Makefile
index 67ae3fe2..d117d46 100644
--- a/arch/mips/netlogic/dts/Makefile
+++ b/arch/mips/netlogic/dts/Makefile
@@ -1,4 +1 @@
obj-$(CONFIG_DT_XLP_EVP) := xlp_evp.dtb.o
-
-$(obj)/%.dtb: $(obj)/%.dts
- $(call if_changed,dtc)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0be6f11..bdf42fd 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -266,6 +266,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
+$(obj)/%.dtb: $(src)/%.dts FORCE
+ $(call if_changed_dep,dtc)
+
# Bzip2
# ---------------------------------------------------------------------------
Stephen Warren
2012-11-30 19:34:22 UTC
Permalink
Post by Rob Herring
Post by Stephen Warren
From: Stephen Warren <swarren at nvidia.com>
All architectures that use cmd_dtc do so in almost the same way. Create
a central build rule to avoid duplication. The one difference is that
most current uses of dtc build $(obj)/%.dtb from $(src)/dts/%.dts rather
than building the .dtb in the same directory as the .dts file. This
difference will be eliminated arch-by-arch in future patches.
MIPS is the exception here; it already uses the exact same rule as the
new common rule, so the duplicate is removed in this patch to avoid any
conflict. arch/mips changes courtesy of Ralf Baechle.
Update Documentation/kbuild to remove the explicit call to cmd_dtc from
the example, now that the rule exists in a centralized location.
Cc: Arnd Bergmann <arnd at arndb.de>
Cc: linux-arm-kernel at lists.infradead.org
Cc: Olof Johansson <olof at lixom.net>
Cc: Russell King <linux at arm.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas at arm.com>
Cc: Jonas Bonn <jonas at southpole.se>
Cc: linux at lists.openrisc.net
Cc: Aurelien Jacquiot <a-jacquiot at ti.com>
Cc: linux-c6x-dev at linux-c6x.org
Cc: Mark Salter <msalter at redhat.com>
Cc: Michal Simek <monstr at monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Chris Zankel <chris at zankel.net>
Cc: linux-xtensa at linux-xtensa.org
Cc: Max Filippov <jcmvbkbc at gmail.com>
Signed-off-by: Ralf Baechle <ralf at linux-mips.org>
Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
This is based on next-20121126.
I'll apply the series but I need a stable base. Looks like xtensa has
the dependency. Or I can just drop xtensa.
I was assuming this series would be applied for 3.9, hence hadn't
rebased it onto anything stable yet. Are you wanting to apply it
earlier? If so, I'll look into how it fits on top of 3.7-rc7.
Max Filippov
2012-12-01 04:43:19 UTC
Permalink
On Fri, Nov 30, 2012 at 8:01 PM, Rob Herring <robherring2 at gmail.com> wrote:

[...]
Post by Rob Herring
Post by Stephen Warren
This is based on next-20121126.
I'll apply the series but I need a stable base. Looks like xtensa has
the dependency. Or I can just drop xtensa.
Please drop it, I will follow up with a conversion.
--
Thanks.
-- Max
Loading...