All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Schier <nsc@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: "Rob Herring (Arm)" <robh@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v2] kbuild: Support directory targets for building DTBs
Date: Fri, 21 Nov 2025 20:42:34 +0100	[thread overview]
Message-ID: <aSDAqhUb8_76IP0Y@derry.ads.avm.de> (raw)
In-Reply-To: <20251121063033.GA571346@ax162>

[-- Attachment #1: Type: text/plain, Size: 5124 bytes --]

On Thu, Nov 20, 2025 at 11:30:33PM -0700, Nathan Chancellor wrote:
> On Thu, Nov 20, 2025 at 02:48:13PM -0600, Rob Herring (Arm) wrote:
> > It is useful to be able to build all the DTBs for a vendor. One can list
> > all the .dts files in a directory and convert those to %.dtb targets,
> > but that doesn't work for base+overlay DTB targets.
> > 
> > Adding the dts subdirectory is straight-forward, but building the
> > DTBs should only happen for certain targets (dtbs, dtbs_check, %.dtb,
> > %.dtbo, and the directory target(s)).
> > 
> > The 'scripts_dtc' rule doesn't really depend on 'dt_binding_schemas',
> > but the directory target only depends on 'scripts' which depends on
> > 'scripts_dtc'.
> > 
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
> > Please ack and I'll take this in the DT tree.
> > 
> > I don't really like looking at MAKECMDGOALS, but that's the only way I
> > could come up with that works. Maybe someone knows a better way.
> 
> Yeah, I do worry that just looking for "dtb" in MAKECMDGOALS could
> result in some false positives but in the tree now, I only see one .c
> file that would trigger this logic, so maybe it is not that big of a
> deal?
> 
>   $ fd dtb
>   arch/microblaze/boot/dts/linked_dtb.S
>   arch/mips/include/asm/mach-loongson64/builtin_dtbs.h
>   arch/um/kernel/dtb.c
>   drivers/gpu/drm/ci/dtbs-check.sh
>   scripts/Makefile.dtbinst
>   scripts/Makefile.dtbs
> 
> Unfortunately, my Make-fu is pretty weak right now so I do not have any
> immediate suggestions but Nicolas might... otherwise, we could probably
> ride this for right now and either revert it or forward fix it if
> problems come up in further testing, since this does seem rather useful
> for folks working on device tree files.

well, evaluating MAKECMDGOALS does not look that bad to me.  But I'd
rather like to reduce the use of findstring, see below.

> 
> > v2:
> >  - Convert arm, mips and riscv. The other DT enabled arches don't have 
> >    vendor directories.
> >  - Link to v1: https://lore.kernel.org/all/20251113225952.867138-1-robh@kernel.org/ 
> > 
> > ---
> >  Makefile              | 2 +-
> >  arch/arm/Kbuild       | 2 ++
> >  arch/arm64/Kbuild     | 2 ++
> >  arch/mips/Kbuild      | 2 ++
> >  arch/riscv/Kbuild     | 2 ++
> >  scripts/Makefile.dtbs | 3 +++
> >  6 files changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index 17cfa11ca716..85018d461575 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1494,7 +1494,7 @@ export CHECK_DTBS=y
> >  endif
> >  
> >  ifneq ($(CHECK_DTBS),)
> > -dtbs_prepare: dt_binding_schemas
> > +scripts_dtc: dt_binding_schemas
> >  endif
> >  
> >  dtbs_check: dtbs
> > diff --git a/arch/arm/Kbuild b/arch/arm/Kbuild
> > index 69de6b6243c7..af7dd53585c3 100644
> > --- a/arch/arm/Kbuild
> > +++ b/arch/arm/Kbuild
> > @@ -10,5 +10,7 @@ obj-y				+= probes/
> >  obj-y				+= net/
> >  obj-y				+= crypto/
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
> > index 5bfbf7d79c99..9e9820af48c9 100644
> > --- a/arch/arm64/Kbuild
> > +++ b/arch/arm64/Kbuild
> > @@ -5,5 +5,7 @@ obj-$(CONFIG_XEN)	+= xen/
> >  obj-$(subst m,y,$(CONFIG_HYPERV))	+= hyperv/
> >  obj-$(CONFIG_CRYPTO)	+= crypto/
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/arch/mips/Kbuild b/arch/mips/Kbuild
> > index e901bf554483..6125d00cdcef 100644
> > --- a/arch/mips/Kbuild
> > +++ b/arch/mips/Kbuild
> > @@ -21,5 +21,7 @@ ifdef CONFIG_KVM
> >  obj-y += kvm/
> >  endif
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/arch/riscv/Kbuild b/arch/riscv/Kbuild
> > index 126fb738fc44..3cf7f84eb287 100644
> > --- a/arch/riscv/Kbuild
> > +++ b/arch/riscv/Kbuild
> > @@ -7,5 +7,7 @@ obj-$(CONFIG_KVM) += kvm/
> >  
> >  obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
> > index 2d321b813600..4d0d164df275 100644
> > --- a/scripts/Makefile.dtbs
> > +++ b/scripts/Makefile.dtbs
> > @@ -14,7 +14,10 @@ dtb-y           := $(addprefix $(obj)/, $(dtb-y))
> >  multi-dtb-y     := $(addprefix $(obj)/, $(multi-dtb-y))
> >  real-dtb-y      := $(addprefix $(obj)/, $(real-dtb-y))
> >  
> > +ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(findstring dtb,$(MAKECMDGOALS)),)

Using '$(filter )' instead of '$(findstring )' reduces the risk of false
positives, e.g.:

dtb-targets := %/dts %.dtb %.dtbo dtbs dtbs_check
ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(filter $(dtb-targets),$(MAKECMDGOALS)),)


With (something like) that:
Tested-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Nicolas Schier <nsc@kernel.org>

But [1] seems to break this patch.

[1]: https://lore.kernel.org/linux-kbuild/20251120140645.478623-1-thomas.de_schampheleire@nokia.com

Kind regards,
Nicolas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Nicolas Schier <nsc@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: "Rob Herring (Arm)" <robh@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v2] kbuild: Support directory targets for building DTBs
Date: Fri, 21 Nov 2025 20:42:34 +0100	[thread overview]
Message-ID: <aSDAqhUb8_76IP0Y@derry.ads.avm.de> (raw)
In-Reply-To: <20251121063033.GA571346@ax162>


[-- Attachment #1.1: Type: text/plain, Size: 5124 bytes --]

On Thu, Nov 20, 2025 at 11:30:33PM -0700, Nathan Chancellor wrote:
> On Thu, Nov 20, 2025 at 02:48:13PM -0600, Rob Herring (Arm) wrote:
> > It is useful to be able to build all the DTBs for a vendor. One can list
> > all the .dts files in a directory and convert those to %.dtb targets,
> > but that doesn't work for base+overlay DTB targets.
> > 
> > Adding the dts subdirectory is straight-forward, but building the
> > DTBs should only happen for certain targets (dtbs, dtbs_check, %.dtb,
> > %.dtbo, and the directory target(s)).
> > 
> > The 'scripts_dtc' rule doesn't really depend on 'dt_binding_schemas',
> > but the directory target only depends on 'scripts' which depends on
> > 'scripts_dtc'.
> > 
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
> > Please ack and I'll take this in the DT tree.
> > 
> > I don't really like looking at MAKECMDGOALS, but that's the only way I
> > could come up with that works. Maybe someone knows a better way.
> 
> Yeah, I do worry that just looking for "dtb" in MAKECMDGOALS could
> result in some false positives but in the tree now, I only see one .c
> file that would trigger this logic, so maybe it is not that big of a
> deal?
> 
>   $ fd dtb
>   arch/microblaze/boot/dts/linked_dtb.S
>   arch/mips/include/asm/mach-loongson64/builtin_dtbs.h
>   arch/um/kernel/dtb.c
>   drivers/gpu/drm/ci/dtbs-check.sh
>   scripts/Makefile.dtbinst
>   scripts/Makefile.dtbs
> 
> Unfortunately, my Make-fu is pretty weak right now so I do not have any
> immediate suggestions but Nicolas might... otherwise, we could probably
> ride this for right now and either revert it or forward fix it if
> problems come up in further testing, since this does seem rather useful
> for folks working on device tree files.

well, evaluating MAKECMDGOALS does not look that bad to me.  But I'd
rather like to reduce the use of findstring, see below.

> 
> > v2:
> >  - Convert arm, mips and riscv. The other DT enabled arches don't have 
> >    vendor directories.
> >  - Link to v1: https://lore.kernel.org/all/20251113225952.867138-1-robh@kernel.org/ 
> > 
> > ---
> >  Makefile              | 2 +-
> >  arch/arm/Kbuild       | 2 ++
> >  arch/arm64/Kbuild     | 2 ++
> >  arch/mips/Kbuild      | 2 ++
> >  arch/riscv/Kbuild     | 2 ++
> >  scripts/Makefile.dtbs | 3 +++
> >  6 files changed, 12 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Makefile b/Makefile
> > index 17cfa11ca716..85018d461575 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1494,7 +1494,7 @@ export CHECK_DTBS=y
> >  endif
> >  
> >  ifneq ($(CHECK_DTBS),)
> > -dtbs_prepare: dt_binding_schemas
> > +scripts_dtc: dt_binding_schemas
> >  endif
> >  
> >  dtbs_check: dtbs
> > diff --git a/arch/arm/Kbuild b/arch/arm/Kbuild
> > index 69de6b6243c7..af7dd53585c3 100644
> > --- a/arch/arm/Kbuild
> > +++ b/arch/arm/Kbuild
> > @@ -10,5 +10,7 @@ obj-y				+= probes/
> >  obj-y				+= net/
> >  obj-y				+= crypto/
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
> > index 5bfbf7d79c99..9e9820af48c9 100644
> > --- a/arch/arm64/Kbuild
> > +++ b/arch/arm64/Kbuild
> > @@ -5,5 +5,7 @@ obj-$(CONFIG_XEN)	+= xen/
> >  obj-$(subst m,y,$(CONFIG_HYPERV))	+= hyperv/
> >  obj-$(CONFIG_CRYPTO)	+= crypto/
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/arch/mips/Kbuild b/arch/mips/Kbuild
> > index e901bf554483..6125d00cdcef 100644
> > --- a/arch/mips/Kbuild
> > +++ b/arch/mips/Kbuild
> > @@ -21,5 +21,7 @@ ifdef CONFIG_KVM
> >  obj-y += kvm/
> >  endif
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/arch/riscv/Kbuild b/arch/riscv/Kbuild
> > index 126fb738fc44..3cf7f84eb287 100644
> > --- a/arch/riscv/Kbuild
> > +++ b/arch/riscv/Kbuild
> > @@ -7,5 +7,7 @@ obj-$(CONFIG_KVM) += kvm/
> >  
> >  obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/
> >  
> > +subdir-y += boot/dts
> > +
> >  # for cleaning
> >  subdir- += boot
> > diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
> > index 2d321b813600..4d0d164df275 100644
> > --- a/scripts/Makefile.dtbs
> > +++ b/scripts/Makefile.dtbs
> > @@ -14,7 +14,10 @@ dtb-y           := $(addprefix $(obj)/, $(dtb-y))
> >  multi-dtb-y     := $(addprefix $(obj)/, $(multi-dtb-y))
> >  real-dtb-y      := $(addprefix $(obj)/, $(real-dtb-y))
> >  
> > +ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(findstring dtb,$(MAKECMDGOALS)),)

Using '$(filter )' instead of '$(findstring )' reduces the risk of false
positives, e.g.:

dtb-targets := %/dts %.dtb %.dtbo dtbs dtbs_check
ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(filter $(dtb-targets),$(MAKECMDGOALS)),)


With (something like) that:
Tested-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Nicolas Schier <nsc@kernel.org>

But [1] seems to break this patch.

[1]: https://lore.kernel.org/linux-kbuild/20251120140645.478623-1-thomas.de_schampheleire@nokia.com

Kind regards,
Nicolas

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2025-11-21 19:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 20:48 [PATCH v2] kbuild: Support directory targets for building DTBs Rob Herring (Arm)
2025-11-20 20:48 ` Rob Herring (Arm)
2025-11-21  6:30 ` Nathan Chancellor
2025-11-21  6:30   ` Nathan Chancellor
2025-11-21 19:42   ` Nicolas Schier [this message]
2025-11-21 19:42     ` Nicolas Schier
2025-11-21 22:20     ` Nathan Chancellor
2025-11-21 22:20       ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aSDAqhUb8_76IP0Y@derry.ads.avm.de \
    --to=nsc@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=nathan@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=robh@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.