[PATCH v2 1/2] FWU: Add platform hook support for fwu metata

Begari, Padmarao Padmarao.Begari at amd.com
Tue Jul 8 15:09:37 CEST 2025


[AMD Official Use Only - AMD Internal Distribution Only]

Hi Sughosh,

> From: Sughosh Ganu <sughosh.ganu at linaro.org>
> Sent: Monday, July 7, 2025 5:19 PM
> To: Begari, Padmarao <Padmarao.Begari at amd.com>
> Cc: u-boot at lists.denx.de; git (AMD-Xilinx) <git at amd.com>; Simek, Michal
> <michal.simek at amd.com>
> Subject: Re: [PATCH v2 1/2] FWU: Add platform hook support for fwu metata
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Mon, 7 Jul 2025 at 16:09, Padmarao Begari <padmarao.begari at amd.com>
> wrote:
> >
> > FWU metadata information is unavailable for platform-specific
> > operations since FWU initialization has not yet occurred.
> > The initialization function is invoked as part of the main loop event.
> > To address this, the FWU platform hook function is introduced during
> > FWU initialization, allowing metadata processing with
> > platform-specific operations.
> >
> > Signed-off-by: Padmarao Begari <padmarao.begari at amd.com>
> > ---
> >  include/fwu.h         | 11 +++++++++++
> >  lib/fwu_updates/fwu.c | 18 ++++++++++++++++++
> >  2 files changed, 29 insertions(+)
> >
> > diff --git a/include/fwu.h b/include/fwu.h index
> > 6441de370c9..8d0b856cc81 100644
> > --- a/include/fwu.h
> > +++ b/include/fwu.h
> > @@ -129,6 +129,17 @@ int fwu_read_mdata(struct udevice *dev, struct
> > fwu_mdata *mdata,  int fwu_write_mdata(struct udevice *dev, struct fwu_mdata
> *mdata,
> >                     bool primary, uint32_t size);
> >
> > +/**
> > + * fwu_platform_hook() - Hook the given FWU data copy
>
> This can be phrased better. Something like "platform specific processing with FWU
> metadata".
>
OK
> > + * @dev: FWU metadata device
> > + * @data: FWU metadata
> > + *
> > + * It is a platform-specific function that processes fwu metadata.
>
> More details please. This is an API. Something like, "Provide a platform specific
> function for processing with the FWU metadata".
OK

>
> > + *
> > + * Return: 0 if OK, -ve on error
> > + */
> > +int fwu_platform_hook(struct udevice *dev, struct fwu_data *data);
> > +
> >  /**
> >   * fwu_get_mdata() - Read, verify and return the FWU metadata
> >   *
> > diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c index
> > 7f085a0211f..9e913a04ed4 100644
> > --- a/lib/fwu_updates/fwu.c
> > +++ b/lib/fwu_updates/fwu.c
> > @@ -655,6 +655,16 @@ __weak void fwu_plat_get_bootidx(uint *boot_idx)
> >                 *boot_idx = 0; /* Dummy value */  }
> >
> > +/**
> > + * fwu_platform_hook() - Hook the given FWU data copy
> > + *
> > + * Return: 0 if OK, -ve on error
> > + */
> > +__weak int fwu_platform_hook(struct udevice *dev, struct fwu_data
> > +*data) {
> > +       return 0;
> > +}
> > +
> >  /**
> >   * fwu_update_checks_pass() - Check if FWU update can be done
> >   *
> > @@ -712,6 +722,7 @@ static int fwu_boottime_checks(void)  {
> >         int ret;
> >         u32 boot_idx, active_idx;
> > +       struct fwu_data *data;
> >
> >         ret = uclass_first_device_err(UCLASS_FWU_MDATA, &g_dev);
> >         if (ret) {
> > @@ -770,6 +781,13 @@ static int fwu_boottime_checks(void)
> >         if (!ret)
> >                 boottime_check = 1;
> >
> > +       data = fwu_get_data();
> > +       ret = fwu_platform_hook(g_dev, data);
> > +       if (ret && ret != -ENOSYS) {
>
> Is there any scenario for returning ENOSYS. This is not a DM uclass
> call where an operation might not be defined.
>
No, will update it

Regards
Padmarao

> -sughosh
>
> > +               log_err("fwu_platform_hook() failed\n");
> > +               return ret;
> > +       }
> > +
> >         return 0;
> >  }
> >  EVENT_SPY_SIMPLE(EVT_MAIN_LOOP, fwu_boottime_checks);
> > --
> > 2.25.1
> >


More information about the U-Boot mailing list