| Message ID | 20260415183250.3031030-7-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCQ4XFG47UFRB2VT77HAMGQEEV7CE6I@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com
[209.85.128.70])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 8AC1F3F2F2
for <linux-amarula@patchwork.amarulasolutions.com>;
Wed, 15 Apr 2026 20:33:15 +0200 (CEST)
Received: by mail-wm1-f70.google.com with SMTP id
5b1f17b1804b1-488cc31ea57sf45801615e9.3
for <linux-amarula@patchwork.amarulasolutions.com>;
Wed, 15 Apr 2026 11:33:15 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1776277995; cv=pass;
d=google.com; s=arc-20240605;
b=HJjdGouNjlbQWRj0DlMqVZIu4U2iJ2aTh7vxqd7pdAp63XQzsejuUOJUjrdXp30iwO
p+pttU3VMOWuDMpIVQta0G3awbhw3Up1kBYjnHwGXEtzm2bHVNZ0HPnyqKWVNSQqRenv
/jL+xDgczy1Y8RaKn/B0gkPYfTfEPO2LRT4PJpfvmuGkaM2J31+thNxcr5IHlgAwququ
LOHWydreJOAj3L9ys4NGIgjL+GHUcPfxVFTixx8JoTMSdMI7Ivv0nPZgmd7ee55B5STT
dGcxC0z5I0/mioSHz7EV9VaF0ha53WFiXWp/a+hz/GwC2/3v3PD7e7UWDQD5vyzRKzSL
ECgQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=fHtCV5w8Fi9fYXYt7hPmd63f3+gGQAJl+tpWRUPpRZk=;
fh=Vg7vsSvdCKT485gG9nltxKFvu6eBXH6YikSJmalNMoI=;
b=YfsvEujYYF9pwCeDcprIORkJt0HLTatHD/+3ZFKLPgrZBpY5TH+FZeZQqXfA4ekkks
7DnLdH3GtJRAVh5JyxfOgWb9n6AK1eZsoJ6VCFGYJfEYaAm26zOO6ynZwW22o1q5afp+
6uqyzk/rLSOp8hnHIM+wrT5JuTfgETEr2X1pSQjkhD5X6cGxow0nol79EL2QUxq9vGCI
utMiwt94V4HMuP6JeKFazwnc0DRL/Z7vURTM+u/CS6EmyJEUs4qq+ix9+bZj6zq7f9yD
nSu8Pd5rmkx26YdRWVspofPQ3RG1owXe/lFxiQAsSwa6HHVzD/guw76F0T8XlhC0G4Ch
7Mlg==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=YzkXFoYT;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amarulasolutions.com; s=google; t=1776277995; x=1776882795;
darn=patchwork.amarulasolutions.com;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:x-original-authentication-results
:x-original-sender:mime-version:references:in-reply-to:message-id
:date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
bh=fHtCV5w8Fi9fYXYt7hPmd63f3+gGQAJl+tpWRUPpRZk=;
b=dSi/3SUavyo9MGEhL4aSfjvg10zY6tJvO50PgfvjiJoGZphiyUukkbtw0kX7rF+0G3
63m8b1nzfxnYDp55rxjDl3jlo/uyAxWtfCQFbfsFKX8i4wAxqoGoTQaIcMIRHyBeR+iX
1q4JTJZz9xhF4VoFUjoHD9oEkudixtEXvj98E=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20251104; t=1776277995; x=1776882795;
h=list-unsubscribe:list-archive:list-help:list-post
:x-spam-checked-in-group:list-id:mailing-list:precedence
:x-original-authentication-results:x-original-sender:mime-version
:references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg
:x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=fHtCV5w8Fi9fYXYt7hPmd63f3+gGQAJl+tpWRUPpRZk=;
b=CBKxNk1xm7zMapPFsCcdOMaaCXj7F4vz/uBx21I+03ob8Q+M48jd7TtoSCT7qZTlTH
eZrkGLtwOy6Ow0CT4wn1B/iYCrCORtqOEp1Zvcshf2uLze8ZxSxzINj6hAJ8kr2VrGHE
yz7ft+wKcadQivJaK4qqowuj3OGiLaSoTdAqWgED2MwfEhu/84f02GQPrwb7Qt1Hhqgx
OirVBK2oElmKtqmJhXr/XcJjMQ2rywD1RBd131MDqla/NPPpt1qj0IIMxdtJrs9dBX0E
GjAfO8yL6K9inzJymTj2tsi3DPD85Xp1vpc2LIsVTMxqaaiCxQnB5R/QjbjFMRBvWUvL
FOjA==
X-Forwarded-Encrypted: i=2;
AFNElJ9/CdM4YlGr6L5aNIHUMvOEq8VvpkWO/XHIyJjKkdsN/9QLE+gjxcH4CCBW9dLXK58n8JZB13lCy0lddDta@patchwork.amarulasolutions.com
X-Gm-Message-State: AOJu0YxslsqomAH24pZZgQtNdaxrUAtTqRLhEXZT3SPaz6iFU+LXMrY/
0mb77mAoUY4kkbKD8++1+FuSRkhm1RYefn0fMctpco7ypVvtpYRu94WvctnLfof9PBLJJrmg/r/
wCQ==
X-Received: by 2002:a05:600c:a416:b0:488:7f69:4abf with SMTP id
5b1f17b1804b1-488d67f946bmr240224685e9.12.1776277995166;
Wed, 15 Apr 2026 11:33:15 -0700 (PDT)
X-BeenThere: linux-amarula@amarulasolutions.com;
h="AYAyTiKvKbDa/yZF6ObPwtgE4KRT1PODc3ZKG238jz0WRXLpVg=="
Received: by 2002:a05:600c:648a:b0:488:9454:b51 with SMTP id
5b1f17b1804b1-488f4a708a9ls512815e9.0.-pod-prod-05-eu; Wed, 15 Apr 2026
11:33:13 -0700 (PDT)
X-Received: by 2002:a05:600c:5249:b0:485:7f02:afd5 with SMTP id
5b1f17b1804b1-488d680079bmr305210105e9.13.1776277993462;
Wed, 15 Apr 2026 11:33:13 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1776277993; cv=none;
d=google.com; s=arc-20240605;
b=O1rEHcAMnqdmSfrxHBD4RHPRD01w/s1BqwJALyIYbdUNptwQQAQAqoGAI+Lu7XxgC5
PY4zoCD1ZZdBnkA8f/Y5mH3DsmmKYkdbIYQFfXkzJgGbmxk/hbVIBnLJvTsTiqzU5pRe
b7vN8VV6LDj9IhHrJVPAO2BUfgUPvo+C7/iCCJlHn2MSMC2Z2ErEOF48ZIZtrUR7LBya
MemK38BEdW9jKzh6DjaJbKu37L3lKNNx4rdLoebFungH/Ep3EH3+0yWNoHgeRnJP5GIY
wHr6V87/D4xZKwQY+jbHaxw5NpM3zvyVrSt82TY4sN0rxWp7pzTtttdbP6nZzg5g4FCh
6Spw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=uCAR4bHfuzLtCYDWhI3svjkqvfHud+Ornn0vBeRVnY0=;
fh=p7hMND4jtPHylywAszv7PI5Sz1LnGjCgu6NzVMiguXk=;
b=T8JQQTB0f/OsbKQS9pr9u/nkklvTfo9bX2EDeduPTC5U44WkfvJ4fbuaR0Y06/Be0/
kyUJbUS4DdDR6z4Mq+4Ddrl3rKfYhoEvhyxzh3Yd/yBbRHQfyqgdueOg3ns/pAASklW9
ebALqKMPKmOrBJS6WEfBYHkjvba+AUxOwHXyRWPjyukH+bfi7cnahoYIjVPJf2GY0RBK
L5TJpwitvTltCjRI456ZN2UqjCvQPzgbfmpCN3H0h43h7L2M/jIzM/VMDUr1x5VVjCmb
ZjnzdsPZM582g9yL4xmeX+t/MFmoQdnxEplfb92BTfyP341WsiLOMla4oofCjfy1ag9C
RP3w==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=YzkXFoYT;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
Received: from mail-sor-f41.google.com (mail-sor-f41.google.com.
[209.85.220.41])
by mx.google.com with SMTPS id
5b1f17b1804b1-488f1e55bb0sor5554975e9.15.2026.04.15.11.33.13
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Wed, 15 Apr 2026 11:33:13 -0700 (PDT)
Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Gm-Gg: AeBDies08S+RIlGHSWq22aW2w8virEKMYh1v2ysdEk8euceNnVZALy1TPeJ3NWymtq+
YjgIbnGf7rU0B4EMchd5QQvISzL3wYgNU9SP19IJttI/cxzV+Gv69k0ve3doZzVA2408Rwwthuq
AQOKygd1OS4ko80LiPIWqUbsNSLqlU7Z5/xfLcJTsPR5x8RT78z6/OYEdkTcbrLjH+Cdlk9HE/X
B2SChpuaGhs5pddPBjqOxhiiVMhElZZSGPzvQ4qmPAWe1lLhpJOA5Dmj9lsSwbYVxONjGKUPlzh
tYRmUdmp21gtL7Kds1kkFVoMPS8GJJPcH7gV5Z0R43hJyGIxlvIOaVtO784Qt/meuasokEItX8B
sg6cSOfFApJvj2Ut2a1tnShgzZYNBLOjn9HZyggm8EUWKWFCujVcKDGF8t24sGl9oaTs2oLkMm2
AdI0Yl63AGhR8aM9lpxJFBmz0Foh22e5H/Uqevyru6c7cPGXr83gIMAYG6aoqWDw10cGpRlHNKC
Ja/lVvvnJ9bYBmoaHgsu0uZfzKELOI0UzuL22ALf32Yfmc69T73N8t6/Q==
X-Received: by 2002:a05:600c:8b2f:b0:485:3423:727d with SMTP id
5b1f17b1804b1-488d688d46cmr293152095e9.26.1776277993020;
Wed, 15 Apr 2026 11:33:13 -0700 (PDT)
Received: from dario-ThinkPad-P14s-Gen-5.amarulasolutions.com ([2.196.40.93])
by smtp.gmail.com with ESMTPSA id
5b1f17b1804b1-488f0e72980sm34953115e9.5.2026.04.15.11.33.11
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 15 Apr 2026 11:33:12 -0700 (PDT)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: u-boot@lists.denx.de
Cc: linux-amarula@amarulasolutions.com,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Kory Maincent <kory.maincent@bootlin.com>,
Michal Simek <michal.simek@amd.com>,
Padmarao Begari <padmarao.begari@amd.com>,
Sughosh Ganu <sughosh.ganu@arm.com>,
Tom Rini <trini@konsulko.com>
Subject: [PATCH v3 6/7] fwu: add helper to get image GUID by type and bank
index
Date: Wed, 15 Apr 2026 20:31:33 +0200
Message-ID: <20260415183250.3031030-7-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20260415183250.3031030-1-dario.binacchi@amarulasolutions.com>
References: <20260415183250.3031030-1-dario.binacchi@amarulasolutions.com>
MIME-Version: 1.0
X-Original-Sender: dario.binacchi@amarulasolutions.com
X-Original-Authentication-Results: mx.google.com; dkim=pass
header.i=@amarulasolutions.com header.s=google header.b=YzkXFoYT;
spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com
designates 209.85.220.41 as permitted sender)
smtp.mailfrom=dario.binacchi@amarulasolutions.com;
dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com;
dara=neutral header.i=@amarulasolutions.com
Content-Type: text/plain; charset="UTF-8"
Precedence: list
Mailing-list: list linux-amarula@amarulasolutions.com;
contact linux-amarula+owners@amarulasolutions.com
List-ID: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
Support metadata-driven A/B boot for STM32MP25
|
|
Commit Message
Dario Binacchi
April 15, 2026, 6:31 p.m. UTC
Introduce fwu_mdata_get_image_guid() to retrieve a specific image GUID
from the FWU metadata based on the bank index and image type GUID.
This allows identifying the correct partition in multi-bank (A/B)
scenarios, ensuring the correct image is targeted depending on the
current bank.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
Changes in v3:
- Add kerneldoc comment for fwu_mdata_get_image_guid() above its
declaration in fwu.h.
Changes in v2:
- Add kerneldoc comment for fwu_mdata_get_image_guid().
- Pass efi_guid_t by pointer for consistency.
include/fwu.h | 11 +++++++++++
lib/fwu_updates/fwu.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
Comments
Hi Dario, On 2026-04-15T18:31:27, Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote: > fwu: add helper to get image GUID by type and bank index > > Introduce fwu_mdata_get_image_guid() to retrieve a specific image GUID > from the FWU metadata based on the bank index and image type GUID. > > This allows identifying the correct partition in multi-bank (A/B) > scenarios, ensuring the correct image is targeted depending on the > current bank. > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> > > include/fwu.h | 11 +++++++++++ > lib/fwu_updates/fwu.c | 33 +++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c > @@ -243,6 +243,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part) > +int fwu_mdata_get_image_guid(efi_guid_t *image_guid, > + const efi_guid_t *image_type_guid, u32 bank_index) > +{ > + struct fwu_data *data = &g_fwu_data; > + struct fwu_image_entry *image; > + int i; > + > + if (bank_index >= data->num_banks) > + return -EINVAL; > + > + for (i = 0; i < data->num_images; i++) { Using data->num_images here is the proper approach for new code. Some existing functions still use CONFIG_FWU_NUM_IMAGES_PER_BANK in their loops but using the runtime value is more correct, especially since FWU v2 populates num_images from the metadata itself. Is there a unit test for this new function? Since you have added tests for the part command in patches 2, 3, and 5, it would be good to add coverage here as well, e.g. testing success, -EINVAL for invalid bank index, and -ENOENT for missing image type. Reviewed-by: Simon Glass <sjg@chromium.org> To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
On Wed, 15 Apr 2026 at 21:33, Dario Binacchi <dario.binacchi@amarulasolutions.com> wrote: > > Introduce fwu_mdata_get_image_guid() to retrieve a specific image GUID > from the FWU metadata based on the bank index and image type GUID. > > This allows identifying the correct partition in multi-bank (A/B) > scenarios, ensuring the correct image is targeted depending on the > current bank. > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> > > --- > > Changes in v3: > - Add kerneldoc comment for fwu_mdata_get_image_guid() above its > declaration in fwu.h. > > Changes in v2: > - Add kerneldoc comment for fwu_mdata_get_image_guid(). > - Pass efi_guid_t by pointer for consistency. > Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> > include/fwu.h | 11 +++++++++++ > lib/fwu_updates/fwu.c | 33 +++++++++++++++++++++++++++++++++ > 2 files changed, 44 insertions(+) > > diff --git a/include/fwu.h b/include/fwu.h > index 9cee8fb085cb..68a51fb4296b 100644 > --- a/include/fwu.h > +++ b/include/fwu.h > @@ -396,6 +396,17 @@ void fwu_populate_mdata_image_info(struct fwu_data *data); > */ > int fwu_get_mdata_size(uint32_t *mdata_size); > > +/** > + * fwu_mdata_get_image_guid() - Get image GUID for a type and bank > + * @image_guid: Pointer to be filled with the found image GUID > + * @image_type_guid: Pointer to the image type GUID to search for > + * @bank_index: Index of the bank > + * > + * Return: 0 if OK, -ve on error > + */ > +int fwu_mdata_get_image_guid(efi_guid_t *image_guid, > + const efi_guid_t *image_type_guid, u32 bank_index); > + > /** > * fwu_state_machine_updates() - Update FWU state of the platform > * @state: FWU bank state > diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c > index 37c613014d18..e5e4907a2d43 100644 > --- a/lib/fwu_updates/fwu.c > +++ b/lib/fwu_updates/fwu.c > @@ -243,6 +243,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part) > return 0; > } > > +/** > + * fwu_mdata_get_image_guid() - Get image GUID for a type and bank > + * @image_guid: Pointer to be filled with the found image GUID > + * @image_type_guid: Pointer to the image type GUID to search for > + * @bank_index: Index of the bank > + * > + * Return: 0 if OK, -ve on error > + */ > +int fwu_mdata_get_image_guid(efi_guid_t *image_guid, > + const efi_guid_t *image_type_guid, u32 bank_index) > +{ > + struct fwu_data *data = &g_fwu_data; > + struct fwu_image_entry *image; > + int i; > + > + if (bank_index >= data->num_banks) > + return -EINVAL; > + > + for (i = 0; i < data->num_images; i++) { > + image = &data->fwu_images[i]; > + > + if (!guidcmp(image_type_guid, &image->image_type_guid)) { > + struct fwu_image_bank_info *bank; > + > + bank = &image->img_bank_info[bank_index]; > + guidcpy(image_guid, &bank->image_guid); > + return 0; > + } > + } > + > + return -ENOENT; > +} > + > /** > * fwu_mdata_copies_allocate() - Allocate memory for metadata > * @mdata_size: Size of the metadata structure > -- > 2.43.0 > To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
diff --git a/include/fwu.h b/include/fwu.h index 9cee8fb085cb..68a51fb4296b 100644 --- a/include/fwu.h +++ b/include/fwu.h @@ -396,6 +396,17 @@ void fwu_populate_mdata_image_info(struct fwu_data *data); */ int fwu_get_mdata_size(uint32_t *mdata_size); +/** + * fwu_mdata_get_image_guid() - Get image GUID for a type and bank + * @image_guid: Pointer to be filled with the found image GUID + * @image_type_guid: Pointer to the image type GUID to search for + * @bank_index: Index of the bank + * + * Return: 0 if OK, -ve on error + */ +int fwu_mdata_get_image_guid(efi_guid_t *image_guid, + const efi_guid_t *image_type_guid, u32 bank_index); + /** * fwu_state_machine_updates() - Update FWU state of the platform * @state: FWU bank state diff --git a/lib/fwu_updates/fwu.c b/lib/fwu_updates/fwu.c index 37c613014d18..e5e4907a2d43 100644 --- a/lib/fwu_updates/fwu.c +++ b/lib/fwu_updates/fwu.c @@ -243,6 +243,39 @@ int fwu_sync_mdata(struct fwu_mdata *mdata, int part) return 0; } +/** + * fwu_mdata_get_image_guid() - Get image GUID for a type and bank + * @image_guid: Pointer to be filled with the found image GUID + * @image_type_guid: Pointer to the image type GUID to search for + * @bank_index: Index of the bank + * + * Return: 0 if OK, -ve on error + */ +int fwu_mdata_get_image_guid(efi_guid_t *image_guid, + const efi_guid_t *image_type_guid, u32 bank_index) +{ + struct fwu_data *data = &g_fwu_data; + struct fwu_image_entry *image; + int i; + + if (bank_index >= data->num_banks) + return -EINVAL; + + for (i = 0; i < data->num_images; i++) { + image = &data->fwu_images[i]; + + if (!guidcmp(image_type_guid, &image->image_type_guid)) { + struct fwu_image_bank_info *bank; + + bank = &image->img_bank_info[bank_index]; + guidcpy(image_guid, &bank->image_guid); + return 0; + } + } + + return -ENOENT; +} + /** * fwu_mdata_copies_allocate() - Allocate memory for metadata * @mdata_size: Size of the metadata structure