From patchwork Sun Apr 26 15:35:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4560 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id F41DA3F206 for ; Sun, 26 Apr 2026 17:36:32 +0200 (CEST) Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43fe791a398sf7292030f8f.0 for ; Sun, 26 Apr 2026 08:36:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777217792; cv=pass; d=google.com; s=arc-20240605; b=W+ykkndfLM+BASjTQATIbLZlKb4EsFk0phguBm28Gi6QLVdD5/+RhWAsYSz+kXWcBP CSWauvF2haULdCuLuVdOcx5j33aGlIUCBYYJSMSQv3UL0NawLV0euGgfVgfy83x9rt6U J8wK/sk8llXTyiLEMm22yD0ttzKQGlRcvhrggKFaJRtroyaA8TAQADBDBEJxNdTFHDAb jKF0VSelEnKL362vdq9Ir8KjAUsyWQVl8CH3bCMEo2upOLgAOtNg3nPPIMxGX91e6lK3 JKuHfTarEK5xcuVSBV+kzUhrGUrtcxJG2egLNn4x2wpxzkmKyIz0F3uuuengUZ0YGLwT 5tUg== 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=mbs+oY9F4U9suQU5Yj2NYWQjULs3NL4eqMr6z4K9NVc=; fh=NUEIshl6XbUlcAnHrTE2blvgbWqV3/O4BjpFWM4pPr4=; b=MZ+I1ZRUJjcGKi0bnjY4IEA+NK3mb/5mUU2NLWvno1++WSV+2jKL0/8mNVxStLwCCq NBS91KP7zCGehvUTDCBT4xpCnXTA2vcYMkozx64EoS97bmFB9tdByVHGjUPIGseFbtW1 VoVA4X14CPr1PH/9kzatK2KkkyAlh7+mjVSYoia8E0YX1LnijP36QxUwtYsHub2dpHQX gY/dMjyp30ymYIMIjqUncgBYFU5aEK1npFJ2tIbYhzWiEf24NoL1yoNfdU/ammZ+yyar IEOXRD7asInTLhAvbdPBLC27H/srW97lgrpz4BWMQqvN4c10OU9FYBGp/mbVf64Ekrcb R7+w==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="ETn43/ZI"; 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=1777217792; x=1777822592; 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=mbs+oY9F4U9suQU5Yj2NYWQjULs3NL4eqMr6z4K9NVc=; b=XyiC62F6V0tpIlm4Kh4xTKVIl651yfuu4xQV0dBC4cGXX6I+4KSgOhtg9VMtctOHXI nuLmjmJ7SadfefEbAl4hpzw2qJHB++NtTkF7khyOKMlZ2rWhYewgJfw+sW94/1Uv0KwT VhbSDunn/Xh7yBfFsY0xvmzncDnG7bg3xX/VU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777217792; x=1777822592; 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=mbs+oY9F4U9suQU5Yj2NYWQjULs3NL4eqMr6z4K9NVc=; b=BX/ggttGdkbk1HsaX0xOaw8NIykx/KlnKRr7i6hEKMUvcrjxdaoKclWxl4Dye4G+bd W6j/bxHhZ3tazFGUOIvh0eHOUpfpk8mjeWxEKA8JO4Ug4iZeMVswfCdeg0gYc5otY9nx g4red0lQDiqMY6CB88Q48RJKkpRd0amZuBk0K5ou28pXQOEq9EGJ0hWQfdohXEZ0U0Sz q0eOwFglOB9gJtlggqJbuyPtjlXzfiX2R1riTBSDw2F2WyyRPXRb0CI93R+0TuOB/Qyn be9eiw45irKafLySpOTndch/iB/d3GbMpJ4m6EiSJnEj7qN+fG5x9YssEn7NhOh3hGlL SdWw== X-Forwarded-Encrypted: i=2; AFNElJ/mRavpU3Ia1AU6RZA5Pj0A904JXTuXxGgb9XefMUFtV5P3lU1Rt7SVkpAeM8eZ8EYNzDc1mzPOGsfFhl3a@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yw0J1pn0gznwX1DSvz0w+xJAgXQF9S4rwLu2xU21n/0//5T9eLX 5LkYTMDGyqo1gnGA2C5NX6Rx+M3muBCc5+RZns0jCMqVEQmgHcdUu7f9hQgqixSEFmfbPg== X-Received: by 2002:a05:600c:8908:b0:48a:58e1:6d02 with SMTP id 5b1f17b1804b1-48a58e16eb2mr230250475e9.19.1777217792619; Sun, 26 Apr 2026 08:36:32 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="AYAyTiJRC4rjxbkfd3sluXJexgX11Xmgw6hBvVXHnH8jgYzKXw==" Received: by 2002:a05:600c:a404:b0:485:2e9c:9e81 with SMTP id 5b1f17b1804b1-488f4b0f219ls64514735e9.1.-pod-prod-09-eu; Sun, 26 Apr 2026 08:36:31 -0700 (PDT) X-Received: by 2002:a05:600c:a105:b0:485:3a03:ceca with SMTP id 5b1f17b1804b1-488fb7826femr396488045e9.23.1777217790967; Sun, 26 Apr 2026 08:36:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777217790; cv=none; d=google.com; s=arc-20240605; b=MlorU9yAnnCyF+WORXVhIkVUvX3uDfALkQj+noQXlWEf+VkjzlzfuKnmF0mqi47oQY Vy8EPQZ/WqkvbLtfiV6JFq5RyPeW3ol9+QhLDJWjw2LfPPZY8G9kv81mXlWTPBHsy0ry 92huZePHGZKg/B87bV1j5fDchlMHw/YBTp0+lBhMKm6SEBSK5nwJnxdIblDRi//s2bng nAda/lGHrv240inJ1AQsHweDIHn6ahhCmnST0f4V/eGpApOSlc3oLlJzmeKeohWgGe/q SJBazMcSrDEED1EgWPSYzRXnk8GHoPC0vjGNtyT7r8v9PuBhOlJYB+dj6/mdtqg2zYE7 c1vg== 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=06sczhgbtWdNK8ERusWYcOlhVyUuYZr9/KPOpcPmhKw=; fh=63tQyC28C9/eYaWpq6aXRoXJf0iCc3tAFavW3mffgU0=; b=QzeJuTg7ZSLBuJ5BQFmqx+ITvQ/F+Mh66oQRPLAPN/hRhEqdT7hOfQWrDVWC5rDA3D TjYfFTk9+qKwEyBfpTOuD01/D1sbfrWEA6bPZsrERLT7s0yjaZw50V4BVcyS4VATtSbP t70RBOkiRmDVjf61Gv6a3rZnZrimIxIOhGSLAMd//Mr12jnW6Z6mfQquTDfEjxQdpQFC iuOyLYjQ31YnISFMDAYQ8tU/QFFjj3xL8+dT8iyyh+0qQic1gmVTi7UjwYsy/vcAoue3 frTNB6B88Uz54bSZ6B65M9x1W3aqqMfg4d7e3Utg6HVLC1GNXey6PTTV7QPSMVGajtjg IJGA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="ETn43/ZI"; 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-489d07644e8sor32553445e9.15.2026.04.26.08.36.30 for (Google Transport Security); Sun, 26 Apr 2026 08:36:30 -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: AeBDieseGGGvV+nw7KVoDhTW7vuaa7P6iUiSQ9UPYsf3tqDq3DWnDiANWWLBRF+8VBy 5uTtkyirchDU8BgkomvzW2nKZjjx7HAZNS/4/RflN6oUhvhSAApdploDVHTVb98xlmSbOqbiY9M 5+hYx5UEQLdKqxF0Ewds1HOW7OBJr+y9iGGYyk2ybYrxcmP5nK5XSTrOPKw3wQW6zHsXTATuJiL No4xRsAWgcmRAe96QCwrMNOuzwMUJEVSpMw8LSTnqZGyXXNREOJkycvb4ok0Gqm8YZ+9y3dhgxC MA1MQUSkupvNeHhljupkCr1rO5GYVgbAd1qoxOFjCpQBokxTTj8Y29PK2SKeZvpJLum71cgdVyk udqT6rggzZuW2ETvsyO3eFhcrIUYO7W3N2tSJRaaAUgcadgfAtva8lC5bpIrA6MAX7U+7GFEYb4 UT8mpdjVG0LfNgQAlMtrwoSZAvePGolME3l4hZddS7neEq9B5XV1OSIH7YdaPJgiTKFhzWlXB4w 3bvjOzyxCY8HB3AEkFE+mRUm+qZDydfNetkyri+JmKO0RJZlK1Vggii0BlDUcrll6DRNrIRHGuY IxHI/LGmHdVC4Yv7zO0g5t+1bGuP3A== X-Received: by 2002:a05:600c:64c7:b0:488:a2ac:a334 with SMTP id 5b1f17b1804b1-488fb73aa3bmr573546275e9.3.1777217790527; Sun, 26 Apr 2026 08:36:30 -0700 (PDT) Received: from dario-ThinkPad-P14s-Gen-5.amarulasolutions.com (host-82-56-22-134.retail.telecomitalia.it. [82.56.22.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a5499b0edsm388438845e9.14.2026.04.26.08.36.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 08:36:29 -0700 (PDT) From: Dario Binacchi To: u-boot@lists.denx.de Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , Simon Glass , Ilias Apalodimas , Kory Maincent , Michal Simek , Padmarao Begari , Sughosh Ganu , Tom Rini Subject: [PATCH v5 6/8] fwu: add helper to get image GUID by type and bank index Date: Sun, 26 Apr 2026 17:35:31 +0200 Message-ID: <20260426153617.2039651-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260426153617.2039651-1-dario.binacchi@amarulasolutions.com> References: <20260426153617.2039651-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="ETn43/ZI"; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Reviewed-by: Simon Glass Acked-by: Ilias Apalodimas --- Changes in v5: - Add Acked-by of Ilias Apalodimas (added to v3) Changes in v4: - Add Reviewed-by of Simon Glass 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(+) 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 e82600a29a40..2b11e5da061d 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