All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] support separate asm-offsets.h for SPL and TPL
@ 2020-04-17  7:21 Masahiro Yamada
  2020-04-17  7:21 ` [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Masahiro Yamada @ 2020-04-17  7:21 UTC (permalink / raw)
  To: u-boot


Bin Meng asked me how to generate correct asm-offsets headers for SPL/TPL.

1/3: fix a bug that I just happened to find when touching this line
2/3: cherry-pick some Kbuild changes. This is a good resync regardless of 3/3
3/3: change as Bin Meng requested. This complicates the build process
     a bit more, but if we want this, just go ahead.


Changes in v2:
  - Check-pick two more while I am here
  - Rebase on the mainline

Masahiro Yamada (3):
  kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o
  kbuild: cherry-pick kbuild changes from Linux
  kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL

 Kbuild                 | 49 +++++-------------------------------------
 Makefile               |  3 +--
 scripts/Kbuild.include | 15 +++++++------
 scripts/Makefile.build | 18 +++++-----------
 scripts/Makefile.host  | 12 -----------
 scripts/Makefile.lib   | 42 ++++++++++++++++++++++++++++--------
 scripts/Makefile.spl   | 13 ++++++++---
 7 files changed, 62 insertions(+), 90 deletions(-)

-- 
2.25.1

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

* [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o
  2020-04-17  7:21 [PATCH v2 0/3] support separate asm-offsets.h for SPL and TPL Masahiro Yamada
@ 2020-04-17  7:21 ` Masahiro Yamada
  2020-04-26 11:27   ` Tom Rini
  2020-04-17  7:21 ` [PATCH v2 2/3] kbuild: cherry-pick kbuild changes from Linux Masahiro Yamada
  2020-04-17  7:21 ` [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL Masahiro Yamada
  2 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2020-04-17  7:21 UTC (permalink / raw)
  To: u-boot

if_changed must have FORCE as a prerequisite.

Add $(obj)/dts/dt-platdata.o to 'targets' so that the corresponding
.cmd file is included.

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

Changes in v2: None

 scripts/Makefile.spl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 5384f21278..4c2c0567c5 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -307,10 +307,11 @@ quiet_cmd_dtoch = DTOC H  $@
 cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct
 
 quiet_cmd_plat = PLAT    $@
-cmd_plat = $(CC) $(c_flags) -c $< -o $@
+cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
 
+targets += $(obj)/dts/dt-platdata.o
 $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \
-		include/generated/dt-structs-gen.h
+		include/generated/dt-structs-gen.h FORCE
 	$(call if_changed,plat)
 
 PHONY += dts_dir
-- 
2.25.1

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

* [PATCH v2 2/3] kbuild: cherry-pick kbuild changes from Linux
  2020-04-17  7:21 [PATCH v2 0/3] support separate asm-offsets.h for SPL and TPL Masahiro Yamada
  2020-04-17  7:21 ` [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o Masahiro Yamada
@ 2020-04-17  7:21 ` Masahiro Yamada
  2020-04-26 11:27   ` Tom Rini
  2020-04-17  7:21 ` [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL Masahiro Yamada
  2 siblings, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2020-04-17  7:21 UTC (permalink / raw)
  To: u-boot

b42841b7bb62 kbuild: Get rid of KBUILD_STR
2aedcd098a94 kbuild: suppress annoying "... is up to date." message
9c8fa9bc08f6 kbuild: fix if_change and friends to consider argument order
ebf003f0cfb3 kbuild: Consolidate header generation from ASM offset information
2982c953570b kbuild: remove redundant $(wildcard ...) for cmd_files calculation
8a78756eb545 kbuild: create object directories simpler and faster
4d4b5c2e3b6e treewide: remove explicit rules for *offsets.s
01d509a48b46 kbuild: remove unimportant comments from ./Kbuild

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

Changes in v2:
  - Check-pick two more while I am here
  - Rebase on the mainline

 Kbuild                 | 45 +++---------------------------------------
 Makefile               |  3 +--
 scripts/Kbuild.include | 15 +++++++-------
 scripts/Makefile.build | 18 +++++------------
 scripts/Makefile.host  | 12 -----------
 scripts/Makefile.lib   | 42 ++++++++++++++++++++++++++++++---------
 6 files changed, 50 insertions(+), 85 deletions(-)

diff --git a/Kbuild b/Kbuild
index e2e3b2995f..6014f7c34a 100644
--- a/Kbuild
+++ b/Kbuild
@@ -1,54 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
 #
 # Kbuild for top-level directory of U-Boot
-# This file takes care of the following:
-# 1) Generate generic-asm-offsets.h
-# 2) Generate asm-offsets.h
-
-# Default sed regexp - multiline due to syntax constraints
-define sed-y
-	"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
-	/^->/{s:->#\(.*\):/* \1 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
-	s:->::; p;}"
-endef
-
-# Use filechk to avoid rebuilds when a header changes, but the resulting file
-# does not
-define filechk_offsets
-	(set -e; \
-	 echo "#ifndef $2"; \
-	 echo "#define $2"; \
-	 echo "/*"; \
-	 echo " * DO NOT MODIFY."; \
-	 echo " *"; \
-	 echo " * This file was generated by Kbuild"; \
-	 echo " */"; \
-	 echo ""; \
-	 sed -ne $(sed-y); \
-	 echo ""; \
-	 echo "#endif" )
-endef
 
 #####
-# 1) Generate generic-asm-offsets.h
+# Generate generic-asm-offsets.h
 
 generic-offsets-file := include/generated/generic-asm-offsets.h
 
 always  := $(generic-offsets-file)
 targets := lib/asm-offsets.s
 
-# We use internal kbuild rules to avoid the "is up to date" message from make
-lib/asm-offsets.s: lib/asm-offsets.c FORCE
-	$(Q)mkdir -p $(dir $@)
-	$(call if_changed_dep,cc_s_c)
-
 $(obj)/$(generic-offsets-file): lib/asm-offsets.s FORCE
 	$(call filechk,offsets,__GENERIC_ASM_OFFSETS_H__)
 
 #####
-# 2) Generate asm-offsets.h
-#
+# Generate asm-offsets.h
 
 ifneq ($(wildcard $(srctree)/arch/$(ARCH)/lib/asm-offsets.c),)
 offsets-file := include/generated/asm-offsets.h
@@ -59,10 +25,5 @@ targets += arch/$(ARCH)/lib/asm-offsets.s
 
 CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY
 
-# We use internal kbuild rules to avoid the "is up to date" message from make
-arch/$(ARCH)/lib/asm-offsets.s: arch/$(ARCH)/lib/asm-offsets.c FORCE
-	$(Q)mkdir -p $(dir $@)
-	$(call if_changed_dep,cc_s_c)
-
 $(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s FORCE
 	$(call filechk,offsets,__ASM_OFFSETS_H__)
diff --git a/Makefile b/Makefile
index 26307fd4a6..7e0ca8ccba 100644
--- a/Makefile
+++ b/Makefile
@@ -2239,8 +2239,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files))
 
 # read all saved command lines
 
-targets := $(wildcard $(sort $(targets)))
-cmd_files := $(wildcard .*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
+cmd_files := $(wildcard .*.cmd $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
 
 ifneq ($(cmd_files),)
   $(cmd_files): ;	# Do not try to update included dependency files
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index cad3b6e76c..dfb67226b0 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -7,6 +7,7 @@ quote   := "
 squote  := '
 empty   :=
 space   := $(empty) $(empty)
+space_escape := _-_SPACE_-_
 pound := \#
 
 ###
@@ -234,10 +235,10 @@ objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
 # See Documentation/kbuild/makefiles.txt for more info
 
 ifneq ($(KBUILD_NOCMDDEP),1)
-# Check if both arguments has same arguments. Result is empty string if equal.
-# User may override this check using make KBUILD_NOCMDDEP=1
-arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
-                    $(filter-out $(cmd_$@),   $(cmd_$(1))) )
+# Check if both arguments are the same including their order. Result is empty
+# string if equal. User may override this check using make KBUILD_NOCMDDEP=1
+arg-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \
+                         $(subst $(space),$(space_escape),$(strip $(cmd_$1))))
 else
 arg-check = $(if $(strip $(cmd_$@)),,1)
 endif
@@ -259,7 +260,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
 if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \
 	@set -e;                                                             \
 	$(echo-cmd) $(cmd_$(1));                                             \
-	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
+	printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
 
 # Execute the command and also postprocess generated .d dependencies file.
 if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
@@ -267,14 +268,14 @@ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \
 	$(echo-cmd) $(cmd_$(1));                                             \
 	scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\
 	rm -f $(depfile);                                                    \
-	mv -f $(dot-target).tmp $(dot-target).cmd)
+	mv -f $(dot-target).tmp $(dot-target).cmd, @:)
 
 # Usage: $(call if_changed_rule,foo)
 # Will check if $(cmd_foo) or any of the prerequisites changed,
 # and if so will execute $(rule_foo).
 if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ),                 \
 	@set -e;                                                             \
-	$(rule_$(1)))
+	$(rule_$(1)), @:)
 
 ###
 # why - tell why a a target got build
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 5e5f1682c9..705a886cb9 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -75,17 +75,6 @@ ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(h
 include scripts/Makefile.host
 endif
 
-# Uncommented for U-Boot
-#  We need to create output dicrectory for SPL and TPL even for in-tree build
-#ifneq ($(KBUILD_SRC),)
-# Create output directory if not already present
-_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
-
-# Create directories for object files if directory does not exist
-# Needed when obj-y := dir/file.o syntax is used
-_dummy := $(foreach d,$(obj-dirs), $(shell [ -d $(d) ] || mkdir -p $(d)))
-#endif
-
 ifndef obj
 $(warning kbuild: Makefile.build is included improperly)
 endif
@@ -441,11 +430,14 @@ FORCE:
 # optimization, we don't need to read them if the target does not
 # exist, we will rebuild anyway in that case.
 
-targets := $(wildcard $(sort $(targets)))
-cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
+cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
 
 ifneq ($(cmd_files),)
   include $(cmd_files)
 endif
 
+# Create directories for object files if they do not exist
+obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets))))
+$(shell mkdir -p $(obj-dirs))
+
 .PHONY: $(PHONY)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index da2f4d5bfd..69983a19a4 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -53,15 +53,6 @@ host-cxxobjs	:= $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
 host-cshobjs	:= $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
 host-cxxshobjs	:= $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
 
-# output directory for programs/.o files
-# hostprogs-y := tools/build may have been specified.
-# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation
-host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs))
-
-host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
-
-
-__hostprogs     := $(addprefix $(obj)/,$(__hostprogs))
 host-csingle	:= $(addprefix $(obj)/,$(host-csingle))
 host-cmulti	:= $(addprefix $(obj)/,$(host-cmulti))
 host-cobjs	:= $(addprefix $(obj)/,$(host-cobjs))
@@ -72,9 +63,6 @@ host-cxxshlib	:= $(addprefix $(obj)/,$(host-cxxshlib))
 host-cshobjs	:= $(addprefix $(obj)/,$(host-cshobjs))
 host-cxxshobjs	:= $(addprefix $(obj)/,$(host-cxxshobjs))
 host-shared	:= $(addprefix $(obj)/,$(host-shared))
-host-objdirs    := $(addprefix $(obj)/,$(host-objdirs))
-
-obj-dirs += $(host-objdirs)
 
 #####
 # Handle options to gcc. Support building with separate output directory
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 1c8cb7488f..63fbadd757 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -57,15 +57,11 @@ single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
 # objects depend on those (obviously)
 multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y)))
 multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y)))
-multi-objs   := $(multi-objs-y) $(multi-objs-m)
 
 # $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to
 # tell kbuild to descend
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 
-# $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(obj-y))
-
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
 real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
@@ -88,7 +84,6 @@ multi-used-m	:= $(addprefix $(obj)/,$(multi-used-m))
 multi-objs-y	:= $(addprefix $(obj)/,$(multi-objs-y))
 multi-objs-m	:= $(addprefix $(obj)/,$(multi-objs-m))
 subdir-ym	:= $(addprefix $(obj)/,$(subdir-ym))
-obj-dirs	:= $(addprefix $(obj)/,$(obj-dirs))
 
 # These flags are needed for modversions and compiling, so we define them here
 # already
@@ -97,10 +92,10 @@ obj-dirs	:= $(addprefix $(obj)/,$(obj-dirs))
 # Note: Files that end up in two or more modules are compiled without the
 #       KBUILD_MODNAME definition. The reason is that any made-up name would
 #       differ in different configs.
-name-fix = $(subst $(comma),_,$(subst -,_,$1))
-basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
+name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote)
+basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
-                 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
+                 -DKBUILD_MODNAME=$(call name-fix,$(modname)))
 
 orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
                  $(ccflags-y) $(CFLAGS_$(basetarget).o)
@@ -153,7 +148,7 @@ endif
 # Modified for U-Boot: LINUXINCLUDE -> UBOOTINCLUDE
 c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 		 $(__c_flags) $(modkern_cflags)                           \
-		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
+		 $(basename_flags) $(modname_flags)
 
 a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(UBOOTINCLUDE)     \
 		 $(__a_flags) $(modkern_aflags)
@@ -576,3 +571,32 @@ quiet_cmd_fdtgrep = FDTGREP $@
 quiet_cmd_fdt_rm_props = FDTGREP $@
 	cmd_fdt_rm_props = cat $< | $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \
 			$(addprefix -P ,$(subst $\",,$(CONFIG_OF_REMOVE_PROPS)))
+
+# ASM offsets
+# ---------------------------------------------------------------------------
+
+# Default sed regexp - multiline due to syntax constraints
+define sed-offsets
+	"s:[[:space:]]*\.ascii[[:space:]]*\"\(.*\)\":\1:; \
+	/^->/{s:->#\(.*\):/* \1 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
+	s:->::; p;}"
+endef
+
+# Use filechk to avoid rebuilds when a header changes, but the resulting file
+# does not
+define filechk_offsets
+	(set -e; \
+	 echo "#ifndef $2"; \
+	 echo "#define $2"; \
+	 echo "/*"; \
+	 echo " * DO NOT MODIFY."; \
+	 echo " *"; \
+	 echo " * This file was generated by Kbuild"; \
+	 echo " */"; \
+	 echo ""; \
+	 sed -ne $(sed-offsets); \
+	 echo ""; \
+	 echo "#endif" )
+endef
-- 
2.25.1

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-17  7:21 [PATCH v2 0/3] support separate asm-offsets.h for SPL and TPL Masahiro Yamada
  2020-04-17  7:21 ` [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o Masahiro Yamada
  2020-04-17  7:21 ` [PATCH v2 2/3] kbuild: cherry-pick kbuild changes from Linux Masahiro Yamada
@ 2020-04-17  7:21 ` Masahiro Yamada
  2020-04-18 12:37   ` Bin Meng
  2020-04-29 12:48   ` Tom Rini
  2 siblings, 2 replies; 16+ messages in thread
From: Masahiro Yamada @ 2020-04-17  7:21 UTC (permalink / raw)
  To: u-boot

Currently generic-asm-offsets.h and asm-offsets.h are generated based
on U-Boot proper config options. The same asm-offsets headers are used
for building U-Boot SPL/TPL, which causes potential offset mismatch if
U-Boot proper has different config options from U-Boot SPL/TPL.

This commit adds:
  spl/include/generated/(generic-)asm-offsets.h
  tpl/include/generated/(generic-)asm-offsets.h

spl/include/generated/(generic-)asm-offsets.h is generated if
CONFIG_SPL=y, and included when building SPL.

tpl/include/generated/(generic-)asm-offsets.h is generated if
CONFIG_TPL=y, and included when building TPL.

They are created before Kbuild descends into SPL/TPL object directories
and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
includes a bunch of headers.

Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
is searched in {spl,tpl}/include/generated/.

Requested-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

Changes in v2: None

 Kbuild               |  4 ++--
 scripts/Makefile.spl | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Kbuild b/Kbuild
index 6014f7c34a..1eac091594 100644
--- a/Kbuild
+++ b/Kbuild
@@ -10,7 +10,7 @@ generic-offsets-file := include/generated/generic-asm-offsets.h
 always  := $(generic-offsets-file)
 targets := lib/asm-offsets.s
 
-$(obj)/$(generic-offsets-file): lib/asm-offsets.s FORCE
+$(obj)/$(generic-offsets-file): $(obj)/lib/asm-offsets.s FORCE
 	$(call filechk,offsets,__GENERIC_ASM_OFFSETS_H__)
 
 #####
@@ -25,5 +25,5 @@ targets += arch/$(ARCH)/lib/asm-offsets.s
 
 CFLAGS_asm-offsets.o := -DDO_DEPS_ONLY
 
-$(obj)/$(offsets-file): arch/$(ARCH)/lib/asm-offsets.s FORCE
+$(obj)/$(offsets-file): $(obj)/arch/$(ARCH)/lib/asm-offsets.s FORCE
 	$(call filechk,offsets,__ASM_OFFSETS_H__)
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 4c2c0567c5..6741ef911e 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -22,6 +22,8 @@ include $(srctree)/scripts/Kbuild.include
 -include include/config/auto.conf
 -include $(obj)/include/autoconf.mk
 
+UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
+
 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
 ifeq ($(CONFIG_TPL_BUILD),y)
 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
@@ -311,7 +313,7 @@ cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
 
 targets += $(obj)/dts/dt-platdata.o
 $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \
-		include/generated/dt-structs-gen.h FORCE
+		include/generated/dt-structs-gen.h prepare FORCE
 	$(call if_changed,plat)
 
 PHONY += dts_dir
@@ -422,9 +424,13 @@ $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \
 $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
 
 PHONY += $(u-boot-spl-dirs)
-$(u-boot-spl-dirs): $(u-boot-spl-platdata)
+$(u-boot-spl-dirs): $(u-boot-spl-platdata) prepare
 	$(Q)$(MAKE) $(build)=$@
 
+PHONY += prepare
+prepare:
+	$(Q)$(MAKE) $(build)=$(obj)/.
+
 quiet_cmd_cpp_lds = LDS     $@
 cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
 		-D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
-- 
2.25.1

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-17  7:21 ` [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL Masahiro Yamada
@ 2020-04-18 12:37   ` Bin Meng
  2020-04-27  1:37     ` Bin Meng
  2020-04-29 12:48   ` Tom Rini
  1 sibling, 1 reply; 16+ messages in thread
From: Bin Meng @ 2020-04-18 12:37 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Currently generic-asm-offsets.h and asm-offsets.h are generated based
> on U-Boot proper config options. The same asm-offsets headers are used
> for building U-Boot SPL/TPL, which causes potential offset mismatch if
> U-Boot proper has different config options from U-Boot SPL/TPL.
>
> This commit adds:
>   spl/include/generated/(generic-)asm-offsets.h
>   tpl/include/generated/(generic-)asm-offsets.h
>
> spl/include/generated/(generic-)asm-offsets.h is generated if
> CONFIG_SPL=y, and included when building SPL.
>
> tpl/include/generated/(generic-)asm-offsets.h is generated if
> CONFIG_TPL=y, and included when building TPL.
>
> They are created before Kbuild descends into SPL/TPL object directories
> and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> includes a bunch of headers.
>
> Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> is searched in {spl,tpl}/include/generated/.
>
> Requested-by: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> Changes in v2: None
>
>  Kbuild               |  4 ++--
>  scripts/Makefile.spl | 10 ++++++++--
>  2 files changed, 10 insertions(+), 4 deletions(-)
>

It works like a charm. Thanks!

Tested-by: Bin Meng <bmeng.cn@gmail.com>

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

* [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o
  2020-04-17  7:21 ` [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o Masahiro Yamada
@ 2020-04-26 11:27   ` Tom Rini
  0 siblings, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-04-26 11:27 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 17, 2020 at 04:21:35PM +0900, Masahiro Yamada wrote:

> if_changed must have FORCE as a prerequisite.
> 
> Add $(obj)/dts/dt-platdata.o to 'targets' so that the corresponding
> .cmd file is included.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200426/7ed82a19/attachment.sig>

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

* [PATCH v2 2/3] kbuild: cherry-pick kbuild changes from Linux
  2020-04-17  7:21 ` [PATCH v2 2/3] kbuild: cherry-pick kbuild changes from Linux Masahiro Yamada
@ 2020-04-26 11:27   ` Tom Rini
  0 siblings, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-04-26 11:27 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 17, 2020 at 04:21:36PM +0900, Masahiro Yamada wrote:

> b42841b7bb62 kbuild: Get rid of KBUILD_STR
> 2aedcd098a94 kbuild: suppress annoying "... is up to date." message
> 9c8fa9bc08f6 kbuild: fix if_change and friends to consider argument order
> ebf003f0cfb3 kbuild: Consolidate header generation from ASM offset information
> 2982c953570b kbuild: remove redundant $(wildcard ...) for cmd_files calculation
> 8a78756eb545 kbuild: create object directories simpler and faster
> 4d4b5c2e3b6e treewide: remove explicit rules for *offsets.s
> 01d509a48b46 kbuild: remove unimportant comments from ./Kbuild
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200426/ffaf1c50/attachment.sig>

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-18 12:37   ` Bin Meng
@ 2020-04-27  1:37     ` Bin Meng
  2020-04-27 13:36       ` Tom Rini
  0 siblings, 1 reply; 16+ messages in thread
From: Bin Meng @ 2020-04-27  1:37 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > on U-Boot proper config options. The same asm-offsets headers are used
> > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > U-Boot proper has different config options from U-Boot SPL/TPL.
> >
> > This commit adds:
> >   spl/include/generated/(generic-)asm-offsets.h
> >   tpl/include/generated/(generic-)asm-offsets.h
> >
> > spl/include/generated/(generic-)asm-offsets.h is generated if
> > CONFIG_SPL=y, and included when building SPL.
> >
> > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > CONFIG_TPL=y, and included when building TPL.
> >
> > They are created before Kbuild descends into SPL/TPL object directories
> > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > includes a bunch of headers.
> >
> > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > is searched in {spl,tpl}/include/generated/.
> >
> > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> > Changes in v2: None
> >
> >  Kbuild               |  4 ++--
> >  scripts/Makefile.spl | 10 ++++++++--
> >  2 files changed, 10 insertions(+), 4 deletions(-)
> >
>
> It works like a charm. Thanks!
>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>

It looks only patch 1 and 2 in this series were applied. This patch was missed.

Regards,
Bin

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-27  1:37     ` Bin Meng
@ 2020-04-27 13:36       ` Tom Rini
  2020-04-27 14:50         ` Bin Meng
  0 siblings, 1 reply; 16+ messages in thread
From: Tom Rini @ 2020-04-27 13:36 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> Hi Tom,
> 
> On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > >
> > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > on U-Boot proper config options. The same asm-offsets headers are used
> > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > >
> > > This commit adds:
> > >   spl/include/generated/(generic-)asm-offsets.h
> > >   tpl/include/generated/(generic-)asm-offsets.h
> > >
> > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > CONFIG_SPL=y, and included when building SPL.
> > >
> > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > CONFIG_TPL=y, and included when building TPL.
> > >
> > > They are created before Kbuild descends into SPL/TPL object directories
> > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > includes a bunch of headers.
> > >
> > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > is searched in {spl,tpl}/include/generated/.
> > >
> > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > ---
> > >
> > > Changes in v2: None
> > >
> > >  Kbuild               |  4 ++--
> > >  scripts/Makefile.spl | 10 ++++++++--
> > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > >
> >
> > It works like a charm. Thanks!
> >
> > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> 
> It looks only patch 1 and 2 in this series were applied. This patch was missed.

So, I was going to ask and forgot, sorry.  Why do we need to have these
differ between TPL/SPL/U-Boot itself, and then why is that good?  I
thought this was something we wanted to ensure was consistent from stage
to stage to facilitate sharing of information.  But I also am happy to
assume I just missed an explanation along the way.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200427/4083a6fb/attachment.sig>

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-27 13:36       ` Tom Rini
@ 2020-04-27 14:50         ` Bin Meng
  2020-04-28 14:46           ` Tom Rini
  0 siblings, 1 reply; 16+ messages in thread
From: Bin Meng @ 2020-04-27 14:50 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On Mon, Apr 27, 2020 at 9:37 PM Tom Rini <trini@konsulko.com> wrote:
>
> On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > Hi Tom,
> >
> > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> > >
> > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > >
> > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > >
> > > > This commit adds:
> > > >   spl/include/generated/(generic-)asm-offsets.h
> > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > >
> > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > CONFIG_SPL=y, and included when building SPL.
> > > >
> > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > CONFIG_TPL=y, and included when building TPL.
> > > >
> > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > includes a bunch of headers.
> > > >
> > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > is searched in {spl,tpl}/include/generated/.
> > > >
> > > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > ---
> > > >
> > > > Changes in v2: None
> > > >
> > > >  Kbuild               |  4 ++--
> > > >  scripts/Makefile.spl | 10 ++++++++--
> > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > >
> > >
> > > It works like a charm. Thanks!
> > >
> > > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > It looks only patch 1 and 2 in this series were applied. This patch was missed.
>
> So, I was going to ask and forgot, sorry.  Why do we need to have these
> differ between TPL/SPL/U-Boot itself, and then why is that good?  I

Because currently the offsets
{spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
the U-Boot config options. But SPL and TPL are not guaranteed to have
the same config options.

For example it's possible to have SPL/TPL turned on
{SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.

To me this is more like a bug fix other than a feature.

> thought this was something we wanted to ensure was consistent from stage
> to stage to facilitate sharing of information.  But I also am happy to
> assume I just missed an explanation along the way.  Thanks!

Regards,
Bin

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-27 14:50         ` Bin Meng
@ 2020-04-28 14:46           ` Tom Rini
  2020-04-28 15:01             ` Bin Meng
  0 siblings, 1 reply; 16+ messages in thread
From: Tom Rini @ 2020-04-28 14:46 UTC (permalink / raw)
  To: u-boot

On Mon, Apr 27, 2020 at 10:50:48PM +0800, Bin Meng wrote:
> Hi Tom,
> 
> On Mon, Apr 27, 2020 at 9:37 PM Tom Rini <trini@konsulko.com> wrote:
> >
> > On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > > Hi Tom,
> > >
> > > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> > > >
> > > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > > >
> > > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > > >
> > > > > This commit adds:
> > > > >   spl/include/generated/(generic-)asm-offsets.h
> > > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > > >
> > > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > CONFIG_SPL=y, and included when building SPL.
> > > > >
> > > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > CONFIG_TPL=y, and included when building TPL.
> > > > >
> > > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > > includes a bunch of headers.
> > > > >
> > > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > > is searched in {spl,tpl}/include/generated/.
> > > > >
> > > > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > > ---
> > > > >
> > > > > Changes in v2: None
> > > > >
> > > > >  Kbuild               |  4 ++--
> > > > >  scripts/Makefile.spl | 10 ++++++++--
> > > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > > >
> > > >
> > > > It works like a charm. Thanks!
> > > >
> > > > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> > >
> > > It looks only patch 1 and 2 in this series were applied. This patch was missed.
> >
> > So, I was going to ask and forgot, sorry.  Why do we need to have these
> > differ between TPL/SPL/U-Boot itself, and then why is that good?  I
> 
> Because currently the offsets
> {spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
> the U-Boot config options. But SPL and TPL are not guaranteed to have
> the same config options.
> 
> For example it's possible to have SPL/TPL turned on
> {SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.
> 
> To me this is more like a bug fix other than a feature.

Ah, OK.  But shouldn't we make sure that asm-offsets are consistent
between SPL/TPL/U-Boot?  Or is there a use-case where it makes sense for
them to differ intentionally?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200428/e1545c90/attachment.sig>

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-28 14:46           ` Tom Rini
@ 2020-04-28 15:01             ` Bin Meng
  2020-04-28 15:14               ` Tom Rini
  2020-04-28 15:20               ` Masahiro Yamada
  0 siblings, 2 replies; 16+ messages in thread
From: Bin Meng @ 2020-04-28 15:01 UTC (permalink / raw)
  To: u-boot

Hi Tom,

On Tue, Apr 28, 2020 at 10:46 PM Tom Rini <trini@konsulko.com> wrote:
>
> On Mon, Apr 27, 2020 at 10:50:48PM +0800, Bin Meng wrote:
> > Hi Tom,
> >
> > On Mon, Apr 27, 2020 at 9:37 PM Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > > > Hi Tom,
> > > >
> > > > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> > > > >
> > > > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > > > >
> > > > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > > > >
> > > > > > This commit adds:
> > > > > >   spl/include/generated/(generic-)asm-offsets.h
> > > > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > > > >
> > > > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > CONFIG_SPL=y, and included when building SPL.
> > > > > >
> > > > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > CONFIG_TPL=y, and included when building TPL.
> > > > > >
> > > > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > > > includes a bunch of headers.
> > > > > >
> > > > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > > > is searched in {spl,tpl}/include/generated/.
> > > > > >
> > > > > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > > > ---
> > > > > >
> > > > > > Changes in v2: None
> > > > > >
> > > > > >  Kbuild               |  4 ++--
> > > > > >  scripts/Makefile.spl | 10 ++++++++--
> > > > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > > > >
> > > > >
> > > > > It works like a charm. Thanks!
> > > > >
> > > > > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> > > >
> > > > It looks only patch 1 and 2 in this series were applied. This patch was missed.
> > >
> > > So, I was going to ask and forgot, sorry.  Why do we need to have these
> > > differ between TPL/SPL/U-Boot itself, and then why is that good?  I
> >
> > Because currently the offsets
> > {spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
> > the U-Boot config options. But SPL and TPL are not guaranteed to have
> > the same config options.
> >
> > For example it's possible to have SPL/TPL turned on
> > {SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.
> >
> > To me this is more like a bug fix other than a feature.
>
> Ah, OK.  But shouldn't we make sure that asm-offsets are consistent
> between SPL/TPL/U-Boot?  Or is there a use-case where it makes sense for
> them to differ intentionally?

I don't know other boards, but for now RISC-V does turn on SPL_SMP in
SPL, but does not turn on SMP in U-Boot S-mode. U-Boot M-mode can
still turn on SMP.

Regards,
Bin

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-28 15:01             ` Bin Meng
@ 2020-04-28 15:14               ` Tom Rini
  2020-04-28 15:20               ` Masahiro Yamada
  1 sibling, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-04-28 15:14 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 28, 2020 at 11:01:12PM +0800, Bin Meng wrote:
> Hi Tom,
> 
> On Tue, Apr 28, 2020 at 10:46 PM Tom Rini <trini@konsulko.com> wrote:
> >
> > On Mon, Apr 27, 2020 at 10:50:48PM +0800, Bin Meng wrote:
> > > Hi Tom,
> > >
> > > On Mon, Apr 27, 2020 at 9:37 PM Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > > > > Hi Tom,
> > > > >
> > > > > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> > > > > >
> > > > > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > > > > >
> > > > > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > > > > >
> > > > > > > This commit adds:
> > > > > > >   spl/include/generated/(generic-)asm-offsets.h
> > > > > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > > > > >
> > > > > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > > CONFIG_SPL=y, and included when building SPL.
> > > > > > >
> > > > > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > > CONFIG_TPL=y, and included when building TPL.
> > > > > > >
> > > > > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > > > > includes a bunch of headers.
> > > > > > >
> > > > > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > > > > is searched in {spl,tpl}/include/generated/.
> > > > > > >
> > > > > > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > > > > ---
> > > > > > >
> > > > > > > Changes in v2: None
> > > > > > >
> > > > > > >  Kbuild               |  4 ++--
> > > > > > >  scripts/Makefile.spl | 10 ++++++++--
> > > > > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > > > > >
> > > > > >
> > > > > > It works like a charm. Thanks!
> > > > > >
> > > > > > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > >
> > > > > It looks only patch 1 and 2 in this series were applied. This patch was missed.
> > > >
> > > > So, I was going to ask and forgot, sorry.  Why do we need to have these
> > > > differ between TPL/SPL/U-Boot itself, and then why is that good?  I
> > >
> > > Because currently the offsets
> > > {spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
> > > the U-Boot config options. But SPL and TPL are not guaranteed to have
> > > the same config options.
> > >
> > > For example it's possible to have SPL/TPL turned on
> > > {SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.
> > >
> > > To me this is more like a bug fix other than a feature.
> >
> > Ah, OK.  But shouldn't we make sure that asm-offsets are consistent
> > between SPL/TPL/U-Boot?  Or is there a use-case where it makes sense for
> > them to differ intentionally?
> 
> I don't know other boards, but for now RISC-V does turn on SPL_SMP in
> SPL, but does not turn on SMP in U-Boot S-mode. U-Boot M-mode can
> still turn on SMP.

OK.  I'd really like to have it confirmed that it's a good idea to have
that value differ between the modes and it's not a bug that should be
fixed.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200428/4d265674/attachment.sig>

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-28 15:01             ` Bin Meng
  2020-04-28 15:14               ` Tom Rini
@ 2020-04-28 15:20               ` Masahiro Yamada
  2020-04-28 19:44                 ` Tom Rini
  1 sibling, 1 reply; 16+ messages in thread
From: Masahiro Yamada @ 2020-04-28 15:20 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 29, 2020 at 12:01 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Tom,
>
> On Tue, Apr 28, 2020 at 10:46 PM Tom Rini <trini@konsulko.com> wrote:
> >
> > On Mon, Apr 27, 2020 at 10:50:48PM +0800, Bin Meng wrote:
> > > Hi Tom,
> > >
> > > On Mon, Apr 27, 2020 at 9:37 PM Tom Rini <trini@konsulko.com> wrote:
> > > >
> > > > On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > > > > Hi Tom,
> > > > >
> > > > > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> > > > > >
> > > > > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > > > > >
> > > > > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > > > > >
> > > > > > > This commit adds:
> > > > > > >   spl/include/generated/(generic-)asm-offsets.h
> > > > > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > > > > >
> > > > > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > > CONFIG_SPL=y, and included when building SPL.
> > > > > > >
> > > > > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > > CONFIG_TPL=y, and included when building TPL.
> > > > > > >
> > > > > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > > > > includes a bunch of headers.
> > > > > > >
> > > > > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > > > > is searched in {spl,tpl}/include/generated/.
> > > > > > >
> > > > > > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > > > > ---
> > > > > > >
> > > > > > > Changes in v2: None
> > > > > > >
> > > > > > >  Kbuild               |  4 ++--
> > > > > > >  scripts/Makefile.spl | 10 ++++++++--
> > > > > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > > > > >
> > > > > >
> > > > > > It works like a charm. Thanks!
> > > > > >
> > > > > > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > >
> > > > > It looks only patch 1 and 2 in this series were applied. This patch was missed.
> > > >
> > > > So, I was going to ask and forgot, sorry.  Why do we need to have these
> > > > differ between TPL/SPL/U-Boot itself, and then why is that good?  I
> > >
> > > Because currently the offsets
> > > {spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
> > > the U-Boot config options. But SPL and TPL are not guaranteed to have
> > > the same config options.
> > >
> > > For example it's possible to have SPL/TPL turned on
> > > {SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.
> > >
> > > To me this is more like a bug fix other than a feature.
> >
> > Ah, OK.  But shouldn't we make sure that asm-offsets are consistent
> > between SPL/TPL/U-Boot?  Or is there a use-case where it makes sense for
> > them to differ intentionally?


Maybe, save memory for SPL/TPL ?
We can say "do not do that", but it is fragile.

People are adding #ifdef around to all sort of structs,
and it is difficult to guess which ones are used to
construct asm-offsets.



-- 
Best Regards
Masahiro Yamada

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-28 15:20               ` Masahiro Yamada
@ 2020-04-28 19:44                 ` Tom Rini
  0 siblings, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-04-28 19:44 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 29, 2020 at 12:20:46AM +0900, Masahiro Yamada wrote:
> On Wed, Apr 29, 2020 at 12:01 AM Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Tom,
> >
> > On Tue, Apr 28, 2020 at 10:46 PM Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Mon, Apr 27, 2020 at 10:50:48PM +0800, Bin Meng wrote:
> > > > Hi Tom,
> > > >
> > > > On Mon, Apr 27, 2020 at 9:37 PM Tom Rini <trini@konsulko.com> wrote:
> > > > >
> > > > > On Mon, Apr 27, 2020 at 09:37:28AM +0800, Bin Meng wrote:
> > > > > > Hi Tom,
> > > > > >
> > > > > > On Sat, Apr 18, 2020 at 8:37 PM Bin Meng <bmeng.cn@gmail.com> wrote:
> > > > > > >
> > > > > > > On Fri, Apr 17, 2020 at 3:22 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > > > > > > >
> > > > > > > > Currently generic-asm-offsets.h and asm-offsets.h are generated based
> > > > > > > > on U-Boot proper config options. The same asm-offsets headers are used
> > > > > > > > for building U-Boot SPL/TPL, which causes potential offset mismatch if
> > > > > > > > U-Boot proper has different config options from U-Boot SPL/TPL.
> > > > > > > >
> > > > > > > > This commit adds:
> > > > > > > >   spl/include/generated/(generic-)asm-offsets.h
> > > > > > > >   tpl/include/generated/(generic-)asm-offsets.h
> > > > > > > >
> > > > > > > > spl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > > > CONFIG_SPL=y, and included when building SPL.
> > > > > > > >
> > > > > > > > tpl/include/generated/(generic-)asm-offsets.h is generated if
> > > > > > > > CONFIG_TPL=y, and included when building TPL.
> > > > > > > >
> > > > > > > > They are created before Kbuild descends into SPL/TPL object directories
> > > > > > > > and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> > > > > > > > includes a bunch of headers.
> > > > > > > >
> > > > > > > > Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> > > > > > > > is searched in {spl,tpl}/include/generated/.
> > > > > > > >
> > > > > > > > Requested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > > > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > > > > > > > ---
> > > > > > > >
> > > > > > > > Changes in v2: None
> > > > > > > >
> > > > > > > >  Kbuild               |  4 ++--
> > > > > > > >  scripts/Makefile.spl | 10 ++++++++--
> > > > > > > >  2 files changed, 10 insertions(+), 4 deletions(-)
> > > > > > > >
> > > > > > >
> > > > > > > It works like a charm. Thanks!
> > > > > > >
> > > > > > > Tested-by: Bin Meng <bmeng.cn@gmail.com>
> > > > > >
> > > > > > It looks only patch 1 and 2 in this series were applied. This patch was missed.
> > > > >
> > > > > So, I was going to ask and forgot, sorry.  Why do we need to have these
> > > > > differ between TPL/SPL/U-Boot itself, and then why is that good?  I
> > > >
> > > > Because currently the offsets
> > > > {spl,tpl}/include/generated/(generic-)asm-offsets.h are generated per
> > > > the U-Boot config options. But SPL and TPL are not guaranteed to have
> > > > the same config options.
> > > >
> > > > For example it's possible to have SPL/TPL turned on
> > > > {SPL,TPL}_CONFIG_XXX but U-Boot to turn off CONFIG_XXX, or vice verse.
> > > >
> > > > To me this is more like a bug fix other than a feature.
> > >
> > > Ah, OK.  But shouldn't we make sure that asm-offsets are consistent
> > > between SPL/TPL/U-Boot?  Or is there a use-case where it makes sense for
> > > them to differ intentionally?
> 
> Maybe, save memory for SPL/TPL ?
> We can say "do not do that", but it is fragile.
> 
> People are adding #ifdef around to all sort of structs,
> and it is difficult to guess which ones are used to
> construct asm-offsets.

So, you're right.  I'm doing a build now to check the differences, but
fairly often SPL and TPL disagree here, related to malloc and similar it
looks like.  So this is a bug-fix and I'll apply it shortly.  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200428/802957f9/attachment.sig>

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

* [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL
  2020-04-17  7:21 ` [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL Masahiro Yamada
  2020-04-18 12:37   ` Bin Meng
@ 2020-04-29 12:48   ` Tom Rini
  1 sibling, 0 replies; 16+ messages in thread
From: Tom Rini @ 2020-04-29 12:48 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 17, 2020 at 04:21:37PM +0900, Masahiro Yamada wrote:

> Currently generic-asm-offsets.h and asm-offsets.h are generated based
> on U-Boot proper config options. The same asm-offsets headers are used
> for building U-Boot SPL/TPL, which causes potential offset mismatch if
> U-Boot proper has different config options from U-Boot SPL/TPL.
> 
> This commit adds:
>   spl/include/generated/(generic-)asm-offsets.h
>   tpl/include/generated/(generic-)asm-offsets.h
> 
> spl/include/generated/(generic-)asm-offsets.h is generated if
> CONFIG_SPL=y, and included when building SPL.
> 
> tpl/include/generated/(generic-)asm-offsets.h is generated if
> CONFIG_TPL=y, and included when building TPL.
> 
> They are created before Kbuild descends into SPL/TPL object directories
> and builds $(obj)/dts/dt-platdata.o because $(obj)/dts/dt-platdata.c
> includes a bunch of headers.
> 
> Prepend -I$(obj)/include to $(UBOOTINCLUDE) so (generic-)asm-offsets.h
> is searched in {spl,tpl}/include/generated/.
> 
> Requested-by: Bin Meng <bmeng.cn@gmail.com>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200429/ff2dc3fa/attachment.sig>

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

end of thread, other threads:[~2020-04-29 12:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17  7:21 [PATCH v2 0/3] support separate asm-offsets.h for SPL and TPL Masahiro Yamada
2020-04-17  7:21 ` [PATCH v2 1/3] kbuild: add FORCE to dependency of $(obj)/dts/dt-platdata.o Masahiro Yamada
2020-04-26 11:27   ` Tom Rini
2020-04-17  7:21 ` [PATCH v2 2/3] kbuild: cherry-pick kbuild changes from Linux Masahiro Yamada
2020-04-26 11:27   ` Tom Rini
2020-04-17  7:21 ` [PATCH v2 3/3] kbuild: SPL/TPL: generate separate asm-offsets.h for SPL and TPL Masahiro Yamada
2020-04-18 12:37   ` Bin Meng
2020-04-27  1:37     ` Bin Meng
2020-04-27 13:36       ` Tom Rini
2020-04-27 14:50         ` Bin Meng
2020-04-28 14:46           ` Tom Rini
2020-04-28 15:01             ` Bin Meng
2020-04-28 15:14               ` Tom Rini
2020-04-28 15:20               ` Masahiro Yamada
2020-04-28 19:44                 ` Tom Rini
2020-04-29 12:48   ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.