From patchwork Sun Apr 26 15:40:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4569 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 36FF93F36A for ; Sun, 26 Apr 2026 17:41:10 +0200 (CEST) Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-43d1fec59c9sf5965484f8f.0 for ; Sun, 26 Apr 2026 08:41:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777218070; cv=pass; d=google.com; s=arc-20240605; b=LCz8m7d6+cftuk5pnpZYgaJTLz+qwu+5hHjV4ZNfOZ6VgVcl0F2Rssja4fpuD4U+Pe p8JPr2NEBNxHfkkBL3CPfdOr4sMTM3zFCcHK9Quxwd3r+RK9kMvIQLrEGg/v1S31CIAh QI/v4EVp0stQKpGzdtYCJhF8eMaz4SDKVBPreR2yfUoBx/mSAO5miNFdFr+6ceqpivTq PrSPICd+6kMUXo3B6ds0oZAdJTT8HKRLH7mmKxDsIfCqLFg2DdEmK6YmNa3pnpMvzvVI GURkL21K6dX7Z8Dee40nA64Xz5Sc9d4ReFog2BrmTZS2uwaQD7vKac5QXZbulJ4oD3xz +Ssw== 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=vRD/LL3Oz6mmKxiNRbO+S2s4dknkk9O4TDMFsQZRPDA=; b=bHVfgvKIQ36xPBo1n5epXIRCgAWIaBxD2kPDBl5e359TlQRUVS5xnAuKadFhKepkGd 8675gFHJ0w18cM40jnoKFSUE7x5La/kDi1tp/kesIunVch6CQnLpa/+/+AvXAZhVML/a 8WGrrrrdmUqyXfe7Shyi8Lu8pHEdekjykv1+PJylMA50Kup/dzpJSeZeDTFBuQ8WJI1Z Wcgc6X8459gd0+nA2SMFvgL/yxQ5UXBjCh/488eOYtRL05LNzDrOgMMorPGft7Hu1wbJ MS5w1oHdxVX7f7q/KGnqVHvkRHgN+UIA5bk+IDSQNFhx4aB76sRFosOBBU1PzhFMYuyA rcXg==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="i8k6/Ca/"; 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=1777218070; x=1777822870; 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=WGtoWkUB2SaF5DArKM51wOC3KfcrbOX/9fo8qpyCPuObkqRZ2Jr0RUWey/LZb4XPlr 8NwmY0igVBDBow9vFrL0QSltL8NFVZT3CJt/azEuPiYYc3zdQqtmhRgIYjKqoD9CBYr9 jkEjBbwpRl4Ab41keNzX3GFUeIrU20nBXjs9g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777218070; x=1777822870; 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=igMJHxJe0eSKtYx4DTj6B9xhPF64HMgZUx/MIT9MpZV0SvxmEh5OqHMc0JwRBz0yRe MlK1/nREb7c1mNEB/XcYrTgDdC2fQVY6T7rDgeMPMjcO++ykTrYSobqoIZ2pOGb92VWo btg5M8V0FUBP3hM9ZLyrUIk5XGDsZh/D8K/O7lx/sbokuhvLnhy0usP3lyygG/C7J8KK Pxstb6XxN007H1pWUn4urgWL7Gt75z9Lg0RrFm8pqLMPXoIazoQ+1d5pnrQ2D/yIn9qO Qj5pvRmYLBAaZZ27mHvmVd0l8cE1fMbOFVQEM9dH/WHObrHaGSfGCz2N1WJwApnFSrr0 KTPQ== X-Forwarded-Encrypted: i=2; AFNElJ9nHdLeW+e5pmIIAHHUjl21uO5FLVMSSQljvChzyABobnW4LKxOxxyzrBSLBueFASv0/TjIiSApgdBtGHi0@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YzjLP89PccdH8eQl+D6dZgByqVYha+YVHeIj7KgR37qXqaDHndH vh30nj95WICO/fzdbVm4Fr6WxxfIrQ4FgQPmsyHQg4NUz5DJAqQvBSeuAmTU4I0SCIUKZw== X-Received: by 2002:a05:6000:1ac5:b0:43d:73d4:b1a with SMTP id ffacd0b85a97d-43fe407c0d8mr61256562f8f.19.1777218069807; Sun, 26 Apr 2026 08:41:09 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="AUV6zMMHUnHSMU0koz2106gf2oChZ8r4Poy3KcDBY3Uw5v5CgA==" Received: by 2002:a05:6000:49:b0:43c:fbd0:8eb6 with SMTP id ffacd0b85a97d-43ea9c4bba2ls2880236f8f.0.-pod-prod-00-eu-canary; Sun, 26 Apr 2026 08:41:08 -0700 (PDT) X-Received: by 2002:a05:600c:1d05:b0:489:1baf:8c03 with SMTP id 5b1f17b1804b1-4891baf8d2cmr401874265e9.11.1777218068093; Sun, 26 Apr 2026 08:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777218068; cv=none; d=google.com; s=arc-20240605; b=KTofnSvqaZ3zlVa1pKQBgv0cdnlS7enEQ4/7qPXsRW3BNo99chzA+1f1RdV64inyQl jINo1YU39DJjiCIP1MICypnUH60Op9JKpHV4kfIwUDXSdFnMjKjozfWgeKjBsTWJwfz5 CQdzzfHcfAgIfraQb8lHDO1Fz564ca63j8MndnrZfF3PUmGNI91RRFGuiqAfCrMVtvXC M7NhyUjb4JN1/mEgSvn9svhlH+APo9nmcj86Jf1wFWfde4Nq1LJSZabJHcZeJai7/pt5 vzniFMS3GdSPD5f5hjo9ipBdHhC7bUEJrjZq+BYDQx+rOQa1y2ArHzOo5K0dwD9mVhxV KEwg== 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=aaHmwiYbgdFbJke7oNYQC7vk4l114e4JmWrdMMr93ox6QCJ3+A7UkbSkwIaDxI4lXB yrc5zmu5GSfl8nq1hUp2tTG2P2DDjZsyiuPFdFhKp5qY+lT02QWH5YnsUUB8aL3tMSyw QMWxghxF7g9ENG9F98hXKMgWQiSbnAdUp1RmVyPKfPkZaI2DwmVPMLqhxYVuODA2sP7m udlF2IcyksLorY8Rrkd7MiVr92DRKl9l3htxilQcGh1WVILUcTNH1PcFchbGJY7b+WB3 44Ne4Z99G/ZPb6ROMsVvnmA6/YKcFBoG+/lSO+i2LcklJw7PT7K3uwyemy6fWsdWhzPB 7xFw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="i8k6/Ca/"; 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-48a53eb4a4dsor28589625e9.0.2026.04.26.08.41.08 for (Google Transport Security); Sun, 26 Apr 2026 08:41:08 -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: AeBDieuR9x2hfysm68HDVFSkoRP99uf10SV4d2ov9DLQYDXSRChDkFLRNZQHaVpIiHo f4lblbXhPHF46W4iNaBplM4rk3Z8GvAVwT2Kzb10peRRxsbilgS2SlWsxdgipLZ18NOx8u04lzi cKefBIaVmMiDISRW/45R6f8Z6dRydd/yOsk550y8Vlzlpno7nx9g4H6KtFSMwzub2idBjVGUJgq 0c0ZJjlE3hM/K+A87DrEbHrzhJld/0nEP8b8sTY/BnNN49JtKDEzHNQ6idMRZinaUjZszyMTmn6 GyCTKMvYVnJxeW2VBsVKh9VeGX1e4bd+Fu2Kt0V7gJFgWsaGErlf6s/eNBo3Y3XIXZPoCEdn+73 7rptEBp4qxqWVHaxJY35W4VWY9zQ1GIi7RXomMjL9txHlbzIUVxjL7lSxIz2bt/HbCe/dx09JRd 0fqJw0sDZzInODrbqP4aZsDBmAa4Wv4vQ3896yso2jQ7VCv3to4EBHbfbuONnNsCnUYFgfdcSgD 2VqWvdRZYONbER+1uusV+V76vpEACavGHTaDdreeOiVUKP3r4i1phlDbJKYnZfnLcEKJu1srbAR MrbbfRlX2QqseSgz8/BkwVWX4uxDgw== X-Received: by 2002:a05:600c:1d05:b0:489:1baf:8c03 with SMTP id 5b1f17b1804b1-4891baf8d2cmr401873875e9.11.1777218067634; Sun, 26 Apr 2026 08:41:07 -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-4891bb3d121sm802593765e9.14.2026.04.26.08.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 08:41:07 -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 v6 6/8] fwu: add helper to get image GUID by type and bank index Date: Sun, 26 Apr 2026 17:40:38 +0200 Message-ID: <20260426154054.2040932-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260426154054.2040932-1-dario.binacchi@amarulasolutions.com> References: <20260426154054.2040932-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="i8k6/Ca/"; 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