linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V10 0/5] dt: Add fdtoverlay rule and statically build unittest
@ 2021-03-08 10:45 Viresh Kumar
  2021-03-08 10:45 ` [PATCH V10 1/5] kbuild: Simplify builds with CONFIG_OF_ALL_DTBS Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Viresh Kumar @ 2021-03-08 10:45 UTC (permalink / raw)
  To: Masahiro Yamada, Frank Rowand, Michal Marek, Rob Herring
  Cc: Viresh Kumar, Vincent Guittot, David Gibson, Michal Simek,
	Geert Uytterhoeven, anmar.oueja, Bill Mills, devicetree,
	Geert Uytterhoeven, linux-kbuild, linux-kernel, Rob Herring

Hi,

This patchset adds a generic rule for applying overlays using fdtoverlay
tool and then updates unittests to get built statically using the same.

V9->V10:
- Add a new patch to allow .dtso files.
- Update 2/5 to be more efficient and also generate symbols for base
  files automatically.
- No need to add lines like DTC_FLAGS_foo_base += -@ in patch 5/5.
- Add Ack by Masahiro for 1/5.

V8->V9:
- Added some comment in patch 3/4 based on Frank's suggestions.

V7->V8:
- Patch 1 is new.
- Platforms need to use dtb-y += foo.dtb instead of overlay-y +=
  foo.dtb.
- Use multi_depend instead of .SECONDEXPANSION.
- Use dtb-y for unittest instead of overlay-y.
- Rename the commented dtb filess in unittest Makefile as .dtbo.
- Improved Makefile code (I am learning a lot every day :)

V6->V7:
- Dropped the first 4 patches, already merged.
- Patch 1/3 is new, suggested by Rob and slightly modified by me.
- Adapt Patch 3/3 to the new rule and name the overlay dtbs as .dtbo.

--
Viresh

Rob Herring (1):
  kbuild: Add generic rule to apply fdtoverlay

Viresh Kumar (4):
  kbuild: Simplify builds with CONFIG_OF_ALL_DTBS
  kbuild: Allow .dtso format for overlay source files
  of: unittest: Create overlay_common.dtsi and testcases_common.dtsi
  of: unittest: Statically apply overlays using fdtoverlay

 drivers/of/unittest-data/Makefile             | 48 ++++++++++
 drivers/of/unittest-data/overlay_base.dts     | 90 +-----------------
 drivers/of/unittest-data/overlay_common.dtsi  | 91 +++++++++++++++++++
 drivers/of/unittest-data/static_base_1.dts    |  4 +
 drivers/of/unittest-data/static_base_2.dts    |  4 +
 drivers/of/unittest-data/testcases.dts        | 23 ++---
 .../of/unittest-data/testcases_common.dtsi    | 19 ++++
 .../of/unittest-data/tests-interrupts.dtsi    | 11 +--
 scripts/Makefile.lib                          | 40 ++++++--
 9 files changed, 218 insertions(+), 112 deletions(-)
 create mode 100644 drivers/of/unittest-data/overlay_common.dtsi
 create mode 100644 drivers/of/unittest-data/static_base_1.dts
 create mode 100644 drivers/of/unittest-data/static_base_2.dts
 create mode 100644 drivers/of/unittest-data/testcases_common.dtsi


base-commit: a38fd8748464831584a19438cbb3082b5a2dab15
-- 
2.25.0.rc1.19.g042ed3e048af


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

* [PATCH V10 1/5] kbuild: Simplify builds with CONFIG_OF_ALL_DTBS
  2021-03-08 10:45 [PATCH V10 0/5] dt: Add fdtoverlay rule and statically build unittest Viresh Kumar
@ 2021-03-08 10:45 ` Viresh Kumar
  2021-03-08 10:45 ` [PATCH V10 2/5] kbuild: Add generic rule to apply fdtoverlay Viresh Kumar
  2021-03-08 10:45 ` [PATCH V10 3/5] kbuild: Allow .dtso format for overlay source files Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2021-03-08 10:45 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek
  Cc: Viresh Kumar, Vincent Guittot, David Gibson, Frank Rowand,
	Michal Simek, Geert Uytterhoeven, anmar.oueja, Bill Mills,
	linux-kbuild, linux-kernel

We update 'extra-y' based on CONFIG_OF_ALL_DTBS three times. It would be
far more straight forward if we rather update dtb-y to include all .dtb
files if CONFIG_OF_ALL_DTBS is enabled.

Acked-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 scripts/Makefile.lib | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index eee59184de64..a2658242d956 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -73,14 +73,13 @@ always-y += $(userprogs-always-y) $(userprogs-always-m)
 
 # DTB
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
+dtb-$(CONFIG_OF_ALL_DTBS)       += $(dtb-)
+
 always-y			+= $(dtb-y)
-always-$(CONFIG_OF_ALL_DTBS)	+= $(dtb-)
 
 ifneq ($(CHECK_DTBS),)
 always-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
 always-y += $(patsubst %.dtbo,%.dt.yaml, $(dtb-y))
-always-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
-always-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtbo,%.dt.yaml, $(dtb-))
 endif
 
 # Add subdir path
-- 
2.25.0.rc1.19.g042ed3e048af


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

* [PATCH V10 2/5] kbuild: Add generic rule to apply fdtoverlay
  2021-03-08 10:45 [PATCH V10 0/5] dt: Add fdtoverlay rule and statically build unittest Viresh Kumar
  2021-03-08 10:45 ` [PATCH V10 1/5] kbuild: Simplify builds with CONFIG_OF_ALL_DTBS Viresh Kumar
@ 2021-03-08 10:45 ` Viresh Kumar
  2021-03-09 16:27   ` Masahiro Yamada
  2021-03-08 10:45 ` [PATCH V10 3/5] kbuild: Allow .dtso format for overlay source files Viresh Kumar
  2 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2021-03-08 10:45 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek
  Cc: Viresh Kumar, Vincent Guittot, David Gibson, Frank Rowand,
	Michal Simek, Geert Uytterhoeven, anmar.oueja, Bill Mills,
	Rob Herring, linux-kbuild, linux-kernel

From: Rob Herring <robh@kernel.org>

Add a generic rule to apply fdtoverlay in Makefile.lib, so every
platform doesn't need to carry the complex rule. This also automatically
adds "DTC_FLAGS_foo_base += -@" for all base files.

The platform's Makefile only needs to have this now:

 foo-dtbs := foo_base.dtb foo_overlay1.dtbo foo_overlay2.dtbo
 dtb-y := foo.dtb

We don't want to run schema checks on foo.dtb (as foo.dts doesn't exist)
and the Makefile is updated accordingly.

Signed-off-by: Rob Herring <robh@kernel.org>
Co-developed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 scripts/Makefile.lib | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index a2658242d956..bc045a54a34e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -75,11 +75,24 @@ always-y += $(userprogs-always-y) $(userprogs-always-m)
 # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
 dtb-$(CONFIG_OF_ALL_DTBS)       += $(dtb-)
 
+# List all dtbs to be generated by fdtoverlay
+overlay-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$(m),))
+
+# Generate symbols for the base files so overlays can be applied to them.
+$(foreach m,$(overlay-y), $(eval DTC_FLAGS_$(basename $(firstword $($(m:.dtb=-dtbs)))) += -@))
+
+# Add base dtb and overlay dtbo
+dtb-y += $(foreach m,$(overlay-y), $($(m:.dtb=-dtbs)))
+
 always-y			+= $(dtb-y)
 
 ifneq ($(CHECK_DTBS),)
-always-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
-always-y += $(patsubst %.dtbo,%.dt.yaml, $(dtb-y))
+# Don't run schema checks for dtbs created by fdtoverlay as they don't
+# have corresponding dts files.
+dt-yaml-y := $(filter-out $(overlay-y),$(dtb-y))
+
+always-y += $(patsubst %.dtb,%.dt.yaml, $(dt-yaml-y))
+always-y += $(patsubst %.dtbo,%.dt.yaml, $(dt-yaml-y))
 endif
 
 # Add subdir path
@@ -337,6 +350,15 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
 $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
 	$(call if_changed_dep,dtc)
 
+overlay-y := $(addprefix $(obj)/, $(overlay-y))
+
+quiet_cmd_fdtoverlay = DTOVL   $@
+      cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs)
+
+$(overlay-y): FORCE
+	$(call if_changed,fdtoverlay)
+$(call multi_depend, $(overlay-y), .dtb, -dtbs)
+
 DT_CHECKER ?= dt-validate
 DT_BINDING_DIR := Documentation/devicetree/bindings
 # DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
-- 
2.25.0.rc1.19.g042ed3e048af


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

* [PATCH V10 3/5] kbuild: Allow .dtso format for overlay source files
  2021-03-08 10:45 [PATCH V10 0/5] dt: Add fdtoverlay rule and statically build unittest Viresh Kumar
  2021-03-08 10:45 ` [PATCH V10 1/5] kbuild: Simplify builds with CONFIG_OF_ALL_DTBS Viresh Kumar
  2021-03-08 10:45 ` [PATCH V10 2/5] kbuild: Add generic rule to apply fdtoverlay Viresh Kumar
@ 2021-03-08 10:45 ` Viresh Kumar
  2 siblings, 0 replies; 5+ messages in thread
From: Viresh Kumar @ 2021-03-08 10:45 UTC (permalink / raw)
  To: Masahiro Yamada, Michal Marek
  Cc: Viresh Kumar, Vincent Guittot, David Gibson, Frank Rowand,
	Michal Simek, Geert Uytterhoeven, anmar.oueja, Bill Mills,
	Geert Uytterhoeven, linux-kbuild, linux-kernel

Since the overlays dtb files are now named as .dtbo, there is a lot of
interest in similarly naming the overlay source dts files as .dtso.

This patch makes the necessary changes to allow .dtso format for overlay
source files.

Note that we still support generating .dtbo files from .dts files. This
is required for the source files present in drivers/of/unittest-data/,
because they can't be renamed to .dtso as they are used for some runtime
testing as well.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 scripts/Makefile.lib | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index bc045a54a34e..59e86f67f9e0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -339,7 +339,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
 
 quiet_cmd_dtc = DTC     $@
 cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
-	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
+	$(DTC) -I dts -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
 		$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
@@ -347,9 +347,13 @@ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ;
 $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
 	$(call if_changed_dep,dtc)
 
+# Required for of unit-test files as they can't be renamed to .dtso
 $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
 	$(call if_changed_dep,dtc)
 
+$(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE
+	$(call if_changed_dep,dtc)
+
 overlay-y := $(addprefix $(obj)/, $(overlay-y))
 
 quiet_cmd_fdtoverlay = DTOVL   $@
@@ -375,6 +379,9 @@ endef
 $(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE
 	$(call if_changed_rule,dtc,yaml)
 
+$(obj)/%.dt.yaml: $(src)/%.dtso $(DTC) $(DT_TMP_SCHEMA) FORCE
+	$(call if_changed_rule,dtc,yaml)
+
 dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
 
 # Bzip2
-- 
2.25.0.rc1.19.g042ed3e048af


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

* Re: [PATCH V10 2/5] kbuild: Add generic rule to apply fdtoverlay
  2021-03-08 10:45 ` [PATCH V10 2/5] kbuild: Add generic rule to apply fdtoverlay Viresh Kumar
@ 2021-03-09 16:27   ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2021-03-09 16:27 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Michal Marek, Vincent Guittot, David Gibson, Frank Rowand,
	Michal Simek, Geert Uytterhoeven, Anmar Oueja, Bill Mills,
	Rob Herring, Linux Kbuild mailing list,
	Linux Kernel Mailing List

On Mon, Mar 8, 2021 at 7:45 PM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> From: Rob Herring <robh@kernel.org>
>
> Add a generic rule to apply fdtoverlay in Makefile.lib, so every
> platform doesn't need to carry the complex rule. This also automatically
> adds "DTC_FLAGS_foo_base += -@" for all base files.
>
> The platform's Makefile only needs to have this now:
>
>  foo-dtbs := foo_base.dtb foo_overlay1.dtbo foo_overlay2.dtbo
>  dtb-y := foo.dtb
>
> We don't want to run schema checks on foo.dtb (as foo.dts doesn't exist)
> and the Makefile is updated accordingly.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Co-developed-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

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



> ---
>  scripts/Makefile.lib | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index a2658242d956..bc045a54a34e 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -75,11 +75,24 @@ always-y += $(userprogs-always-y) $(userprogs-always-m)
>  # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
>  dtb-$(CONFIG_OF_ALL_DTBS)       += $(dtb-)
>
> +# List all dtbs to be generated by fdtoverlay
> +overlay-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$(m),))
> +
> +# Generate symbols for the base files so overlays can be applied to them.
> +$(foreach m,$(overlay-y), $(eval DTC_FLAGS_$(basename $(firstword $($(m:.dtb=-dtbs)))) += -@))
> +
> +# Add base dtb and overlay dtbo
> +dtb-y += $(foreach m,$(overlay-y), $($(m:.dtb=-dtbs)))
> +
>  always-y                       += $(dtb-y)
>
>  ifneq ($(CHECK_DTBS),)
> -always-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y))
> -always-y += $(patsubst %.dtbo,%.dt.yaml, $(dtb-y))
> +# Don't run schema checks for dtbs created by fdtoverlay as they don't
> +# have corresponding dts files.
> +dt-yaml-y := $(filter-out $(overlay-y),$(dtb-y))
> +
> +always-y += $(patsubst %.dtb,%.dt.yaml, $(dt-yaml-y))
> +always-y += $(patsubst %.dtbo,%.dt.yaml, $(dt-yaml-y))
>  endif
>
>  # Add subdir path
> @@ -337,6 +350,15 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
>  $(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
>         $(call if_changed_dep,dtc)
>
> +overlay-y := $(addprefix $(obj)/, $(overlay-y))
> +
> +quiet_cmd_fdtoverlay = DTOVL   $@
> +      cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs)
> +
> +$(overlay-y): FORCE
> +       $(call if_changed,fdtoverlay)
> +$(call multi_depend, $(overlay-y), .dtb, -dtbs)
> +
>  DT_CHECKER ?= dt-validate
>  DT_BINDING_DIR := Documentation/devicetree/bindings
>  # DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
> --
> 2.25.0.rc1.19.g042ed3e048af
>


-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2021-03-09 16:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 10:45 [PATCH V10 0/5] dt: Add fdtoverlay rule and statically build unittest Viresh Kumar
2021-03-08 10:45 ` [PATCH V10 1/5] kbuild: Simplify builds with CONFIG_OF_ALL_DTBS Viresh Kumar
2021-03-08 10:45 ` [PATCH V10 2/5] kbuild: Add generic rule to apply fdtoverlay Viresh Kumar
2021-03-09 16:27   ` Masahiro Yamada
2021-03-08 10:45 ` [PATCH V10 3/5] kbuild: Allow .dtso format for overlay source files Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).