All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Heiko Schocher <hs@nabladev.com>,
	Alexey Charkov <alchark@flipper.net>,
	"Lucien.Jheng" <lucienzx159@gmail.com>,
	Daniel Golle <daniel@makrotopia.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Mehmet Fide <mehmet.fide@screeningeagle.com>,
	Casey Connolly <casey.connolly@linaro.org>,
	Michal Simek <michal.simek@amd.com>,
	Aristo Chen <aristo.chen@canonical.com>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Anshul Dalal <anshuld@ti.com>, Johan Jonker <jbx6244@gmail.com>,
	Neha Malcom Francis <n-francis@ti.com>,
	Marcello Sylvester Bauer <marcello.bauer@9elements.com>,
	Mateus Lima Alves <mateuslima.ti@gmail.com>,
	Tan Siewert <tan.siewert@9elements.com>, Yao Zi <me@ziyao.cc>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Peng Fan <peng.fan@nxp.com>, Randolph Sapp <rs@ti.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Martin Schwan <m.schwan@phytec.de>,
	u-boot@lists.u-boot-project.org
Subject: Re: [PATCH v9 7/8] misc: fw_loader: introduce FIP loader driver
Date: Mon, 26 Oct 2026 14:36:37 +0100	[thread overview]
Message-ID: <6adf5769.950cae81.ea04b.740f@mx.google.com> (raw)
In-Reply-To: <CAFLszTgNfacD0cDBii5VudmUWZhGThU2WFGHh=qNr6FvM5PTVQ@mail.gmail.com>

On Mon, Oct 26, 2026 at 05:37:29AM -0700, Simon Glass wrote:
> Hi Christian,
> 
> On 2026-10-23T19:00:21, Christian Marangi <ansuelsmth@gmail.com> wrote:
> > misc: fw_loader: introduce FIP loader driver
> >
> > Introduce a variant of the FS loader driver to extract images from FIP
> > image. These image can contain additional binary used to init Network
> > accelerator or PHY firmware blob.
> >
> > The way FIP handle image type is with the usage of UUID.
> >
> > This FIP loader driver implement a simple FIP image parser that check
> > every entry for a matching UUID.
> >
> > Similar to FS loader, this driver also support both UBI and Block
> > devices.
> >
> > Also an additional property is added to handle special case with eMMC
> > that doesn't have a GPT partition and require a global offset to
> > reference the FIP partition.
> >
> > An example usage of this driver is the following:
> >
> > [...]
> >
> >  drivers/misc/Kconfig                |  23 ++
> >  drivers/misc/fw_loader/Makefile     |   1 +
> >  drivers/misc/fw_loader/fip_loader.c | 558 ++++++++++++++++++++++++++++++++++++
> >  drivers/misc/fw_loader/internal.h   |   2 +
> >  4 files changed, 584 insertions(+)
> 
> > diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> > @@ -0,0 +1,558 @@
> > +	lbaint_t offset = part_info->start + part_offset;
> > +	lbaint_t pos, to_read, read = 0;
> > +	lbaint_t blkstart, blkcnt;
> > +	char *read_buf;
> > +	size_t size;
> > +	int i, ret;
> > +
> > +	read_buf = malloc(desc->blksz);
> > +	if (!read_buf)
> > +		return -ENOMEM;
> > +
> > +	size = min(firmwarep->size, (size_t)ent->size - firmwarep->offset);
> > +	blkcnt = BLOCK_CNT(size, desc);
> > +	blkstart = ent->offset_address + firmwarep->offset;
> > +	pos = do_div(blkstart, desc->blksz);
> 
> One thing I'd like to check: the move to lbaint_t in v9 breaks 32-bit
> builds. Without CONFIG_SYS_64BIT_LBA, lbaint_t is a ulong, so on
> 32-bit ARM blkstart is only 32 bits wide. do_div() needs a u64, so
> __div64_32() then writes 64 bits through a pointer to a 32-bit
> variable. Building Cubietruck_defconfig with CONFIG_FIP_LOADER=y
> gives:
> 
>     include/div64.h:220:32: warning: right shift count >= width of type
>     include/div64.h:224:36: warning: passing argument 1 of
> '__div64_32' from incompatible pointer type
> 
> blkstart is a byte offset here, not an LBA, so please can you make it a u64?
> 
> > diff --git a/drivers/misc/fw_loader/fip_loader.c b/drivers/misc/fw_loader/fip_loader.c
> > @@ -0,0 +1,558 @@
> > +		to_read = min(desc->blksz,
> > +			      (lbaint_t)(sizeof(*hdr) - read));
> 
> The same build also gives 'comparison of distinct pointer types'
> warnings from min() here and in blk_read_fip_toc_entry(). That build
> has no CONFIG_SYS_64BIT_LBA, so lbaint_t matches blksz, but size_t is
> unsigned int on 32-bit ARM, so the two min() calls in
> blk_read_fip_firmware() that cast to size_t still warn. With
> CONFIG_SYS_64BIT_LBA=y, lbaint_t becomes uint64_t, so these two calls
> warn as well. Using min_t() for all four would avoid this. No in-tree
> board enables FIP_LOADER yet, so CI won't catch it. It would be worth
> building a 32-bit board with it enabled before v10.
> 
> With those two nits fixed:
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 

I compiled for qemu_arm_defconfig and used min_t(lbaint_t...

I think should be enough. (I also verified 64bit target...)

-- 
	Ansuel

  reply	other threads:[~2026-10-26 13:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 19:00 [PATCH v9 0/8] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Christian Marangi
2026-10-23 19:00 ` [PATCH v9 1/8] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
2026-10-23 19:00 ` [PATCH v9 2/8] misc: fs_loader: reorganize and split to FS loader and FW UCLASS Christian Marangi
2026-10-26 12:37   ` Simon Glass
2026-10-23 19:00 ` [PATCH v9 3/8] misc: fw_loader: implement generic get_fw_loader_from_node() Christian Marangi
2026-10-23 19:00 ` [PATCH v9 4/8] misc: fs_loader: validate requested offset on reading file Christian Marangi
2026-10-26 12:37   ` Simon Glass
2026-10-23 19:00 ` [PATCH v9 5/8] misc: fw_loader: implement request_firmware_size() OP Christian Marangi
2026-10-26 12:37   ` Simon Glass
2026-10-23 19:00 ` [PATCH v9 6/8] doc: dtbinding: Update documentation for Generic Firmware loader Christian Marangi
2026-10-26 12:37   ` Simon Glass
2026-10-23 19:00 ` [PATCH v9 7/8] misc: fw_loader: introduce FIP loader driver Christian Marangi
2026-10-26 12:37   ` Simon Glass
2026-10-26 13:36     ` Christian Marangi [this message]
2026-10-23 19:00 ` [PATCH v9 8/8] test: dm: Add test for FW Loader feature Christian Marangi
2026-10-26 15:08   ` Simon Glass
2026-10-26 15:12     ` Christian Marangi (Ansuel)

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=6adf5769.950cae81.ea04b.740f@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=alchark@flipper.net \
    --cc=anshuld@ti.com \
    --cc=aristo.chen@canonical.com \
    --cc=casey.connolly@linaro.org \
    --cc=daniel@makrotopia.org \
    --cc=hs@nabladev.com \
    --cc=jbx6244@gmail.com \
    --cc=lucienzx159@gmail.com \
    --cc=m.schwan@phytec.de \
    --cc=marcello.bauer@9elements.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mateuslima.ti@gmail.com \
    --cc=me@ziyao.cc \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=n-francis@ti.com \
    --cc=neil.armstrong@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=quentin.schulz@cherry.de \
    --cc=rs@ti.com \
    --cc=sjg@chromium.org \
    --cc=tan.siewert@9elements.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=xypron.glpk@gmx.de \
    /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.