From: David Gibson <david@gibson.dropbear.id.au>
To: Tom Rini <trini@konsulko.com>
Cc: devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH 2/3] libfdt: Improve size savings in FDT_RO_PROBE slightly
Date: Wed, 10 Dec 2025 17:46:44 +1100 [thread overview]
Message-ID: <aTkXVOPm3BoinU24@zatzit> (raw)
In-Reply-To: <20251210022002.3004223-3-trini@konsulko.com>
[-- Attachment #1: Type: text/plain, Size: 2041 bytes --]
On Tue, Dec 09, 2025 at 03:50:52PM -0600, Tom Rini wrote:
> In the case where we have set FDT_ASSUME_MASK to disable
> ASSUME_VALID_DTB checks, we can improve the FDT_RO_PROBE macro slightly.
> The first thing that fdt_ro_probe_() does when we can_assume(VALID_DTB)
> is true is to return whatever the contents of the totalsize field of the
> DTB is. Since the FDT_RO_PROBE macro only cares about a negative value
> there, we can optimize this check such that we are to assume it's a
> valid DTB, we don't need to do anything here.
>
> Signed-off-by: Tom Rini <trini@konsulko.com>
Applied, thanks.
> ---
> In the case of U-Boot SPL (and similar very early stages) we are
> extremely concerned with binary size, and also assume the device tree is
> valid. This patch here is not a huge savings for us, but every little
> bit helps when talking about something that impacts more than half our
> build configurations.
> ---
> libfdt/libfdt_internal.h | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
> index 9eb32394eb79..0e103cafa714 100644
> --- a/libfdt/libfdt_internal.h
> +++ b/libfdt/libfdt_internal.h
> @@ -11,11 +11,13 @@
> #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
>
> int32_t fdt_ro_probe_(const void *fdt);
> -#define FDT_RO_PROBE(fdt) \
> - { \
> - int32_t totalsize_; \
> - if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \
> - return totalsize_; \
> +#define FDT_RO_PROBE(fdt) \
> + { \
> + if (!can_assume(VALID_DTB)) { \
> + int32_t totalsize_; \
> + if ((totalsize_ = fdt_ro_probe_(fdt)) < 0) \
> + return totalsize_; \
> + } \
> }
>
> int fdt_check_node_offset_(const void *fdt, int offset);
> --
> 2.43.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-12-10 6:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-09 21:50 [PATCH 0/3] libfdt: A few more size improvements Tom Rini
2025-12-09 21:50 ` [PATCH 1/3] libfdt: libfdt_internal.h correct final comment in ASSUME block Tom Rini
2025-12-10 6:42 ` David Gibson
2025-12-09 21:50 ` [PATCH 2/3] libfdt: Improve size savings in FDT_RO_PROBE slightly Tom Rini
2025-12-10 6:46 ` David Gibson [this message]
2025-12-09 21:50 ` [PATCH 3/3] libfdt: fdt_get_name: Add can_assume(VALID_DTB) check Tom Rini
2025-12-10 6:47 ` David Gibson
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=aTkXVOPm3BoinU24@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=devicetree-compiler@vger.kernel.org \
--cc=trini@konsulko.com \
/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 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).