From patchwork Thu Apr 30 08:06:07 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4596 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C86043F0D7 for ; Thu, 30 Apr 2026 10:06:49 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-48a55ecc249sf4040265e9.1 for ; Thu, 30 Apr 2026 01:06:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777536409; cv=pass; d=google.com; s=arc-20240605; b=P6NKwvDN9amRllaOxfZSr2HSWdynftAoITCKYKS2iNC4SzEoL7DRIzgc3TSsS03WeY IZeD/4X7yQC7hcNZJtW/AK6+4boM5ymZuItJ5441NRd9u8R4HzzpcmdAU7pAHa1FHlmY G7JQw8sT1V9gm2xH3HHlbDMETYEE8LQ4i+boIBQ1Fl59jzjHrnqS8l/mOIzIJZsPp3Iy jnMJnNk6FdwZKNUrctN796hivdMmM+HNt5siG0DzRQX7VyA1GoC28M8Muc4voDv7RNU/ B57LAiirmBnn2F9ZSPX2gio6bhSpmS+SrH9WaFpDixX0dUufwtpYmn71qJW4CAtPh8/v 4pbQ== 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=SnkFgZ9OhSQFJivPMLXrgKZV+pHin2Zv20JrmHGfQ3o=; fh=22VD9Q2d7LHMmFatvB+Gbi8E9TJAhJr33KZ4+p5lD5U=; b=AVQhyngNwvJ72oeEWP9boe4pb+Pl0X8GnCJjb3Ufg21arMPHkvaq8m5pcoIKuT1cgj He50uJlRf8lJWO43fD9VKyjRD3OKSrGeKXMIYYDWtzzLIeVmqj321qnhwN9OX4tf0w3K t/14xtZSrrmmNRfPRwIpj2TTXazJZ0fOIY2gc04Gik0mUvRr5iVgKKdN4/GIgEweG4FO cNLguQmB08uCnHPBRQeo8rwYZ8UVzwt8cfqRakz3rNfE+gL1nGUW996m/jRPoqUI/NAX 1gZhQBLktgH0rXJ2ESPX33JUn060vcwebKMggGHy3eKDx+mfvkMIOQ/y19ZG36G05ntS 5zOg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=akA250m1; 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=1777536409; x=1778141209; 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=SnkFgZ9OhSQFJivPMLXrgKZV+pHin2Zv20JrmHGfQ3o=; b=ji95e5NEljuDqo0pu5GUVr0UX+M5ORe+dFowOmUQoJb2USOgmYTAawtldAyDKZX890 Hexjw5MnnCdAz+vghyWYdyk/Wp08S7C/bGBUQf7L9NJIfY7kJb1psenwxuKulW+U0IHv vsWDNtG01lfUlA1H2dCNzR2eJLdOhCMVPIKIA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777536409; x=1778141209; 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=SnkFgZ9OhSQFJivPMLXrgKZV+pHin2Zv20JrmHGfQ3o=; b=BHSpd28Q6DSPX/+/xE8aNosUqDCSW9eqUBCCwTZ20a3cWV5TrsW9CiGkGYf28Oyw1x oIDY55biSc5o7+9nQzR2pUex9W19xDfIbGU9AVJpINNSAFtpvY9xEMeRsngk6GPflmd8 4V3/SuXZpmQ0jL4wtgfJN33RRePBCZpLyp3eggnJ9TiNA7poDye8mEG6y19nYG3ZSoOz pgYyIWnSl030ukzixlaVeni5Sh6x1ZkVTIt3DqEPkULWEIx3BPl+JpdUNY/9xsmtwf2m CWQSUdNxlp7wapmZ/lP2lPGiqasSILqjJOmbtUfd0jf99R0UTOKztaPwGbxcbI8G7b1w Ot8Q== X-Forwarded-Encrypted: i=2; AFNElJ9pKgymhog5GVBDxxAmU9VxXKf+bTGhBPzU38TXbW6RhFq80ycX5MC/IwbUq6KhXqNVZpJE7B7+Y6/BdRn9@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YyG/88Xq21XCtL+yZkmSFSl+TcY5601/djG67KeHH/Nu821CdF5 CO0eflrcOhsAvjKPlkW+di55uk509FmaIv8ctoZigcRQNhsHqveiyKuBTDmm9p75Lg5RLdMR802 1xQ== X-Received: by 2002:a05:600c:a30b:b0:48a:58ae:993b with SMTP id 5b1f17b1804b1-48a8451cfe2mr21018855e9.16.1777536409287; Thu, 30 Apr 2026 01:06:49 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="AUV6zMM7HSCUBVlT8WZKH6MMDkaocsW18q54QT8N3MhyOOjkBA==" Received: by 2002:a05:600c:5607:b0:489:1ce4:41e0 with SMTP id 5b1f17b1804b1-48a83c0083els4229165e9.2.-pod-prod-01-eu; Thu, 30 Apr 2026 01:06:47 -0700 (PDT) X-Received: by 2002:a05:600c:4f88:b0:48a:563c:c8d6 with SMTP id 5b1f17b1804b1-48a844eb8bcmr29527425e9.7.1777536407628; Thu, 30 Apr 2026 01:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777536407; cv=none; d=google.com; s=arc-20240605; b=T9asP71zYdcyg9SXv6PxR/7SMPRmyYXYsbYgEws5SZtzp7gMVwzyfoH53AT8PjCcvl RJe0bnlLVLsdwmo94ZGxs690wzZXuhYwqAEvkmpKA5SgWX8phncYA122eJW8skCElDaW xLJWza/IQfGsc647Duf9smjJHzx5h0lu8JxoIc4roW+0K9q9W30fLRcaYrC3yNA5yz/+ 4xpC5NQ5bCHj1DYUqj95/PCn1w2dSz68uu6ALUDhxhUjx2Pm/NYarnxuz2ardm/2U7q1 KvbGuxOwE+SZCkaxGagIKvcni/9RLQJDjs8+I2n3Qw/HqTA80iaks15qqORV3wj7kzen pZvA== 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=5GSYQhGo2SyIVxnn6Fpy6y7erjo+T2Ff+eqsbRqEQV0=; fh=63tQyC28C9/eYaWpq6aXRoXJf0iCc3tAFavW3mffgU0=; b=Gv1SneOEbYArlpIsNiC0ma4eaKs8tNnmJqY/X3BU+YvAJxXV1BtPpIQWz7HoBFdQeb OzQv+krBBQPiGqkSKCW6ZuaEz+Ws4FhxCkO/EZeYYiPBOZ/4/RBl0EnNsV9G3kCk6CxA znAFeFPEzX6o7JxK0HWdhc2HmQnNorD8ue1sUiR2/aqqwklMBWoVuCrnZns66v/lpX78 G45j6fAPxDP/pYdAH6PcSDX3j96PkCfcId9kn7Sv6OXufEOakBYOWh6YhBw0BSvDLoPV 9nIrJofoJB/a+zSfQG5odezg43s/AKsnkSPYMoBkRxH4R454bNRQeYm6Rm/XT1o4ObMb byWQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=akA250m1; 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 ffacd0b85a97d-447b7e91c73sor616855f8f.19.2026.04.30.01.06.47 for (Google Transport Security); Thu, 30 Apr 2026 01:06:47 -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: AeBDievDrBwCPIvftbLjeEo/DndKHDvZu/14HQZwTTb3jHsi6VSAtKgbdJVIDrry+pk HiU8StHYgRGWF+YGlCdEg2vrWRz22ylN9BslXkUFQOksBKx5D+3aB6nd8HOhwNDMDwFLXOYVkQr 4CpuW08qXyHcgLY2ecEJsb4Ao7VRXJ6y3HI0y12XZCAnLa0iqaMskWiwSYi65ZfqvzvKiNL690C laYDz9B8ZFLdK/EmnQRfkfbfh0qgMP94SnolFfbRCZfFQ7jwR/OiFBzbP/e44hWYi8d7o8KDdJx A8uh3INzSdOb31PzehuPh8vQXttvCaYqtTsfs01g8dEKQdnLzg9pSL+ORLdCSwVq0bYUjATBN8N GIPHZZC74sVHTlkoMhODG5myyBu3BQYPVPUH6yMy1DsFvsIZolbZJgNYQpCe6B5aEANlS368B4F 1MZz8lF6IZ0OsIIQyIztO81ze4KJqjSrDk7T/aPn8R36ugzdndqkDxAR7siSFvgYChpczKGQDA2 BsPimc3sfRYx8oe9NNlLAsRQI7WebV3GXJqxH8vlNuRTPTuzFFmuDkjoJ2zYY8h6o3am3c+YeKO XzKckqpa6t25tJJxUGNymwV0wBuTC8BkP8OmNOUHPg4wog== X-Received: by 2002:a05:6000:40e0:b0:43d:50c:6f18 with SMTP id ffacd0b85a97d-4493cc3fdadmr2932222f8f.11.1777536407032; Thu, 30 Apr 2026 01:06:47 -0700 (PDT) Received: from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it (host-82-56-22-134.retail.telecomitalia.it. [82.56.22.134]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-449c576d0a2sm668071f8f.31.2026.04.30.01.06.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2026 01:06:46 -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 v8 6/8] fwu: add helper to get image GUID by type and bank index Date: Thu, 30 Apr 2026 10:06:07 +0200 Message-ID: <20260430080627.849636-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260430080627.849636-1-dario.binacchi@amarulasolutions.com> References: <20260430080627.849636-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=akA250m1; 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 --- (no changes since v5) 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