Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 049E9C433FE for ; Fri, 4 Nov 2022 02:42:33 +0000 (UTC) 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) 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-Google-Smtp-Source: AMsMyM7Q3r9h3/ZECu7aZFVr17zbtuAvug7x/aY6ZWa7hHuL7pm4f2HsdspE4Z4T0m1HKpqAX9GbIw== 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 Content-Transfer-Encoding: 8bit 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(-) -- 2.25.1