From patchwork Sun Apr 19 14:31:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 4549 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 CB6333F1C5 for ; Sun, 19 Apr 2026 16:33:08 +0200 (CEST) Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-486fa07f2bbsf16950255e9.2 for ; Sun, 19 Apr 2026 07:33:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1776609188; cv=pass; d=google.com; s=arc-20240605; b=JHz3ptoRMeVuoJO4XJOeM4gKdDZhwLQp/ti2LnPAFzHkD/pg6fdEgJI3tDd2Wnh100 ecJ4yJ+TeIo7JPSdegY6zJPjrW6s46VwwO26gqJZWMe44I9HO/ROTtPiVcy5M/a4TNbI yyNeiF132xZEmF8o92hJO4Jpf5f1QCgfUxJ84xW4t+VcxetVS7/g7NGYtTzL/cNtNgg0 q7Iy3bgyQYkaTpZFGFSzQQzoAR+0ePCJj7K8xYyDRy+9bB0kSiNECAf8Jaua8jeONte+ aObnOZRWwA3Ym6lSksFoIARqXSjclJiYCbpDS2gT1CQc93xKmtAXlaKiiG2GZXcJzfGy n0ag== 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=yTgGEeHa2xmUoIIdFalLe42i+irxzHALdiN/54ZthUc=; fh=NsB1U1xPlQKA9JuzSrpoDvPe98dM+A/EmV68SnCqldM=; b=kY+jILlzr6hf7kDlqkoDJIsFTXWOZe5CRSgMMgVgTqSBkLeyIHHjNwP3xQ/TUKSUwD 08aEHsgdb5Vt+3iZzjTIBxlNjf9XWW6sqCw//enNr4QEEIoQVaYPH8tDFUM1r1D7syqe Y3bnT320QBPYF+XdmZVYgMcN2wr+4HlrGnXPjLiWTHjeqySxy0fKmXkjCxFJfw5V3Pem Sn1kN1qlbyCUfL7bqmgZ1mNfhqjYBz2U48GA5VqI16v289gWs+pPxFjXpBBImbOD0QHf j9EMiRGMbHrtKcn9pPZSilTd0M7w3z1aq2ZUYlLyYJ4csmulztlmJOQbLf4lcoUuybNC BTlA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mKJHL8M3; 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=1776609188; x=1777213988; 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=yTgGEeHa2xmUoIIdFalLe42i+irxzHALdiN/54ZthUc=; b=P2ORWvcs4KiqByWYHwC3Wve8dA4YQJpkuTDANY+hqP0Ht3lsiSx1TX5D49K4vaaqmI Cff9SqPIJjDScUFVVS7Mi3St45Tae7aJ/t8yVVWXY6nj59ftvSD0Q3fQON9A3iyvmCZ8 X6gAukFgIPDsmCYzPqYWLIwUDU+huz7p47NP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776609188; x=1777213988; 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=yTgGEeHa2xmUoIIdFalLe42i+irxzHALdiN/54ZthUc=; b=sT+y/XttcXe3w9r2qGHpwRJgC9ry6XoCFd41zRA6nBE7ZmX6EUQqwOu7NwL/0xK6yO D6mIe2tvql/H5TyaTRGKsgliV2gVSSYVjaWjIMXm79ZmKoEYrsqUdCBj9BIbNU3aM4wm swB1efNhoOxvQ60/5fjSZdjEuE7tkP+tgWxnYxFlSq7Gby8HRC5DRvEzXQ6Icm49J+LB MYJnXI8mSd0yiYJSfw2AfKeXLLt236CA7D7GJYUx6B3MQhpBzL5kREptOcEBF7fzFK+T YykrKCNKKoFKRydbc/FXXidrW+8PCK36XpDEnKF/fJ7ilVI8hMZQS6IQKRx7r7qyPo4Z uvxA== X-Forwarded-Encrypted: i=2; AFNElJ/xvmtI0bYqgdBAPIraZRzMgI97NO/PG0WmD1a/Zy9fs3ka+/pGrZ/kFmyGjWheFmhUcyLJmxaJfkOQ9GrI@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yxd+ny66EFSY5Ue6je7XxTwmiqarDgPl9tA2dzVKkkGg3nH3xvD yACphWURaB2h2mnIyKmDjthcfEHQE5JNZho+E3utLqtiQplS4W8I4z1jhaziCxtKYjxpCA== X-Received: by 2002:a05:600c:314b:b0:485:3a86:6392 with SMTP id 5b1f17b1804b1-488fb778b66mr132797305e9.20.1776609188172; Sun, 19 Apr 2026 07:33:08 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h="AYAyTiLqBADC5qFeTfMS6009syuNaxrmEptjPmJobM7TzyLLlQ==" Received: by 2002:a05:600c:6dcb:b0:488:8433:1d20 with SMTP id 5b1f17b1804b1-488f4a7a143ls18380605e9.0.-pod-prod-04-eu; Sun, 19 Apr 2026 07:33:06 -0700 (PDT) X-Received: by 2002:a05:600c:a105:b0:486:fb69:4960 with SMTP id 5b1f17b1804b1-488fb7786e4mr98472525e9.19.1776609186431; Sun, 19 Apr 2026 07:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776609186; cv=none; d=google.com; s=arc-20240605; b=LDZnRw2mqWZuykNOnYKnOKWhEL+BmxWlUWpmsmLJzCYe7wipRXUKCTou0cE+abNVel H8HqP1J537PeAKKMwHRVXXwiREaju4Z3/eZ6qCsEu5vs8sKz27oIiLjjIaQm7hbwgbZC EbjeopM31kysp0l/7CRm9C47nujO5UXYKyVGI9kkw3Pvxfa+4wi6EkXb6PtxTOUjNEUL oPjkOKhNU83oPYo+6Mv6Vou1HHL+Q6eYFzQ4NUjIT+NiVdmQq+bFuI7K7Ch3dy6ToXyd ve43MP6tO+6RupW5c4H/1Y/9GQaIxYdbyBTp0ZWebkQv02qENL9K4Z8tydYBve2ga0pH 8aiQ== 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=35oH3mslwLGRRway1ir7K30i9wTZHNIramSRlzIVcYQ=; fh=63tQyC28C9/eYaWpq6aXRoXJf0iCc3tAFavW3mffgU0=; b=OsqZ3Qo4NkPMysHMzJxHcEijZkXTxGCBcwDc7L7GhJnlFNF1Xx3nKfMtMidgdy+eUI HMf/FOxP7Xq9c8ueIIKQ56an8xxaPeDhJD5peuXodVHX+KsQYLnDr2mmdEFA+ERYuvUD qr7rqDkzLw/IhgVFFCF+p01GV/8SRB9V6gvqANUwiEtVlYsTvTCitsbvAJY34YPvZwiw +Ob5OHNn7lC5feUzT2lawZEcdasdWTq249HZcJJebZsoySrDgbbXfBww2i/5j3gb+5DA d3XFTd88LAD3o3olvr+YRMD3PmXPLe8s5d0fzbxmHNvpnzBedF05ZGxp5WiCSP0JXOK5 KFfA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mKJHL8M3; 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-488fc0fc6f7sor8739785e9.2.2026.04.19.07.33.06 for (Google Transport Security); Sun, 19 Apr 2026 07:33:06 -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: AeBDieu3rHiFoOiij9UUItLouO5dsB8itysTl/OLFl+ujIUaAx49sxCS7z80LKIqOhZ c2ESAaXESGMGuOpaEoKtcMJFA7NupKXEcvD96b9fqH4hAvPna/PpV63VratYUDi3KCiIVm89VAg PgfnBt5IUYJbhHHa2eoGXNtYgVmDfgNymYw72rQpuTNtoKWNEJK5r8jF3u4smAIDGfevghwS1Yl IX9fI6DSr9qPbZ6PG+wdPAPZ8urh/FVSbVqJF77ItiMtii4TrjEEjuFg4a0ntqCM85+OkrGMiqO oB3n3g8DrOSjGJ+jr2do67Xlkfenl6kteUqN96A8phJeA0oiloc/VXUOBSOucfrm+tyntuUn4Nn lcplglQ/WY3tOSF45l6kJr0OIxpWRx5kxOHtbaJiYdjURPl/I4+6l+kHYoS3xDcd2qJHYoHVTKF Bm83hliMbsDFI+U4M8ScnQEWGXrqj158K+/rTnPzMZwnFnPo8CLor0gRD9mkzv8uk3E5Jspc1ao uvyQRMcU2njQmJwOjFmAdyoSUjrYel3SsQlScnIfTMMCLa1M/3BI0sxotCCr69q+W6PatHaU6qs fDRx6N2Pdd1ltyyNpoVYzTrFWoZpZkDq X-Received: by 2002:a05:600c:4e16:b0:488:d6eb:e63a with SMTP id 5b1f17b1804b1-488fb76fe73mr140754565e9.14.1776609185929; Sun, 19 Apr 2026 07:33:05 -0700 (PDT) Received: from dario-ThinkPad-P14s-Gen-5.homenet.telecomitalia.it (host-79-20-97-39.retail.telecomitalia.it. [79.20.97.39]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fb755938sm86864245e9.3.2026.04.19.07.33.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 07:33:05 -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 v4 6/8] fwu: add helper to get image GUID by type and bank index Date: Sun, 19 Apr 2026 16:31:46 +0200 Message-ID: <20260419143247.437733-7-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260419143247.437733-1-dario.binacchi@amarulasolutions.com> References: <20260419143247.437733-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=mKJHL8M3; 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 --- 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