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 73E48C636CC for ; Sun, 5 Feb 2023 03:01:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E04F08581D; Sun, 5 Feb 2023 04:01:09 +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="UpGVnXwc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 91A1985821; Sun, 5 Feb 2023 04:01:08 +0100 (CET) Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) (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 E2411857F5 for ; Sun, 5 Feb 2023 04:01: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=jassisinghbrar@gmail.com Received: by mail-ot1-x32b.google.com with SMTP id v24-20020a05683011d800b0068bdd29b160so2414890otq.13 for ; Sat, 04 Feb 2023 19:01:04 -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=83cyYLXLCt69D00PHCY8u+JaTb2r4DGw8zNIJhejsI0=; b=UpGVnXwcDiEn0VmjbPl7iXp8h4+tcCsIaZg2P1HvP6stVkkyQeoC8tdeUCjoX0VuHp w9tBOCnjahKqs5EAnWVWzeHPP5Wb0mFUCLG2D43ArB9n3IafpOv2o6/xcPvXgXZ+bK2U kr/O4Fds470Mjx4MJcDDk28hnHToNp2UeKmakW+BWkG9LXI3x8CElc+C/RfTNxdD+cxN pmTWHBySJNBUEQqRxW5kt/4SaJtVmRdxxc5/tGsIGxfm5Fa51G0FHIvNp3g1z3yso3w0 B7zJHNsaduMGqZvI5c7jYl1oM7G1Vn/KYslBRTcOwisFFmkG/6gziUNzDKd1brwJ1ElW Deng== 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=83cyYLXLCt69D00PHCY8u+JaTb2r4DGw8zNIJhejsI0=; b=Lfa76F+eCgRVSqqChcQdu/dKhtYLUQtk2ficGXyYIihEnyniA4kfDP8SOuqDfWU9JX fGki/U8nnqvO8WuAu7oemJyNLGfpucI0il13gsHSTKg4k/bZJqzSuNraFHH9FkpyFlmb 4tpfjdAX8uKSmyLcUB7qAPwcinOd70cIYEnBuKuxKyQJ56siYtb3Ut1nYy1SuJFYhpc4 7PdrdZSc6LDIAkmB1K8vm38N0kSkiHv+n1KCV5YQryXn/eKlOpcJGF5DeB/AUdCz7mTr 661Ojw23SevLudNVsmhXtjNIPiHoZMxLfYuJerbmS6jUgx5auAtzjdgQQ6KiyMqpaW2e ykdA== X-Gm-Message-State: AO0yUKVoY4+YhXPcjxF00xgcBXJ9LUif4VLyAXnRuoJHsRmp3fQYL+Hk pW01H6+KfHwJ+WiCAL6Ia5GuvI7nolw= X-Google-Smtp-Source: AK7set+ccmuVraubpAkV2t3V783gdViMQKPTKZcG4ZmCYSCT3Lbyfi/9D+zemjtV0yDAH4l9Xp88gg== X-Received: by 2002:a9d:65cf:0:b0:68b:cd6a:4117 with SMTP id z15-20020a9d65cf000000b0068bcd6a4117mr7599975oth.5.1675566063117; Sat, 04 Feb 2023 19:01:03 -0800 (PST) Received: from jassi-Alienware-x17-R2.. (wnpgmb0311w-ds01-45-177-228.dynamic.bellmts.net. [206.45.177.228]) by smtp.gmail.com with ESMTPSA id h13-20020a9d6f8d000000b0068657984c22sm3039996otq.32.2023.02.04.19.01.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 19:01:02 -0800 (PST) From: jassisinghbrar@gmail.com 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: [PATCHv4 0/5] FWU: Handle meta-data in common code Date: Sat, 4 Feb 2023 21:00:56 -0600 Message-Id: <20230205030056.61345-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.6 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 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 (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 | 294 +++++++++++---------------- 5 files changed, 207 insertions(+), 628 deletions(-) -- 2.34.1