From mboxrd@z Thu Jan 1 00:00:00 1970 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 79498C3DA7A for ; Mon, 2 Jan 2023 18:25:48 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 10BFA85413; Mon, 2 Jan 2023 19:25:46 +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="MVNOL3ot"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 13AA785422; Mon, 2 Jan 2023 19:25:44 +0100 (CET) Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (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 281D38533F for ; Mon, 2 Jan 2023 19:25:38 +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-il1-x135.google.com with SMTP id a9so4556940ilk.6 for ; Mon, 02 Jan 2023 10:25:38 -0800 (PST) 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=abSuqZFLeDeSbbFkMtst7JVROSHy9aYUh3ecmeb7N5I=; b=MVNOL3otCwLJRvpm99VoY4IzH7BE69j7uXS84fGQaahcXGcDpmcnLlCG9AxiTJ0Vsp iZVtPwOL0YVLPBCHlQaNBBsBGEauaWfc8shQgeEPNC5LHCIxW5P/JgYwlaSE6+QgvSmz tZG4a/dUUyI3p45OUKTaimBmfEdBH50Ox/E6KjWitp+B7t6WmegfC0I3t3b1JIsI5bdy HfhA3pZY0UTIzSb3dfBKneg9i70pIDuG83t1umKUsAVIH4yNbt/yPQKfz+WORJIpfPrg la+aIv1JSzLzIHe9zBLuSb10HMgmLhGE2DsNYmltm5d3LI9g3y22gOw0NXGMN2vjAF2x Pofw== 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=abSuqZFLeDeSbbFkMtst7JVROSHy9aYUh3ecmeb7N5I=; b=BXekMHfqwLaXsxp/hPonQwonPGMj4R/ogA7lcc7/7EFVglvZsgcpdy7yKfME7y0ww9 1WQo7Ln9ZNEfz0DFbr4DWAOx1jBPrKR9RgYLiwLEMTvY/DmpCjRMrIX0mtYwIGL3/zMV SSv8YfKTIQQIS5kdYnH00UIlZj2Jex/ejZfZwdVb9RMoDpFL7OHV5FHJADbMZG1bXJo3 rhHcID/yDxBdej19zaKaz6pmP7O27SNRbNS19XXurgf0qbejsD+1i2nBODkCnjIhDl3L eC+DZhoe3kyLk5vTHotJt7UYYWh9i2yaRqC1jCo2X8FgI8yWExf0sW/SliNNCQYImakl +crg== X-Gm-Message-State: AFqh2kodxn9OmeT1N4PDhJ2wP2g89iUcmXt8+sX12VNIFRNWBA4zuypC y1UttH45++ji37QZ3YveqMwcUuAELho= X-Google-Smtp-Source: AMrXdXsmGGE4TinDw2a3oDH3ChIBy9lqEXA+QfQXKS0XA8daiOI1tgOBkjFGriMcV92ispYeXOA/uA== X-Received: by 2002:a05:6e02:50b:b0:30c:87a:2804 with SMTP id d11-20020a056e02050b00b0030c087a2804mr17503217ils.29.1672683936430; Mon, 02 Jan 2023 10:25:36 -0800 (PST) Received: from jassi-Alienware-x17-R2.. (wnpgmb0311w-ds01-45-179-115.dynamic.bellmts.net. [206.45.179.115]) by smtp.gmail.com with ESMTPSA id q39-20020a027b27000000b00389fb6c2ca5sm9274772jac.98.2023.01.02.10.25.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 10:25:35 -0800 (PST) From: Jassi Brar X-Google-Original-From: Jassi Brar To: u-boot@lists.denx.de Cc: ilias.apalodimas@linaro.org, etienne.carriere@linaro.org, trini@konsulko.com, sjg@chromium.org, sughosh.ganu@linaro.org, xypron.glpk@gmx.de, patrick.delaunay@foss.st.com, patrice.chotard@foss.st.com, Jassi Brar Subject: [PATCHv3 0/5] FWU: Handle meta-data in common code Date: Mon, 2 Jan 2023 12:25:32 -0600 Message-Id: <20230102182532.2411125-1-jaswinder.singh@linaro.org> X-Mailer: git-send-email 2.34.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 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. Changes since v2: * Drop whitespace changes * Fix missing mdata copy before return Changes since v1: * Fix typos and misc cosmetic changes * Catch error returns Jassi Brar (5): 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 fwu: rename fwu_get_verified_mdata to fwu_get_mdata 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 | 301 ++++++++++++--------------- 5 files changed, 214 insertions(+), 628 deletions(-) -- 2.34.1