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 37FA9C43334 for ; Thu, 14 Jul 2022 05:20:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 41E9384013; Thu, 14 Jul 2022 07:20:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="Ul1QoPJy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6D6784015; Thu, 14 Jul 2022 07:20:31 +0200 (CEST) Received: from mail-vk1-xa34.google.com (mail-vk1-xa34.google.com [IPv6:2607:f8b0:4864:20::a34]) (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 9A06483FFC for ; Thu, 14 Jul 2022 07:20:28 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sughosh.ganu@linaro.org Received: by mail-vk1-xa34.google.com with SMTP id q194so339429vkb.6 for ; Wed, 13 Jul 2022 22:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tdPWsxa6BBalaosZghwuYcmOpQBN4vj0Rz5G++i3ZcA=; b=Ul1QoPJy9tprLYvUJOoHSY161/gdO+08bWDrfWwNq+0hei8s/txNdrODrTfLFW/CaB GuogYcFMsvcrmbEecQgyRvb8Pse5atdw2ZdoL1YpXbmk4gFDaCOmaqMEHVykDDTrP/W1 kKxY8kDdCuC99s6k0pleV4binSuoYNARszEYPmWgq+zQYb4C/HA65r9F/bg6ztyPXKtP D+HRIWvhqCVINFRyQ4AY9+XA02xBDN4EQL4OM0UaDhoodAW8D6qsh7XnRtJMOrtLO4P6 ayPynAqQ8rcTslPwsY4T114WRKT9sTOPtH+UsExQ9l92dZdO5secdxF0jslT+McvR0y/ Ewfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tdPWsxa6BBalaosZghwuYcmOpQBN4vj0Rz5G++i3ZcA=; b=wpp16TccLzVhqSiIsoZsUeUGkvnL221aIt0Li2IAojLPwzvDw3D/7BYVYw5XaEPj8u HMSvziC2mji5k66i32UYDu7sFq3dtG65qYkLZsr72eUL9GYJ/Ch9IxN2TaXF8tFL36hf lFb8pRKbnKUTYXpfEqJ2MYjZYPE7YkP7Z9bOazB3FCk4AaAjkaj/R4edz5Kmq674zSOV 9mgqpJuGCsVSKi82QDTC2hJa46q71gSk4qgc0a3VkhxFrAHQGqCQjrBPczJRLkIqDZqZ EF/imwnOUG3wpiq91suzE33c+t1DH4dVLV18nLBrb8FgleOtSorvYELkXnPChiqB5Ttw UA8w== X-Gm-Message-State: AJIora8RepnCLGNn6E4pEOszdsVFnzdEXGzm+O/kfXwOkTFft6/yljMV GtFDrphaMmpS1cSgAk2TqPeT0yi4RFrau/KUhq6M2g== X-Google-Smtp-Source: AGRyM1vSdQJd8RES+7iwfXKkAN5QnsUCizHEDP8h5O7t+Z1oXpDDv2SYb2Vmri04tdHjGboUO01jML17ToB+Yaqfe/U= X-Received: by 2002:a05:6122:1281:b0:374:ba5d:37aa with SMTP id i1-20020a056122128100b00374ba5d37aamr2744341vkp.1.1657776027251; Wed, 13 Jul 2022 22:20:27 -0700 (PDT) MIME-Version: 1.0 References: <20220704051658.1085442-1-sughosh.ganu@linaro.org> <20220704051658.1085442-4-sughosh.ganu@linaro.org> In-Reply-To: From: Sughosh Ganu Date: Thu, 14 Jul 2022 10:50:16 +0530 Message-ID: Subject: Re: [PATCH v6 03/13] FWU: Add FWU metadata access driver for GPT partitioned block devices To: Patrick DELAUNAY Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Etienne Carriere , Michal Simek , Jassi Brar Content-Type: text/plain; charset="UTF-8" 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 hi Patrick, On Wed, 13 Jul 2022 at 18:47, Patrick DELAUNAY wrote: > > Hi, > > On 7/4/22 07:16, Sughosh Ganu wrote: > > In the FWU Multi Bank Update feature, the information about the > > updatable images is stored as part of the metadata, on a separate > > partition. Add a driver for reading from and writing to the metadata > > when the updatable images and the metadata are stored on a block > > device which is formated with GPT based partition scheme. > > > > Signed-off-by: Sughosh Ganu > > --- > > Changes since V5: > > * Changed the logic to store the GPT partitioned block device through > > a priv structure as suggested by Patrick > > * Used dev_read_prop() to get the phandle_p instead of > > ofnode_get_property() used earlier as suggested by Patrick > > * Make relevant functions static as suggested by Etienne > > > > drivers/fwu-mdata/Kconfig | 9 + > > drivers/fwu-mdata/Makefile | 1 + > > drivers/fwu-mdata/fwu_mdata_gpt_blk.c | 408 ++++++++++++++++++++++++++ > > include/fwu.h | 5 + > > 4 files changed, 423 insertions(+) > > create mode 100644 drivers/fwu-mdata/fwu_mdata_gpt_blk.c > > > > diff --git a/drivers/fwu-mdata/Kconfig b/drivers/fwu-mdata/Kconfig > > index d6a21c8e19..d5edef19d6 100644 > > --- a/drivers/fwu-mdata/Kconfig > > +++ b/drivers/fwu-mdata/Kconfig > > @@ -5,3 +5,12 @@ config DM_FWU_MDATA > > Enable support for accessing FWU Metadata partitions. The > > FWU Metadata partitions reside on the same storage device > > which contains the other FWU updatable firmware images. > > + > > +config FWU_MDATA_GPT_BLK > > + bool "FWU Metadata access for GPT partitioned Block devices" > > + select PARTITION_TYPE_GUID > > + select PARTITION_UUIDS > > + depends on DM && HAVE_BLOCK_DEVICE && EFI_PARTITION > > + help > > + Enable support for accessing FWU Metadata on GPT partitioned > > + block devices. > > diff --git a/drivers/fwu-mdata/Makefile b/drivers/fwu-mdata/Makefile > > index e53a8c9983..313049f67a 100644 > > --- a/drivers/fwu-mdata/Makefile > > +++ b/drivers/fwu-mdata/Makefile > > @@ -4,3 +4,4 @@ > > # > > > > obj-$(CONFIG_DM_FWU_MDATA) += fwu-mdata-uclass.o > > +obj-$(CONFIG_FWU_MDATA_GPT_BLK) += fwu_mdata_gpt_blk.o > > diff --git a/drivers/fwu-mdata/fwu_mdata_gpt_blk.c b/drivers/fwu-mdata/fwu_mdata_gpt_blk.c > > new file mode 100644 > > index 0000000000..d904c9492d > > --- /dev/null > > +++ b/drivers/fwu-mdata/fwu_mdata_gpt_blk.c > > @@ -0,0 +1,408 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * Copyright (c) 2022, Linaro Limited > > + */ > > #define LOG_CATEGORY UCLASS_FWU_MDATA I think you had mentioned this in your earlier review as well. Sorry, I missed out on this. Will add in the next version. > > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#define PRIMARY_PART BIT(0) > > +#define SECONDARY_PART BIT(1) > > +#define BOTH_PARTS (PRIMARY_PART | SECONDARY_PART) > > + > > +#define MDATA_READ BIT(0) > > +#define MDATA_WRITE BIT(1) > > + > > (...) > > > > + > > +static const struct fwu_mdata_ops fwu_gpt_blk_ops = { > > + .mdata_check = fwu_gpt_mdata_check, > > + .get_mdata = fwu_gpt_get_mdata, > > + .update_mdata = fwu_gpt_update_mdata, > > +};UCLASS_FWU_MDATA > > > > + > > +static const struct udevice_id fwu_mdata_ids[] = { > > + { .compatible = "u-boot,fwu-mdata-gpt" }, > > + { } > > +}; > > + > > +U_BOOT_DRIVER(fwu_mdata_gpt_blk) = { > > + .name = "fwu-mdata-gpt-blk", > > + .id = UCLASS_FWU_MDATA, > > + .of_match = fwu_mdata_ids, > > + .ops = &fwu_gpt_blk_ops, > > + .probe = fwu_mdata_gpt_blk_probe, > > + .priv_auto = sizeof(struct fwu_mdata_gpt_blk_priv), > > +}; > > diff --git a/include/fwu.h b/include/fwu.h > > index e03cfff800..8259c75d12 100644 > > --- a/include/fwu.h > > +++ b/include/fwu.h > > @@ -14,6 +14,10 @@ > > struct fwu_mdata; > > struct udevice; > > > > +struct fwu_mdata_gpt_blk_priv { > > + struct udevice *blk_dev; > > +}; > > + > > NITS: really needed in .h file => private, only used by driver in .c ? I have put it here since this gets accessed in the board file as well to retrieve the block device which has the fwu metadata and the firmware images in fwu_plat_get_alt_num(). > > > > /** > > * @mdata_check: check the validity of the FWU metadata partitions > > * @get_mdata() - Get a FWU metadata copy > > @@ -39,6 +43,7 @@ int fwu_get_active_index(u32 *active_idx); > > int fwu_update_active_index(u32 active_idx); > > int fwu_get_image_alt_num(efi_guid_t *image_type_id, u32 update_bank, > > int *alt_num); > > +int fwu_verify_mdata(struct fwu_mdata *mdata, bool pri_part); > > int fwu_mdata_check(void); > > int fwu_revert_boot_index(void); > > int fwu_accept_image(efi_guid_t *img_type_id, u32 bank); > > > with the minor modification (LOG_CATEGORY) > > > Reviewed-by: Patrick Delaunay Thanks. -sughosh