From patchwork Fri Mar 22 10:57:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 781842 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:33e:7753:30bd with SMTP id o1csp1273890wrj; Fri, 22 Mar 2024 04:00:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV03Ef8oSe63X0M9RagzbT24ZoF3GAM50qgtc5htQcyiPtGKsnB6m/lemlLrwJPQYXBxfas9iDyrSgTZHsC0BE6 X-Google-Smtp-Source: AGHT+IFCrBlHhslYXO35VQtMBunmGaQ5RnNRO6dxDpb/YVQVsOo/r1z/RVTt+iN6JW8KA9KhDB0X X-Received: by 2002:a05:6000:11ca:b0:33d:3566:b5c8 with SMTP id i10-20020a05600011ca00b0033d3566b5c8mr1574175wrx.13.1711105207067; Fri, 22 Mar 2024 04:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711105207; cv=none; d=google.com; s=arc-20160816; b=yyHb6hDhtFyJoX4G8vZ3MnWXOQotKpNtz3G5w3BOoorggA/a0Sx0d71JVDqIX53M64 mpiurZKz11q3HoJSHMVKPNcns7P5UrXzXR29GgtBAWySyNRkGO8hUvs5eyiUltQSoyC7 44oUOe4dEg5TFmiKT3bYNhK55MI0YD/7C78EqJCca9t1kVP9r9y55z7sUIMdvUZRdbuM dK/SnErFlPLacFLfYVttxOMg5bQdKlJFrgfWMVGaBjQka7LORBWHIQiNH0vHpnzrFJ9P jQjeRKZsarQ67TYxEka3awIj5UuQGeFnon6ENoyguF4gPb5Fx0xoD6lL2C2T8SSMTjma f7gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=u0cJ7RwxtkTecIpwBY4acCeYa1VQcJSJMmg8h3arNA4=; fh=0OBOeNvG1YwOz62VjCAPxJsyowuZOMIwtNTktJXXBMY=; b=pwUlpL8euvavMF+SlYtkdKx6VUQpFNSj2eE3prQSbvuuA+y8DK4JLNnoAtJwo3bH/x smkKOOAqdvPAV6zPHKBWIGj8exQvRQ8YjPikoUONPO1AXv8hvNeRpiuUmDCj9I/RUNND 3k5pAd/Jky93f6PF/l6Or/+LkYi61WPVvQr9KVRWlhcUqyVwUqBoMqOtQi7wuRyfxpJ6 Oui1E+D0c+SCyeb0x2eTslpWdTIm7oU3A60E6vLWw6QUzDbIToq21y2PXjxye29HVnlp /unCO7fBKbxcowxs5Vz6kndKZS+pXrkZNaAzz/o6R57QozawPgLnLtAJj63qz6HsdJq1 qprA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id t2-20020adfe442000000b0033e10d653d1si854965wrm.855.2024.03.22.04.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 04:00:07 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3E4B4881CC; Fri, 22 Mar 2024 11:58:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id DE9B0881F3; Fri, 22 Mar 2024 11:58:41 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id DF71B881EA for ; Fri, 22 Mar 2024 11:58:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 808971063; Fri, 22 Mar 2024 03:59:13 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 65FF33F64C; Fri, 22 Mar 2024 03:58:36 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Yann GAUTIER , Etienne Carriere , Patrick DELAUNAY - foss , Michal Simek , Masahisa Kojima , Michal Simek , Sughosh Ganu Subject: [PATCH v3 09/20] capsule: fwu: transition the platform state on a successful update Date: Fri, 22 Mar 2024 16:27:22 +0530 Message-Id: <20240322105733.203888-10-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240322105733.203888-1-sughosh.ganu@linaro.org> References: <20240322105733.203888-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Transition the platform to either Trial State or Regular State on a successful update. Do this by calling the fwu_state_machine_updates() API function. For version 1 of the FWU metadata, the transition to Trial State is done by starting the Trial State counter, while for version 2, in addition to the counter, the bank_state field of the FWU metadata is also updated to Valid. For transitioning the platform to Regular State, no action is needed with version 1 of the FWU metadata structure, while for version 2, the bank_state field is set to Accepted. Signed-off-by: Sughosh Ganu --- Changes since V2: * Earlier patch was catering to v2 only support. These changes support both versions of metadata. lib/efi_loader/efi_capsule.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index de0d49ebeb..0937800e58 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -480,6 +480,11 @@ static __maybe_unused efi_status_t fwu_empty_capsule_process( if (ret != EFI_SUCCESS) log_err("Unable to set the Accept bit for the image %pUs\n", image_guid); + + status = fwu_state_machine_updates(0, active_idx); + if (status < 0) + ret = EFI_DEVICE_ERROR; + } return ret; @@ -521,11 +526,10 @@ static __maybe_unused efi_status_t fwu_post_update_process(bool fw_accept_os) log_err("Failed to update FWU metadata index values\n"); } else { log_debug("Successfully updated the active_index\n"); - if (fw_accept_os) { - status = fwu_trial_state_ctr_start(); - if (status < 0) - ret = EFI_DEVICE_ERROR; - } + status = fwu_state_machine_updates(fw_accept_os ? 1 : 0, + update_index); + if (status < 0) + ret = EFI_DEVICE_ERROR; } return ret;