Re: [PATCH v5 2/2] media: iris: Add Gen2 firmware autodetect and fallback

From: Dmitry Baryshkov

Date: Wed May 13 2026 - 10:59:25 EST


On Tue, May 12, 2026 at 10:03:08PM +0530, Vikash Garodia wrote:
>
> On 5/12/2026 8:51 PM, Dmitry Baryshkov wrote:
> > From: Dikshita Agarwal<dikshita.agarwal@xxxxxxxxxxxxxxxx>
> >
> > Some Iris platforms support both Gen1 and Gen2 HFI firmware images.
> > Update the firmware loading logic to handle this generically by
> > preferring Gen2 when available, while safely falling back to Gen1
> > when required.
> >
> > The firmware loading logic is updated with the following priority:
> > 1. Device Tree (`firmware-name`): If specified, load unconditionally.
> > 2. Gen2 default : If no DT override exists, select the Gen2 firmware
> > descriptor when present and attempt to load the corresponding
> > firmware image.
> > 3. Gen1 Fallback: If loading the Gen2 firmware fails and a Gen1
> > descriptor is available, retry with the Gen1 firmware image.
> >
> > When a platform provides both Gen1 and Gen2 firmware descriptors and the
> > firmware is loaded via a DT override, the driver detects the
> > firmware generation at runtime before authentication by inspecting
> > the firmware data. The firmware is classified as Gen2 if the
> > QC_IMAGE_VERSION_STRING starts with "vfw" or matches the
> > "video-firmware.N.M" format with N >= 2.
> >
> > If a Gen1 firmware image is detected in this case, the driver switches
> > to the Gen1 firmware descriptor and associated platform data so that
> > the correct HFI implementation is used.
> >
> > This change makes firmware generation detection platform‑agnostic,
> > preserves DT overrides, prefers newer Gen2 firmware when available,
> > and maintains compatibility with platforms that only support Gen1.
> >
> > Signed-off-by: Dikshita Agarwal<dikshita.agarwal@xxxxxxxxxxxxxxxx>
> > Co-developed-by: Dmitry Baryshkov<dmitry.baryshkov@xxxxxxxxxxxxxxxx>
> > Signed-off-by: Dmitry Baryshkov<dmitry.baryshkov@xxxxxxxxxxxxxxxx>
> > ---
> > drivers/media/platform/qcom/iris/iris_firmware.c | 105 +++++++++++++++++----
> > .../platform/qcom/iris/iris_platform_common.h | 6 +-
> > .../media/platform/qcom/iris/iris_platform_vpu2.c | 11 ++-
> > .../media/platform/qcom/iris/iris_platform_vpu3x.c | 8 +-
> > drivers/media/platform/qcom/iris/iris_probe.c | 4 -
> > drivers/media/platform/qcom/iris/iris_vidc.c | 3 +
> > 6 files changed, 105 insertions(+), 32 deletions(-)
> >
> > diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c b/drivers/media/platform/qcom/iris/iris_firmware.c
> > index 1a476146d758..64a2170bf538 100644
> > --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> > +++ b/drivers/media/platform/qcom/iris/iris_firmware.c
> > @@ -16,20 +16,95 @@
> > #define MAX_FIRMWARE_NAME_SIZE 128
> > -static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)
> > +/* Detect Gen2 firmware by scanning the blob for:
> > + * QC_IMAGE_VERSION_STRING=<version>
> > + * and then checking:
> > + * - version starts with "vfw", OR
> > + * - version matches "video-firmware.N.M" with N >= 2
> > + */
> > +
> > +static bool iris_detect_gen2_from_fwdata(const u8 *data, size_t size)
> > +{
> > + const char *marker = "QC_IMAGE_VERSION_STRING=";
> > + const size_t mlen = strlen(marker);
> > + int major = 0, minor = 0;
> > + char version_buf[64];
> > + size_t max;
> > +
> > + max = (size > mlen) ? size - mlen : 0;
> > + for (size_t i = 0; i < max; i++) {
>
> check for comment in previous version.

I will comment on your size suggestion at the v4 discussion.

>
> Regards,
> Vikash

--
With best wishes
Dmitry