From patchwork Fri Nov 4 02:42:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jassi Brar X-Patchwork-Id: 621356 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp765329pvb; Thu, 3 Nov 2022 19:42:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7rFTeifrWK/XTqYK4gOiC89WhYPZTRXtUE+ji9LEmhsErgPo+0wJYe5n3CWRyZo7fYHz0w X-Received: by 2002:a17:906:8a7b:b0:7ac:baef:6de1 with SMTP id hy27-20020a1709068a7b00b007acbaef6de1mr32379020ejc.734.1667529753889; Thu, 03 Nov 2022 19:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667529753; cv=none; d=google.com; s=arc-20160816; b=P0HH+AM37Sh5clrgpB6GLiLN+4JHXUOSR0IPZiV4DHQ8xXv3lYFuTrh4GpMwGbPGxK bgAomoL9KRI79f/2O55FzuJoFQzGrs6BkK4o9AmeGvZ4PrJJC6btOvBvcJfCYfxUiSmB aW/1872NnIS5MWCCnjFk34pcQrKdi/NCxOmEWemhflVU3D739eFIiVh6ekgqgI7Vy4an NU7s6M2zhWONaTtABUY0etXgASr7v2GARg7K6Eqmy147ufyObsTROWIrlmgM5jlrdisl CQ1VFTPuelmKVGbyI+Xc6xxNSnhnvefsAyA6g/D8aPaf6bFGlK6RLo9+3HZHQiAwwjei 1Lfw== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=DCJsMxLFYfGHmz3eMr71pGW1Mx6HFqNOEiaimgPODa4=; b=LU2jsb+2MlWFBGEhI8iOaleAa5ZEaCmZjltd5mepfA4jUUX1a6NhyOfWK/InEUvT3T yY6zz7Ae3jQ6EsX59VAvRUa8tXN5F/ldrz14Lyv6T0/W2vm/APGxk8xqzcpcVRgXCZi8 Ml8K+5Lnx/+HWZhDtzKtAipjZeNxWEd2fMx/e7c9dnA21CHixXWEODAuDkp4oMQwjHuf TT45Ka39Kmt9LaHf+VTx3MeQC7lCeAfY/TV1SQgVwRoMtbxBfGcAAunzF/RfDIpeZwz2 qVhiIN18aphktcSMdnjDBVmV2uvm+76Q2xaD/ovVeTROIwV4+4FAgjqhz4W/2wL+mLlf l2Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gyYZom4C; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id hq15-20020a1709073f0f00b007123952b00dsi2601216ejc.100.2022.11.03.19.42.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 19:42:33 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gyYZom4C; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 93CD7850E0; Fri, 4 Nov 2022 03:42:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gyYZom4C"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 44A2684F99; Fri, 4 Nov 2022 03:42:30 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BAE0885101 for ; Fri, 4 Nov 2022 03:42:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jassisinghbrar@gmail.com Received: by mail-io1-xd30.google.com with SMTP id s10so1036296ioa.5 for ; Thu, 03 Nov 2022 19:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DCJsMxLFYfGHmz3eMr71pGW1Mx6HFqNOEiaimgPODa4=; b=gyYZom4CWv0vhF6ruL2Gtc1mHvK+5iG/l+x44flTi70OxocUZPL2O9o3S3Um7VpwAW llcR7llJpW0bQtx+fP3FEEvDralc87G/jt4LcUmpK5MAuWn00FiTiW+6mHMdI+7/SUey 9pd+1yqFXOgt4CADuBvUN589a/DMGfG/tNxbdrpqrsdA8LGuvCWLnG4kFPEXn/7aUwxf 4xOfPyJki3ia5eYqB14Q3bJGyCTTlHrnaOSN53oZoTZCR6DKql/pGNJ+q0Gk1/jmn/LR StgFmjP6bKORLYBmK4zK1ou1hQqn5uXcYlCLlxnBVRXQiL+uM2iN+kRNQ/z0WIA/l4+m tkUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DCJsMxLFYfGHmz3eMr71pGW1Mx6HFqNOEiaimgPODa4=; b=gk+v5xCEhICSEhClit+e1kELFSDcXDVlkAZUiHYHN/20CjT2ewZpxtIm25Xz2sYoDu 8004HdyoZgak3xoqc4nAqRDN4jWT9jynzjjrrEbr57mkYgJWhQzT5r7U8k7XwHmOBiFl nSsrBJhI/LqUll8MgxtTlaFLoCZoHIAmkHDRI9C9vZ0YsKCoWcl5seEeDJrG9bt+99YL lfro3ZkKp8JwqS9DYVrfgO65dT8IAVBkFgYdky5kNygVWpSxnt+SpH2juwa6KKLUS0/A H9q5Km1LJa8HGRbVIgiBfwnU61kFgL39uGgXAWulPzHUdPSRu0gpEtnA/0P0rAj8sSgw w2ng== X-Gm-Message-State: ACrzQf0dTLT8uRtblbyWx1k+XwW3oqLJOJrKq5lRR45vV+EgtrPdo58a qFdQd5bYyRFmY0TOYnqhjzowxnNNzfC9zw== X-Received: by 2002:a05:6638:216e:b0:373:a265:3b6a with SMTP id p14-20020a056638216e00b00373a2653b6amr18996943jak.314.1667529745626; Thu, 03 Nov 2022 19:42:25 -0700 (PDT) Received: from localhost.localdomain (wnpgmb0311w-ds01-45-179-115.dynamic.bellmts.net. [206.45.179.115]) by smtp.gmail.com with ESMTPSA id p17-20020a92da51000000b002ffa449535asm882338ilq.74.2022.11.03.19.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 19:42:25 -0700 (PDT) From: jassisinghbrar@gmail.com To: u-boot@lists.denx.de Cc: ilias.apalodimas@linaro.org, sughosh.ganu@linaro.org, etienne.carriere@linaro.org, trini@konsulko.com, sjg@chromium.org, xypron.glpk@gmx.de, patrick.delaunay@foss.st.com, patrice.chotard@foss.st.com, Jassi Brar Subject: [PATCH 0/4] FWU: Handle meta-data in common code Date: Thu, 3 Nov 2022 21:42:17 -0500 Message-Id: <20221104024217.764612-1-jassisinghbrar@gmail.com> X-Mailer: git-send-email 2.25.1 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.6 at phobos.denx.de X-Virus-Status: Clean From: Jassi Brar Hi, The patchset reduces 400 lines of code, while keeping the functionality same and making meta-data operations much faster (by using cached structures). Issue: meta-data copies (primary and secondary) are being handled by the backend/storage layer instead of the common core in fwu.c (as also noted by Ilias) that is, gpt_blk.c manages meta-data and similarly raw_mtd.c will have to do the same when it arrives. The code could by make smaller, cleaner and optimised. Basic idea: Introduce .read_mdata() and .write_mdata() in fwu_mdata_ops that simply read/write meta-data copy. The core code takes care of integrity and redundancy of the meta-data, as a result we can get rid of every other callback .get_mdata() .update_mdata() .get_mdata_part_num() .read_mdata_partition() .write_mdata_partition() and the corresponding wrapper functions thereby making the code 100s of LOC smaller. Get rid of fwu_check_mdata_validity() and fwu_mdata_check() which expected underlying layer to manage and verify mdata copies. Implement fwu_get_verified_mdata(struct fwu_mdata *mdata) public function that reads, verifies and, if needed, fixes the meta-data copies. Verified copy of meta-data is now cached as 'g_mdata' in fwu.c, which avoids multiple low-level expensive read and parse calls. gpt meta-data partition numbers are now cached in gpt_blk.c, so that we don't have to do expensive part_get_info() and uid ops. Jassi Brar (4): fwu: gpt: use cached meta-data partition numbers fwu: move meta-data management in core fwu: gpt: implement read_mdata and write_mdata callbacks fwu: meta-data: switch to management by common code cmd/fwu_mdata.c | 17 +- drivers/fwu-mdata/fwu-mdata-uclass.c | 151 +------------- drivers/fwu-mdata/gpt_blk.c | 175 +++++------------ include/fwu.h | 198 ++----------------- lib/fwu_updates/fwu.c | 283 +++++++++++---------------- 5 files changed, 202 insertions(+), 622 deletions(-)