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 006AAC61DA4 for ; Mon, 6 Mar 2023 23:18:06 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2635F85359; Tue, 7 Mar 2023 00:18:04 +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="EhUSEXl4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EF1F580BAF; Tue, 7 Mar 2023 00:18:00 +0100 (CET) Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) (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 CBB79858B8 for ; Tue, 7 Mar 2023 00:17:55 +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-qv1-xf34.google.com with SMTP id nv15so7825659qvb.7 for ; Mon, 06 Mar 2023 15:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678144674; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hY6nCxWQfA5r5GBnAlmcSkveaqABR56PNP8Nx2R2vKM=; b=EhUSEXl4vSM4YX4b45wYKcUURwjqQ/JtZ8hbAAbblJogDqET+WykRRVhLUPC0ipSbo xMJH61MAjxW1RYFN0BCsyXHOtWUx+7VQObpYiR3+HKPYcjOWDhjZL+2LK5hX0k7gOTz5 bL5Dzi+H8AG//MyjGzd2eAPg6Zs4DqbsqCBOm7LP2u6TpY2FUhLkOYM+5KnBY40YPhQM Cn/1mchWq5F3AD7TtHHEbMHPGSK3lVihLh7jyj5EAZftUSHoh+EmK11LS9a/zg90cAVS RIwcLJZ4q/uoAKLE2TlcvCh6/NONivKUJEyZySc/BKWnuf9f+59zkQJCAs46lLxcpzZU nQvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678144674; 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=hY6nCxWQfA5r5GBnAlmcSkveaqABR56PNP8Nx2R2vKM=; b=Iemge6ZMLy4RpRah4xjO+D1a2nJ0q7Ir6ctSwtoQ8MfMyUvLAM6XoiryiQKWA1P+mg yhBdqSOxTLVgtDZW/prQT+La+eqplKLAFk6KGCiUbe9ePfHAoziIM/mgpAd/W+f3xRms x2Ll0NvSl3M+gaDh/MBxk8Oz1yv+Hgn61VN78pxIjvxNvjEbqhAat7GoPzKPsjjlij+t G9uVF1CjQsUjGNCF0+zntTTawrqoHTTGbLrccvB5WEpnk41kFaaCrTQAr/ZVALrP9/3E fwpTmRfTZIbhtPOouUioJYISt96FOZdu9AMJ9Sttq/sixjSKwIcVsgdevKEjSbnoLeTF pcZg== X-Gm-Message-State: AO0yUKUgwTil/6ssbqDO4tq0QNzv+xvaZ0nKvnCqeZIWnGSod4RfJtzW Bhz7HCExA1whQiMX7iZYPvMTc0/+qeA= X-Google-Smtp-Source: AK7set/fgYCWyfzpBoQg+uNh2bFTgIvfdC7IyoNTV2bybdX8J8WznWd4dtUYz80LAHee6XQU24AZ3w== X-Received: by 2002:a05:6214:d0e:b0:571:314:d725 with SMTP id 14-20020a0562140d0e00b005710314d725mr21343101qvh.49.1678144672159; Mon, 06 Mar 2023 15:17:52 -0800 (PST) Received: from jassi-desktop.. (wnpgmb0311w-ds01-45-177-228.dynamic.bellmts.net. [206.45.177.228]) by smtp.gmail.com with ESMTPSA id d15-20020a05620a240f00b00742562938cfsm8670580qkn.107.2023.03.06.15.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 15:17:51 -0800 (PST) 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 v6 0/7] fwu: gpt: implement read_mdata and write_mdata callbacks Date: Mon, 6 Mar 2023 17:17:47 -0600 Message-Id: <20230306231747.1888513-1-jassisinghbrar@gmail.com> 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.8 at phobos.denx.de X-Virus-Status: Clean From: Jassi Brar 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 v5: * Fix SANDBOX tests * Removed '@' from dt nodes * misc cosmetic changes suggested by Etienne Changes since v4: * Change fwu-mdata-mtd bindings to not require external changes * Handle 'part == BOTH_PARTS' in fwu_sync_mdata * use parts_ok[] and parts_mdata[] instead of pri/sec_ok and p/s_mdata Changes since v3: * Fix error log wording * call fwu_write_mdata() with part & PRIMARY_PART ? true: false 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 (7): dt/bindings: fwu-mdata-mtd: drop changes outside FWU 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 test: dm: fwu: fix for the updated api cmd/fwu_mdata.c | 17 +- .../firmware/fwu-mdata-mtd.yaml | 105 ++++++- drivers/fwu-mdata/fwu-mdata-uclass.c | 151 +-------- drivers/fwu-mdata/gpt_blk.c | 175 +++-------- include/fwu.h | 198 ++---------- lib/fwu_updates/fwu.c | 296 ++++++++---------- test/dm/fwu_mdata.c | 22 +- 7 files changed, 299 insertions(+), 665 deletions(-) -- 2.34.1