[PATCH] kbuild: Ensure .dtbo targets are applied to a base .dtb

Rob Herring (Arm) posted 1 patch 2 months, 3 weeks ago
scripts/Makefile.dtbs | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH] kbuild: Ensure .dtbo targets are applied to a base .dtb
Posted by Rob Herring (Arm) 2 months, 3 weeks ago
It is a requirement that DT overlays in the kernel are applied at build
time to a base DTB in order to validate they can be applied and to
validate them against the DT schemas. DT overlays on their own may be
incomplete and can't be validated.

Add a kbuild check so this doesn't have to be checked and fixed
periodically.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 scripts/Makefile.dtbs | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
index 2d321b813600..15473edc2589 100644
--- a/scripts/Makefile.dtbs
+++ b/scripts/Makefile.dtbs
@@ -10,6 +10,13 @@ real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs)
 # Base DTB that overlay is applied onto
 base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs))
 
+# Ensure that any .dtbo is applied to at least one base .dtb. Otherwise, it
+# does not get validated.
+applied-dtbo := $(filter %.dtbo, \
+	$(call real-search, $(call multi-search, $(dtb-y) $(dtb-), .dtb, -dtbs), .dtb, -dtbs))
+unapplied-dtbo := $(filter-out $(applied-dtbo),$(filter %.dtbo, $(dtb-y)))
+$(if $(unapplied-dtbo), $(warning .dtbo is not applied to any base: $(unapplied-dtbo)))
+
 dtb-y           := $(addprefix $(obj)/, $(dtb-y))
 multi-dtb-y     := $(addprefix $(obj)/, $(multi-dtb-y))
 real-dtb-y      := $(addprefix $(obj)/, $(real-dtb-y))
-- 
2.51.0
Re: [PATCH] kbuild: Ensure .dtbo targets are applied to a base .dtb
Posted by Nicolas Schier 2 months, 2 weeks ago
On Fri, Nov 14, 2025 at 04:27:58PM -0600, Rob Herring (Arm) wrote:
> It is a requirement that DT overlays in the kernel are applied at build
> time to a base DTB in order to validate they can be applied and to
> validate them against the DT schemas. DT overlays on their own may be
> incomplete and can't be validated.
> 
> Add a kbuild check so this doesn't have to be checked and fixed
> periodically.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
>  scripts/Makefile.dtbs | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
> index 2d321b813600..15473edc2589 100644
> --- a/scripts/Makefile.dtbs
> +++ b/scripts/Makefile.dtbs
> @@ -10,6 +10,13 @@ real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs)
>  # Base DTB that overlay is applied onto
>  base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs))
>  
> +# Ensure that any .dtbo is applied to at least one base .dtb. Otherwise, it
> +# does not get validated.
> +applied-dtbo := $(filter %.dtbo, \
> +	$(call real-search, $(call multi-search, $(dtb-y) $(dtb-), .dtb, -dtbs), .dtb, -dtbs))
> +unapplied-dtbo := $(filter-out $(applied-dtbo),$(filter %.dtbo, $(dtb-y)))
> +$(if $(unapplied-dtbo), $(warning .dtbo is not applied to any base: $(unapplied-dtbo)))
> +
>  dtb-y           := $(addprefix $(obj)/, $(dtb-y))
>  multi-dtb-y     := $(addprefix $(obj)/, $(multi-dtb-y))
>  real-dtb-y      := $(addprefix $(obj)/, $(real-dtb-y))
> -- 
> 2.51.0
> 

Acked-by: Nicolas Schier <nsc@kernel.org>

Do you take this via DT tree?

Kind regards,
Nicolas
Re: [PATCH] kbuild: Ensure .dtbo targets are applied to a base .dtb
Posted by Rob Herring 2 months, 1 week ago
On Wed, Nov 26, 2025 at 2:49 PM Nicolas Schier <nsc@kernel.org> wrote:
>
> On Fri, Nov 14, 2025 at 04:27:58PM -0600, Rob Herring (Arm) wrote:
> > It is a requirement that DT overlays in the kernel are applied at build
> > time to a base DTB in order to validate they can be applied and to
> > validate them against the DT schemas. DT overlays on their own may be
> > incomplete and can't be validated.
> >
> > Add a kbuild check so this doesn't have to be checked and fixed
> > periodically.
> >
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
> >  scripts/Makefile.dtbs | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
> > index 2d321b813600..15473edc2589 100644
> > --- a/scripts/Makefile.dtbs
> > +++ b/scripts/Makefile.dtbs
> > @@ -10,6 +10,13 @@ real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs)
> >  # Base DTB that overlay is applied onto
> >  base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs))
> >
> > +# Ensure that any .dtbo is applied to at least one base .dtb. Otherwise, it
> > +# does not get validated.
> > +applied-dtbo := $(filter %.dtbo, \
> > +     $(call real-search, $(call multi-search, $(dtb-y) $(dtb-), .dtb, -dtbs), .dtb, -dtbs))
> > +unapplied-dtbo := $(filter-out $(applied-dtbo),$(filter %.dtbo, $(dtb-y)))
> > +$(if $(unapplied-dtbo), $(warning .dtbo is not applied to any base: $(unapplied-dtbo)))
> > +
> >  dtb-y           := $(addprefix $(obj)/, $(dtb-y))
> >  multi-dtb-y     := $(addprefix $(obj)/, $(multi-dtb-y))
> >  real-dtb-y      := $(addprefix $(obj)/, $(real-dtb-y))
> > --
> > 2.51.0
> >
>
> Acked-by: Nicolas Schier <nsc@kernel.org>

Thanks!

> Do you take this via DT tree?

Yes, I'll take it.

Rob