2012-11-27 23:29:34

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

From: Stephen Warren <[email protected]>

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 <[email protected]>
Cc: [email protected]
Cc: Olof Johansson <[email protected]>
Cc: Russell King <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Jonas Bonn <[email protected]>
Cc: [email protected]
Cc: Aurelien Jacquiot <[email protected]>
Cc: [email protected]
Cc: Mark Salter <[email protected]>
Cc: Michal Simek <[email protected]>
Cc: [email protected]
Cc: Chris Zankel <[email protected]>
Cc: [email protected]
Cc: Max Filippov <[email protected]>
Signed-off-by: Ralf Baechle <[email protected]>
Signed-off-by: Stephen Warren <[email protected]>
---
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


2012-11-27 23:29:36

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 3/7] arm64: use new common dtc rule

From: Stephen Warren <[email protected]>

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

This requires moving parts of arch/arm64/boot/Makefile into newly created
arch/arm64/boot/dts/Makefile, and updating arch/arm64/Makefile to call the
new Makefile.

Cc: Catalin Marinas <[email protected]>
Cc: [email protected]
Signed-off-by: Stephen Warren <[email protected]>
---
v7: New patch.
---
arch/arm64/Makefile | 2 +-
arch/arm64/boot/Makefile | 5 -----
arch/arm64/boot/dts/Makefile | 5 +++++
3 files changed, 6 insertions(+), 6 deletions(-)
create mode 100644 arch/arm64/boot/dts/Makefile

diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 364191f..fd3d4a1 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -54,7 +54,7 @@ zinstall install: vmlinux
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@

%.dtb:
- $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
+ $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@

# We use MRPROPER_FILES and CLEAN_FILES now
archclean:
diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
index eca209b..5a0e3ab 100644
--- a/arch/arm64/boot/Makefile
+++ b/arch/arm64/boot/Makefile
@@ -22,9 +22,6 @@ $(obj)/Image: vmlinux FORCE
$(obj)/Image.gz: $(obj)/Image FORCE
$(call if_changed,gzip)

-$(obj)/%.dtb: $(src)/dts/%.dts
- $(call cmd,dtc)
-
install: $(obj)/Image
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
$(obj)/Image System.map "$(INSTALL_PATH)"
@@ -32,5 +29,3 @@ install: $(obj)/Image
zinstall: $(obj)/Image.gz
$(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
$(obj)/Image.gz System.map "$(INSTALL_PATH)"
-
-clean-files += *.dtb
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
new file mode 100644
index 0000000..801e2d7
--- /dev/null
+++ b/arch/arm64/boot/dts/Makefile
@@ -0,0 +1,5 @@
+targets += dtbs
+
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+
+clean-files := *.dtb
--
1.7.10.4

2012-11-27 23:29:44

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 5/7] c6x: use new common dtc rule

From: Stephen Warren <[email protected]>

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

This requires moving parts of arch/c6x/boot/Makefile into newly created
arch/c6x/boot/dts/Makefile, and updating arch/c6x/Makefile to call the
new Makefile. linked_dtb.S is also moved into boot/dts/ since it's used
by rules that were moved.

Cc: Mark Salter <[email protected]>
Cc: Aurelien Jacquiot <[email protected]>
Cc: [email protected]
Signed-off-by: Stephen Warren <[email protected]>
---
v7: New patch.
---
arch/c6x/Makefile | 2 +-
arch/c6x/boot/Makefile | 20 --------------------
arch/c6x/boot/{ => dts}/Makefile | 14 ++------------
arch/c6x/boot/dts/linked_dtb.S | 2 ++
arch/c6x/boot/linked_dtb.S | 2 --
5 files changed, 5 insertions(+), 35 deletions(-)
copy arch/c6x/boot/{ => dts}/Makefile (50%)
create mode 100644 arch/c6x/boot/dts/linked_dtb.S
delete mode 100644 arch/c6x/boot/linked_dtb.S

diff --git a/arch/c6x/Makefile b/arch/c6x/Makefile
index a9eb959..e72eb34 100644
--- a/arch/c6x/Makefile
+++ b/arch/c6x/Makefile
@@ -41,7 +41,7 @@ DTB:=$(subst dtbImage.,,$(filter dtbImage.%, $(MAKECMDGOALS)))
export DTB

ifneq ($(DTB),)
-core-y += $(boot)/
+core-y += $(boot)/dts/
endif

# With make 3.82 we cannot mix normal and wildcard targets
diff --git a/arch/c6x/boot/Makefile b/arch/c6x/boot/Makefile
index 6891257..8734abe 100644
--- a/arch/c6x/boot/Makefile
+++ b/arch/c6x/boot/Makefile
@@ -6,25 +6,5 @@ OBJCOPYFLAGS_vmlinux.bin := -O binary
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)

-DTC_FLAGS ?= -p 1024
-
-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)
-
-# Generate builtin.dtb from $(DTB).dtb
-$(obj)/builtin.dtb: $(obj)/$(DTB).dtb
- $(call if_changed,cp)
-
-$(obj)/linked_dtb.o: $(obj)/builtin.dtb
-
$(obj)/dtbImage.%: vmlinux
$(call if_changed,objcopy)
-
-clean-files := $(obj)/*.dtb
diff --git a/arch/c6x/boot/Makefile b/arch/c6x/boot/dts/Makefile
similarity index 50%
copy from arch/c6x/boot/Makefile
copy to arch/c6x/boot/dts/Makefile
index 6891257..c7528b0 100644
--- a/arch/c6x/boot/Makefile
+++ b/arch/c6x/boot/dts/Makefile
@@ -1,20 +1,13 @@
#
-# Makefile for bootable kernel images
+# Makefile for device trees
#

-OBJCOPYFLAGS_vmlinux.bin := -O binary
-$(obj)/vmlinux.bin: vmlinux FORCE
- $(call if_changed,objcopy)
-
DTC_FLAGS ?= -p 1024

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)

@@ -24,7 +17,4 @@ $(obj)/builtin.dtb: $(obj)/$(DTB).dtb

$(obj)/linked_dtb.o: $(obj)/builtin.dtb

-$(obj)/dtbImage.%: vmlinux
- $(call if_changed,objcopy)
-
-clean-files := $(obj)/*.dtb
+clean-files := *.dtb
diff --git a/arch/c6x/boot/dts/linked_dtb.S b/arch/c6x/boot/dts/linked_dtb.S
new file mode 100644
index 0000000..cf347f1
--- /dev/null
+++ b/arch/c6x/boot/dts/linked_dtb.S
@@ -0,0 +1,2 @@
+.section __fdt_blob,"a"
+.incbin "arch/c6x/boot/dts/builtin.dtb"
diff --git a/arch/c6x/boot/linked_dtb.S b/arch/c6x/boot/linked_dtb.S
deleted file mode 100644
index 57a4454..0000000
--- a/arch/c6x/boot/linked_dtb.S
+++ /dev/null
@@ -1,2 +0,0 @@
-.section __fdt_blob,"a"
-.incbin "arch/c6x/boot/builtin.dtb"
--
1.7.10.4

2012-11-27 23:29:42

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 6/7] microblaze: use new common dtc rule

From: Stephen Warren <[email protected]>

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

This requires moving parts of arch/microblaze/boot/Makefile into newly
created arch/microblaze/boot/dts/Makefile, and updating
arch/microblaze/Makefile to call the new Makefile. linked_dtb.S is also
moved into boot/dts/ since it's used by rules that were moved.

Cc: Michal Simek <[email protected]>
Cc: [email protected]
Signed-off-by: Stephen Warren <[email protected]>
---
v7: New patch.
---
arch/microblaze/Makefile | 2 +-
arch/microblaze/boot/Makefile | 19 +------------------
arch/microblaze/boot/dts/Makefile | 22 ++++++++++++++++++++++
arch/microblaze/boot/dts/linked_dtb.S | 2 ++
arch/microblaze/boot/linked_dtb.S | 3 ---
5 files changed, 26 insertions(+), 22 deletions(-)
create mode 100644 arch/microblaze/boot/dts/Makefile
create mode 100644 arch/microblaze/boot/dts/linked_dtb.S
delete mode 100644 arch/microblaze/boot/linked_dtb.S

diff --git a/arch/microblaze/Makefile b/arch/microblaze/Makefile
index b23c40e..d26fb90 100644
--- a/arch/microblaze/Makefile
+++ b/arch/microblaze/Makefile
@@ -57,7 +57,7 @@ boot := arch/microblaze/boot
DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))

ifneq ($(DTB),)
- core-y += $(boot)/
+ core-y += $(boot)/dts/
endif

# defines filename extension depending memory management type
diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
index fa83ea4..80fe54f 100644
--- a/arch/microblaze/boot/Makefile
+++ b/arch/microblaze/boot/Makefile
@@ -2,21 +2,10 @@
# arch/microblaze/boot/Makefile
#

-obj-y += linked_dtb.o
-
targets := linux.bin linux.bin.gz simpleImage.%

OBJCOPYFLAGS := -R .note -R .comment -R .note.gnu.build-id -O binary

-# Ensure system.dtb exists
-$(obj)/linked_dtb.o: $(obj)/system.dtb
-
-# Generate system.dtb from $(DTB).dtb
-ifneq ($(DTB),system)
-$(obj)/system.dtb: $(obj)/$(DTB).dtb
- $(call if_changed,cp)
-endif
-
$(obj)/linux.bin: vmlinux FORCE
$(call if_changed,objcopy)
$(call if_changed,uimage)
@@ -45,10 +34,4 @@ $(obj)/simpleImage.%: vmlinux FORCE
@echo 'Kernel: $@ is ready' ' (#'`cat .version`')'


-# Rule to build device tree blobs
-DTC_FLAGS := -p 1024
-
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
- $(call if_changed_dep,dtc)
-
-clean-files += *.dtb simpleImage.*.unstrip linux.bin.ub
+clean-files += simpleImage.*.unstrip linux.bin.ub
diff --git a/arch/microblaze/boot/dts/Makefile b/arch/microblaze/boot/dts/Makefile
new file mode 100644
index 0000000..c3b3a5d
--- /dev/null
+++ b/arch/microblaze/boot/dts/Makefile
@@ -0,0 +1,22 @@
+#
+# arch/microblaze/boot/Makefile
+#
+
+obj-y += linked_dtb.o
+
+# Ensure system.dtb exists
+$(obj)/linked_dtb.o: $(obj)/system.dtb
+
+# Generate system.dtb from $(DTB).dtb
+ifneq ($(DTB),system)
+$(obj)/system.dtb: $(obj)/$(DTB).dtb
+ $(call if_changed,cp)
+endif
+
+quiet_cmd_cp = CP $< $@$2
+ cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
+
+# Rule to build device tree blobs
+DTC_FLAGS := -p 1024
+
+clean-files += *.dtb
diff --git a/arch/microblaze/boot/dts/linked_dtb.S b/arch/microblaze/boot/dts/linked_dtb.S
new file mode 100644
index 0000000..23345af
--- /dev/null
+++ b/arch/microblaze/boot/dts/linked_dtb.S
@@ -0,0 +1,2 @@
+.section __fdt_blob,"a"
+.incbin "arch/microblaze/boot/dts/system.dtb"
diff --git a/arch/microblaze/boot/linked_dtb.S b/arch/microblaze/boot/linked_dtb.S
deleted file mode 100644
index cb2b537..0000000
--- a/arch/microblaze/boot/linked_dtb.S
+++ /dev/null
@@ -1,3 +0,0 @@
-.section __fdt_blob,"a"
-.incbin "arch/microblaze/boot/system.dtb"
-
--
1.7.10.4

2012-11-27 23:30:01

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 7/7] xtensa: use new common dtc rule

From: Stephen Warren <[email protected]>

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

This requires moving parts of arch/xtensa/boot/Makefile into newly
created arch/xtensa/boot/dts/Makefile, and updating arch/xtensa/Makefile
to call the new Makefile.

Cc: Chris Zankel <[email protected]>
Cc: Max Filippov <[email protected]>
Cc: [email protected]
Signed-off-by: Stephen Warren <[email protected]>
---
v7: New patch.
---
arch/xtensa/Makefile | 4 ++--
arch/xtensa/boot/Makefile | 10 ----------
arch/xtensa/boot/dts/Makefile | 13 +++++++++++++
3 files changed, 15 insertions(+), 12 deletions(-)
create mode 100644 arch/xtensa/boot/dts/Makefile

diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index b8eb819..b0646fd 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -80,7 +80,7 @@ core-y += $(buildvar) $(buildplf)

libs-y += arch/xtensa/lib/ $(LIBGCC)

-core-$(CONFIG_BUILTIN_DTB_BOOL) += arch/xtensa/boot/
+core-$(CONFIG_BUILTIN_DTB_BOOL) += arch/xtensa/boot/dts/

boot := arch/xtensa/boot

@@ -92,7 +92,7 @@ zImage: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $@

%.dtb:
- $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
+ $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@

define archhelp
@echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)'
diff --git a/arch/xtensa/boot/Makefile b/arch/xtensa/boot/Makefile
index 5d21c21..6be27fb 100644
--- a/arch/xtensa/boot/Makefile
+++ b/arch/xtensa/boot/Makefile
@@ -25,16 +25,6 @@ bootdir-$(CONFIG_XTENSA_PLATFORM_ISS) += boot-elf
bootdir-$(CONFIG_XTENSA_PLATFORM_XT2000) += boot-redboot boot-elf boot-uboot
bootdir-$(CONFIG_XTENSA_PLATFORM_XTAVNET)+= boot-redboot boot-elf boot-uboot

-
-BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB)).dtb.o
-obj-$(CONFIG_BUILTIN_DTB_BOOL) += $(BUILTIN_DTB)
-
-# Rule to build device tree blobs
-$(obj)/%.dtb: $(src)/dts/%.dts FORCE
- $(call if_changed_dep,dtc)
-
-clean-files := *.dtb.S
-
zImage Image: $(bootdir-y)

$(bootdir-y): $(addprefix $(obj)/,$(subdir-y)) \
diff --git a/arch/xtensa/boot/dts/Makefile b/arch/xtensa/boot/dts/Makefile
new file mode 100644
index 0000000..0b5581a
--- /dev/null
+++ b/arch/xtensa/boot/dts/Makefile
@@ -0,0 +1,13 @@
+#
+# arch/xtensa/boot/dts/Makefile
+#
+# This file is subject to the terms and conditions of the GNU General Public
+# License. See the file "COPYING" in the main directory of this archive
+# for more details.
+#
+#
+
+BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_BUILTIN_DTB)).dtb.o
+obj-$(CONFIG_BUILTIN_DTB_BOOL) += $(BUILTIN_DTB)
+
+clean-files := *.dtb.S
--
1.7.10.4

2012-11-27 23:31:17

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 4/7] openrisc: use new common dtc rule

From: Stephen Warren <[email protected]>

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 <[email protected]>
Cc: [email protected]
Signed-off-by: Stephen Warren <[email protected]>
---
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

2012-11-27 23:31:58

by Stephen Warren

[permalink] [raw]
Subject: [PATCH V7 2/7] ARM: dt: change .dtb build rules to build in dts directory

From: Grant Likely <[email protected]>

The current rules have the .dtb files build in a different directory
from the .dts files. The only reason for this is that it was what
PowerPC has done historically. This patch changes ARM to use the generic
dtb rule which builds .dtb files in the same directory as the source .dts.

Cc: Russell King <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Olof Johansson <[email protected]>
Cc: [email protected]
Signed-off-by: Grant Likely <[email protected]>
[swarren: added rm command for old stale .dtb files]
Signed-off-by: Stephen Warren <[email protected]>
---
v7: New patch.
---
arch/arm/Makefile | 4 ++--
arch/arm/boot/Makefile | 12 ------------
arch/arm/boot/dts/Makefile | 8 ++++++++
3 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1ec5f67..5f92252 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -291,10 +291,10 @@ zinstall uinstall install: vmlinux
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $@

%.dtb: scripts
- $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
+ $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) $(boot)/dts/$@

dtbs: scripts
- $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
+ $(Q)$(MAKE) $(build)=$(boot)/dts MACHINE=$(MACHINE) dtbs

# We use MRPROPER_FILES and CLEAN_FILES now
archclean:
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 9137df5..abfce28 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -15,8 +15,6 @@ ifneq ($(MACHINE),)
include $(srctree)/$(MACHINE)/Makefile.boot
endif

-include $(srctree)/arch/arm/boot/dts/Makefile
-
# Note: the following conditions must always be true:
# ZRELADDR == virt_to_phys(PAGE_OFFSET + TEXT_OFFSET)
# PARAMS_PHYS must be within 4MB of ZRELADDR
@@ -59,16 +57,6 @@ $(obj)/zImage: $(obj)/compressed/vmlinux FORCE

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
-
ifneq ($(LOADADDR),)
UIMAGE_LOADADDR=$(LOADADDR)
else
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index a17d5ab..cb217f8 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -136,4 +136,12 @@ dtb-$(CONFIG_ARCH_VT8500) += vt8500-bv07.dtb \
wm8650-mid.dtb
dtb-$(CONFIG_ARCH_ZYNQ) += zynq-zc702.dtb

+targets += dtbs
endif
+
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+ # *.dtb used to be generated in the directory above. Clean out the
+ # old build results so people don't accidentally use them.
+ rm -f $(obj)/../*.dtb
+
+clean-files := *.dtb
--
1.7.10.4

2012-11-27 23:50:40

by Olof Johansson

[permalink] [raw]
Subject: Re: [PATCH V7 2/7] ARM: dt: change .dtb build rules to build in dts directory

On Tue, Nov 27, 2012 at 3:29 PM, Stephen Warren <[email protected]> wrote:
> From: Grant Likely <[email protected]>
>
> The current rules have the .dtb files build in a different directory
> from the .dts files. The only reason for this is that it was what
> PowerPC has done historically. This patch changes ARM to use the generic
> dtb rule which builds .dtb files in the same directory as the source .dts.
>
> Cc: Russell King <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Olof Johansson <[email protected]>
> Cc: [email protected]
> Signed-off-by: Grant Likely <[email protected]>
> [swarren: added rm command for old stale .dtb files]
> Signed-off-by: Stephen Warren <[email protected]>

Acked-by: Olof Johansson <[email protected]>

2012-11-28 17:44:35

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

On Tue, Nov 27, 2012 at 11:29:10PM +0000, Stephen Warren wrote:
> From: Stephen Warren <[email protected]>
>
> 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 <[email protected]>
> Cc: [email protected]
> Cc: Olof Johansson <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Catalin Marinas <[email protected]>
> Cc: Jonas Bonn <[email protected]>
> Cc: [email protected]
> Cc: Aurelien Jacquiot <[email protected]>
> Cc: [email protected]
> Cc: Mark Salter <[email protected]>
> Cc: Michal Simek <[email protected]>
> Cc: [email protected]
> Cc: Chris Zankel <[email protected]>
> Cc: [email protected]
> Cc: Max Filippov <[email protected]>
> Signed-off-by: Ralf Baechle <[email protected]>
> Signed-off-by: Stephen Warren <[email protected]>

Acked-by: Catalin Marinas <[email protected]>

2012-11-28 18:09:54

by Mark Salter

[permalink] [raw]
Subject: Re: [PATCH V7 5/7] c6x: use new common dtc rule

On Tue, 2012-11-27 at 16:29 -0700, Stephen Warren wrote:
> From: Stephen Warren <[email protected]>
>
> The current rules have the .dtb files build in a different directory
> from the .dts files. This patch changes c6x to use the generic dtb
> rule which builds .dtb files in the same directory as the source .dts.
>
> This requires moving parts of arch/c6x/boot/Makefile into newly created
> arch/c6x/boot/dts/Makefile, and updating arch/c6x/Makefile to call the
> new Makefile. linked_dtb.S is also moved into boot/dts/ since it's used
> by rules that were moved.
>
> Cc: Mark Salter <[email protected]>
> Cc: Aurelien Jacquiot <[email protected]>
> Cc: [email protected]
> Signed-off-by: Stephen Warren <[email protected]>
> ---

Acked-by: Mark Salter <[email protected]>

2012-11-28 18:33:46

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

On 11/27/2012 04:29 PM, Stephen Warren wrote:
> 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.

Ben, Paul,

Following this patch (http://lkml.org/lkml/2012/11/27/555), I posted a
series of patches to convert almost all architectures to using the
centralized rule. The one architecture I didn't convert was PowerPC.

I didn't convert it because arch/powerpc/boot/Makefile contains a large
number of rules (to generate *Image.% where % is a board name) that
depend on %.dtb, which is expected to be in arch/powerpc/boot rather
than arch/powerpc/boot/dts. Now, I guess it's possible to convert them
all to expect the .dtb files to be in dts/ and also have
arch/powerpc/boot/Makefile call make in boot/dts/ to make each required
.dtb file. However, the patch would be a bit larger than all the other
architecture patches. Do you want me to do that conversion, or would you
rather I leave PowerPC alone? Thanks for any feedback.

2012-11-28 23:34:28

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

On Wed, 2012-11-28 at 11:33 -0700, Stephen Warren wrote:

> Following this patch (http://lkml.org/lkml/2012/11/27/555), I posted a
> series of patches to convert almost all architectures to using the
> centralized rule. The one architecture I didn't convert was PowerPC.
>
> I didn't convert it because arch/powerpc/boot/Makefile contains a large
> number of rules (to generate *Image.% where % is a board name) that
> depend on %.dtb, which is expected to be in arch/powerpc/boot rather
> than arch/powerpc/boot/dts. Now, I guess it's possible to convert them
> all to expect the .dtb files to be in dts/ and also have
> arch/powerpc/boot/Makefile call make in boot/dts/ to make each required
> .dtb file. However, the patch would be a bit larger than all the other
> architecture patches. Do you want me to do that conversion, or would you
> rather I leave PowerPC alone? Thanks for any feedback.

Kumar, any objection to moving the dtb's to arch/powerpc/boot/dtb/ ?
Other than breaking a script or two out there ...

Cheers,
Ben.

2012-11-29 14:30:51

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH V7 3/7] arm64: use new common dtc rule

On Tue, Nov 27, 2012 at 11:29:12PM +0000, Stephen Warren wrote:
> From: Stephen Warren <[email protected]>
>
> The current rules have the .dtb files build in a different directory
> from the .dts files. This patch changes arm64 to use the generic dtb
> rule which builds .dtb files in the same directory as the source .dts.
>
> This requires moving parts of arch/arm64/boot/Makefile into newly created
> arch/arm64/boot/dts/Makefile, and updating arch/arm64/Makefile to call the
> new Makefile.
>
> Cc: Catalin Marinas <[email protected]>
> Cc: [email protected]
> Signed-off-by: Stephen Warren <[email protected]>

I had a bit more clean-up in a local patch (see attached). Depending on
the timing, you can just fold it into your patch (basically removing the
MACHINE argument, adding KBUILD_DTBS and dtbs target help). It's been
derived from your arch/arm patch anyway ;).

--
Catalin


Attachments:
(No filename) (917.00 B)
0001-arm64-Add-dtbs-target-for-building-all-the-enabled-d.patch (2.91 kB)
Download all attachments

2012-11-30 16:01:57

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

On 11/27/2012 05:29 PM, Stephen Warren wrote:
> From: Stephen Warren <[email protected]>
>
> 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 <[email protected]>
> Cc: [email protected]
> Cc: Olof Johansson <[email protected]>
> Cc: Russell King <[email protected]>
> Cc: Catalin Marinas <[email protected]>
> Cc: Jonas Bonn <[email protected]>
> Cc: [email protected]
> Cc: Aurelien Jacquiot <[email protected]>
> Cc: [email protected]
> Cc: Mark Salter <[email protected]>
> Cc: Michal Simek <[email protected]>
> Cc: [email protected]
> Cc: Chris Zankel <[email protected]>
> Cc: [email protected]
> Cc: Max Filippov <[email protected]>
> Signed-off-by: Ralf Baechle <[email protected]>
> Signed-off-by: Stephen Warren <[email protected]>
> ---
> 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

> 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
> # ---------------------------------------------------------------------------
>
>

2012-11-30 19:34:33

by Stephen Warren

[permalink] [raw]
Subject: Re: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

On 11/30/2012 09:01 AM, Rob Herring wrote:
> On 11/27/2012 05:29 PM, Stephen Warren wrote:
>> From: Stephen Warren <[email protected]>
>>
>> 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 <[email protected]>
>> Cc: [email protected]
>> Cc: Olof Johansson <[email protected]>
>> Cc: Russell King <[email protected]>
>> Cc: Catalin Marinas <[email protected]>
>> Cc: Jonas Bonn <[email protected]>
>> Cc: [email protected]
>> Cc: Aurelien Jacquiot <[email protected]>
>> Cc: [email protected]
>> Cc: Mark Salter <[email protected]>
>> Cc: Michal Simek <[email protected]>
>> Cc: [email protected]
>> Cc: Chris Zankel <[email protected]>
>> Cc: [email protected]
>> Cc: Max Filippov <[email protected]>
>> Signed-off-by: Ralf Baechle <[email protected]>
>> Signed-off-by: Stephen Warren <[email protected]>
>> ---
>> 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.

2012-12-01 04:43:23

by Max Filippov

[permalink] [raw]
Subject: Re: [PATCH V7 1/7] kbuild: centralize .dts->.dtb rule

On Fri, Nov 30, 2012 at 8:01 PM, Rob Herring <[email protected]> wrote:

[...]

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