Hi Alexey,

On 2026-09-18T10:52:27, Alexey Charkov <[email protected]> wrote:
> boot: image: Keep the image-type table out of xPL
>
> print_decomp_msg() names the image it is about to unpack, which drags
> uimage_type[] and its strings into any phase that links image_decomp().
> That is about 2.5KB, measured on a Rockchip RK3576 SPL, spent on one line
> of progress output in a phase built for size.

Not quite. This only holds where nothing else in the phase needs the
table. load_simple_fit() calls fit_image_get_type() when SPL_FPGA is
enabled, or SPL_OS_BOOT plus a decompressor, and that uses
genimg_get_type_id() which needs uimage_type[] too.

I tried xilinx_zynqmp_virt (SPL_FPGA and SPL_GZIP) with the whole
series applied, with and without this patch:

       text    data     bss     dec     hex filename
     131556    6968     440  138964   21ed4 spl/u-boot-spl   (with)
     131650    6968     440  139058   21f32 spl/u-boot-spl   (without)

So that is 94 bytes saved and uimage_type[] (0x480 bytes plus its
strings) is still in the map. Please can you update the commit message
to say when the saving applies?

>
> Name it "image" there instead. U-Boot proper is unchanged.
>
> Reviewed-by: Tom Rini <[email protected]>
> Signed-off-by: Alexey Charkov <[email protected]>
>
> boot/image.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

> diff --git a/boot/image.c b/boot/image.c
> @@ -416,7 +416,12 @@ void image_print_contents(const void *ptr)
> +     /*
> +      * The image-type table and its strings cost about 2.5KB, which is a
> +      * lot to spend on a progress message in a phase built for size.
> +      */
> +     const char *name = IS_ENABLED(CONFIG_XPL_BUILD) ? "image" :
> +                        genimg_get_type_name(type);

The boards which keep the table are those where load_simple_fit()
reads the type from the FIT, so the name would be correct there. On
the others the type is never read, so the lookup can only produce
'Unknown Image' anyway. So this drops the name in the one case where
it is useful and nearly free.

I suspect it would be better to key this off the same condition which
load_simple_fit() uses to read the type, rather than CONFIG_XPL_BUILD,
perhaps with a small helper in image.h shared by both. I am not sure
how neat that would be, though, since any xPL build with LOAD_FIT_FULL
also has the table, via fit_image_load(). What do you think?

Regards,
Simon

Reply via email to