From patchwork Sun Apr 26 15:46:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4578 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AAE943F206 for ; Sun, 26 Apr 2026 17:47:39 +0200 (CEST) Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-488d56f87e8sf73994955e9.0 for ; Sun, 26 Apr 2026 08:47:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1777218459; cv=pass; d=google.com; s=arc-20240605; b=dh216Lo8wg8hm0YfxYtRdtcmeuXTWE7XFy8qVUNw/o09Lze7JY5oUjfmfyaA8/e17C Pa8Y+uAQ7L+KS+T76q7/3tKF5YfcDZd8aP70BRXsjAlUgiC8CXxC8xq0bIaR5yufuIyL afqB0MW0bI+PSp3VGV1BWnyWBLnljDo5zg4Z+woDV/lThgOWiMwhkAAeYxl+AAKSD1b0 rDjrzZDoOoEfDxc1TCddVS0disSCXMZff+DI5AOdSig9qb5ODcEOQSeINbH8ELubUS8D Gc53pi5eHjiWV55WzKYuIEEULeuk8BqoD2Jit/YJZPwnSnBipL7PjR2/lALyQ5+gZFg6 6GYw== 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=mNK17XKZ6fRj0jjGk/S8AYnXlZDV/A9phUM7fqlzUuM=; b=lpjR3Ib1dTATouFmFv0O6WLo1qyatrDp41thNUJlIIjYE6jPuYpVWI0zhb4mae2mve Eq0EICULom/JHu17fqr4Bu/KHR3kV0/LF2qLIidJhihIXGt9kGB+X240US+5iycSzUDd PX936JC/dcG3qS3/GfC+9nNF3rlif8Fr6Bd+1kBXhdMP+2isCiTYhMBqMflcLnBlPztw K04gBYiEUqTEk/RUt4uXjf5zrHXRKnBX/CzTscmNaWPiMZp3iUpuigL+fnb81H+GUa6d 48+UoR4Vkh69aHOecKj8TO8Y9gjZxGvCJFwnuvipJ1q1E0FZcXAtXmJRwAqctjHFYAal lMzw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Yue1wz2s; 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=1777218459; x=1777823259; 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=LS+Q85WBB9kK3ILru6Ru3xb5wj2RXYLvlsDqw6F1zu0uMUSnwoZg0qu5+WDM3DYIGK PwmtAC5mNTR5W8wO8PIWfeyUfLbWAiRGAG7dh05TRwqEsa/PG/mAKWEeFr8KscVIyKE/ 0maJbq3wfY54YWTZapYGKF+FXoO5Sl5v6kYY0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777218459; x=1777823259; 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=HQ+YzABM5RYKzKmHiGKlHf8ZKfWZ+NIbwxttsI6uke7VVueXyD6Htftnq7UIBFu7jG c2XhFuRI8lU/jJDXcMRrUk6c2jh96A0ynRIzL6sUEKxVS+6bQZB7Hy+WzAtmxLCLv3Ya QPtb5Kpu6U/iCzWOVfH1M/MbNinkoJXgmDaMp1zf8Ipb4EFbEbFLlL6DnkR83qsqJABK nOO0KVKBARVc+rIqeqM07Vj+dSnsByYR1ia5Xd/XmN9Wzi11KMqYlgcAjvnzc3ysALY0 dS557nyIvF62iFOYHGjOmdeH7kG5Isk2akiXJIBXFro97Td1xlHd2NTqItvjgmc9EcVT 43SQ== X-Forwarded-Encrypted: i=2; AFNElJ+ByWdPijUSDbLQ7a8t+faJXt3LKaVTIXToxYFi8CUKe4CADSaCB05yUgjmO4gRPKdBQ5WmDmOcvCk2WNoD@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxFo9dnSgo3Pu5PvHe5UyqgSVSQ/rJU0nSFEWI9gLmDPDB/jzK3 Sl3enwmxUUZC4R6ndfgFBa+6V3DzLII+wP+UZvgM9fg0761QiUsmvL8rMvGmZHqYaP2++Q== X-Received: by 2002:a05:600d:10:b0:489:1b0c:8b43 with SMTP id 5b1f17b1804b1-4891b0c8c48mr354346835e9.1.1777218459306; Sun, 26 Apr 2026 08:47:39 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="AYAyTiJNqOT5o0lSbWjfXBS8veAzpxFjuVu0y2VfqD6NPYOSfA==" Received: by 2002:a05:600c:548f:b0:488:ab54:fc08 with SMTP id 5b1f17b1804b1-488f4a77b0fls112249895e9.0.-pod-prod-02-eu; Sun, 26 Apr 2026 08:47:38 -0700 (PDT) X-Received: by 2002:a05:600c:530f:b0:48a:56de:d640 with SMTP id 5b1f17b1804b1-48a56dedc17mr358576435e9.16.1777218457872; Sun, 26 Apr 2026 08:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777218457; cv=none; d=google.com; s=arc-20240605; b=N5zuHKjTot2VKJc2tr0zh9Al/1EOV0Uhn1+KnZ47mQb/DH0UNvQP8ldBdX1LH9n6YO R7uiDJKJREpHlUTKPeL2nsrARWigTA+aAV22ApwZyZEA6hXwcka72rwcoaZPqxQVrtvb 6zxK3oDZ5WuYgRbX4NiMnSnwEStBv7e3tGxNBWCbg8inrLXCKCn+fmlbPb5lyvqe1GWQ FxOx98zvYg3VgGUb54xMZhqZjfniAZYoNPDNhZu1Gx/7O/3NLUhJ/RERubGmVDedPaSB MtH8/8hOBjIbXRrqtx74WCAU431Z4/u5Tjaf+r1fmeFdBdIqrcJE2dIYHvsJCoQqENNB xzIQ== 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=O8nnoTTuQwKLjQb0HRXqom2BCjQXcikepyGGjraKkcwZJj4Tucr2LQj6Fq2BNt4fBT PEhGC6WUYv5Alhau1wgID7UXwRr6HQrHkYJVUYVVwUgkUdQCG8RD943isYMWLMT1iJJg KAAFLtfMGbR9f6ntTmzVW7ryWpWtxpg7cy+9HvuxcQYEiWC5f+xdpnwjpgflHGeKAhkf tr4g1RofiPc8/yS0izjglm24a/3vJirdq6VdkxeIDEjW2RI2liKWj8Re1qNAvy5ypOyr S8MiZ/2t1dg2Q6Nb9oLcrs4SuXy5yWzOYVkgzj7/e5bT7OL+6VX0PBxb/rHHQcpqAgQI E3+Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Yue1wz2s; 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-4445991836bsor104702f8f.1.2026.04.26.08.47.37 for (Google Transport Security); Sun, 26 Apr 2026 08:47:37 -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: AeBDietAosyLT6trRDegXl5Adqyew80cO2e66nOpzkP3jlQPnu/WnqeHE7DDjK8Og/J gE+1wme56bf3arUuJO55gb37T+A5PxzBHx/CSxnTiQ2mnlVPL3few2wQcXyitE8aJAWgO/HpixO f5VyF9XalaKDjENl9CKHdDbuJctc53ooDSq0SmNCT/8hyFD9bZJ1iUQbEgvzEoJ5G6dNgU3FwTM 28Na2Dq7wvcCD6s3XaQ48sQcr8aaj97fbatje4LxGZDc5gUaiWSYd1iSJmW3dlFP0ui8T13mDBV fdZ9VPsQ3ESFp8U9bm1pf50qdkw8ycWZN0mkvvcmD5Tuf5mZkQkmvzlCZ89sxBdfyyCE982gaZC apD5wjiphge1t901uR7UoV2NxrNWw1YtMpi72SS9MxAoffKPJVf6BgYb1h35+RCg65vyfiU7Iip RQA73nDhEeUjUWFLQdtQ3gZSZAQdsfHRyPzyfeWm7lgVCzivLxQwnh6vRP0/i9xKKejNpOjxaRv WYMmBSiSnE7Db1p8kwTE6ak4Hg6v6liE0Z9noejUaHpptLfhAlAg50RnW4X+bwvIrpDf7VwbpXG /0a8nQgH5a+Kao/cRi+O6KGOXKl2eg== X-Received: by 2002:a05:6000:4283:b0:43d:73ff:fd59 with SMTP id ffacd0b85a97d-43fe3db9bc9mr60196646f8f.10.1777218457451; Sun, 26 Apr 2026 08:47:37 -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 ffacd0b85a97d-44123d23e0bsm34489985f8f.15.2026.04.26.08.47.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 08:47:37 -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 v7 6/8] fwu: add helper to get image GUID by type and bank index Date: Sun, 26 Apr 2026 17:46:59 +0200 Message-ID: <20260426154724.2042569-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260426154724.2042569-1-dario.binacchi@amarulasolutions.com> References: <20260426154724.2042569-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=Yue1wz2s; 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