Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: add generic support for built-in boot DTBs

Some architectures embed boot DTBs in vmlinux. A potential issue for
these architectures is a race condition during parallel builds because
Kbuild descends into arch/*/boot/dts/ twice.

One build thread is initiated by the 'dtbs' target, which is a
prerequisite of the 'all' target in the top-level Makefile:

ifdef CONFIG_OF_EARLY_FLATTREE
all: dtbs
endif

For architectures that support the built-in boot dtb, arch/*/boot/dts/
is visited also during the ordinary directory traversal in order to
build obj-y objects that wrap DTBs.

Since these build threads are unaware of each other, they can run
simultaneously during parallel builds.

This commit introduces a generic build rule to scripts/Makefile.vmlinux
to support embedded boot DTBs in a race-free way. Architectures that
want to use this rule need to select CONFIG_GENERIC_BUILTIN_DTB.

After the migration, Makefiles under arch/*/boot/dts/ will be visited
only once to build only *.dtb files.

This change also aims to unify the CONFIG options used for built-in DTBs
support. Currently, different architectures use different CONFIG options
for the same purposes.

With this commit, the CONFIG options will be unified as follows:

- CONFIG_GENERIC_BUILTIN_DTB

This enables the generic rule for built-in boot DTBs. This will be
renamed to CONFIG_BUILTIN_DTB after all architectures migrate to the
generic rule.

- CONFIG_BUILTIN_DTB_NAME

This specifies the path to the embedded DTB.
(relative to arch/*/boot/dts/)

- CONFIG_BUILTIN_DTB_ALL

If this is enabled, all DTB files compiled under arch/*/boot/dts/ are
embedded into vmlinux. Only used by MIPS.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+60 -1
+6 -1
Makefile
··· 1433 1433 all: dtbs 1434 1434 endif 1435 1435 1436 + ifdef CONFIG_GENERIC_BUILTIN_DTB 1437 + vmlinux: dtbs 1438 + endif 1439 + 1436 1440 endif 1437 1441 1438 1442 PHONY += scripts_dtc ··· 1504 1500 modules.builtin modules.builtin.modinfo modules.nsdeps \ 1505 1501 modules.builtin.ranges vmlinux.o.map \ 1506 1502 compile_commands.json rust/test \ 1507 - rust-project.json .vmlinux.objs .vmlinux.export.c 1503 + rust-project.json .vmlinux.objs .vmlinux.export.c \ 1504 + .builtin-dtbs-list .builtin-dtb.S 1508 1505 1509 1506 # Directories & files removed with 'make mrproper' 1510 1507 MRPROPER_FILES += include/config include/generated \
+6
drivers/of/Kconfig
··· 2 2 config DTC 3 3 bool 4 4 5 + config GENERIC_BUILTIN_DTB 6 + bool 7 + 8 + config BUILTIN_DTB_ALL 9 + bool 10 + 5 11 menuconfig OF 6 12 bool "Device Tree and Open Firmware support" 7 13 help
+44
scripts/Makefile.vmlinux
··· 17 17 %.o: %.c FORCE 18 18 $(call if_changed_dep,cc_o_c) 19 19 20 + quiet_cmd_as_o_S = AS $@ 21 + cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 22 + 23 + %.o: %.S FORCE 24 + $(call if_changed_dep,as_o_S) 25 + 26 + # Built-in dtb 27 + # --------------------------------------------------------------------------- 28 + 29 + quiet_cmd_wrap_dtbs = WRAP $@ 30 + cmd_wrap_dtbs = { \ 31 + echo '\#include <asm-generic/vmlinux.lds.h>'; \ 32 + echo '.section .dtb.init.rodata,"a"'; \ 33 + while read dtb; do \ 34 + symbase=__dtb_$$(basename -s .dtb "$${dtb}" | tr - _); \ 35 + echo '.balign STRUCT_ALIGNMENT'; \ 36 + echo ".global $${symbase}_begin"; \ 37 + echo "$${symbase}_begin:"; \ 38 + echo '.incbin "'$$dtb'" '; \ 39 + echo ".global $${symbase}_end"; \ 40 + echo "$${symbase}_end:"; \ 41 + done < $<; \ 42 + } > $@ 43 + 44 + .builtin-dtbs.S: .builtin-dtbs-list FORCE 45 + $(call if_changed,wrap_dtbs) 46 + 47 + quiet_cmd_gen_dtbs_list = GEN $@ 48 + cmd_gen_dtbs_list = \ 49 + $(if $(CONFIG_BUILTIN_DTB_NAME), echo "arch/$(SRCARCH)/boot/dts/$(CONFIG_BUILTIN_DTB_NAME).dtb",:) > $@ 50 + 51 + .builtin-dtbs-list: arch/$(SRCARCH)/boot/dts/dtbs-list FORCE 52 + $(call if_changed,$(if $(CONFIG_BUILTIN_DTB_ALL),copy,gen_dtbs_list)) 53 + 54 + targets += .builtin-dtbs-list 55 + 56 + ifdef CONFIG_GENERIC_BUILTIN_DTB 57 + targets += .builtin-dtbs.S .builtin-dtbs.o 58 + vmlinux: .builtin-dtbs.o 59 + endif 60 + 61 + # vmlinux 62 + # --------------------------------------------------------------------------- 63 + 20 64 ifdef CONFIG_MODULES 21 65 targets += .vmlinux.export.o 22 66 vmlinux: .vmlinux.export.o