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 BF077C6FA82 for ; Fri, 23 Sep 2022 06:16:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FE0084BE0; Fri, 23 Sep 2022 08:16:36 +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="QBbJoIJK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 79A4384BE1; Fri, 23 Sep 2022 08:16:34 +0200 (CEST) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 0778684BC4 for ; Fri, 23 Sep 2022 08:16:32 +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=ilias.apalodimas@linaro.org Received: by mail-ej1-x631.google.com with SMTP id sd10so17371748ejc.2 for ; Thu, 22 Sep 2022 23:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=oIBff+CVaylKjrgvLNxSUMutNWGQAjVe+wBY7bB26XQ=; b=QBbJoIJKBv9dH3SYauwV3aN4GpjZKo48NgZHNkR1E7WCGYofbMldMVza2/n1U7AUwa V6yZeBt0dLx0uMf9z+8CQwlNX5gntVJMsI+XVEleJ7EXEbSbd/K584wKt7x3ZkxU6lKW Y5Cma6MlwWpKxBenfWY5lO4GSbjODg8incn/CeyM3jZUac2OPIUW+YjLblydpx6vPt8V SUkyC5Hc3IopjzvLMHKPRnTPrp2A5DzCPbWdQfBd1XXHywEBJ78M1ePUAP5NJrSgguAu p2H1JkX2KQchsZSeOZm5G9bTmgTz/EUiix+AzNpMnz9vtpJSF2rGnPkdBqOcvojAiNgh WbJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=oIBff+CVaylKjrgvLNxSUMutNWGQAjVe+wBY7bB26XQ=; b=AL0DcDQv9MeW5teP4WPtYs02xV3mnew+0g3P51iElcBgDdxBmEyZ6L+qzVVUHNl2JR WuvS9cIXhugFELSdRDRwAcd72xWj9iDJoQ4cMZzFGfakmZ1Yqrk/2eK9K70i6AiqjNa6 yX0fAdXKWYI26qbzkHJpG1k/PoKPLe8GlQkFGi79xn4HYhFWVQebiZR5EfeVXR28sSN3 zAamcHWKB0F0OR9uXSEFA3XMxR7s2T+6WVxvLv1gcNkRuLipW/5tCL+Xdo2lcX7RdGHo dvGWDF/+REYQ/UW2xyo/KdoPUMmC31BP40N4f0GH+dxspNdPNVSaP4o6Lel+mq+kyr9X LpLw== X-Gm-Message-State: ACrzQf0KuUdl/TQt+VejnSwI3+HrdLy/gZfEzk+XACV2F8c8dLd8mDBc 4M67tRFIgLtAiidAMXlm6bXqEA== X-Google-Smtp-Source: AMsMyM4fkwm3TPac3cHTl7E5kRUDMqE4pUcSQYYlvsCuKS33324stEp/CEWIf7ouLxJoBAEQWhN74A== X-Received: by 2002:a17:907:2721:b0:77c:29f9:2c84 with SMTP id d1-20020a170907272100b0077c29f92c84mr5767818ejl.721.1663913791527; Thu, 22 Sep 2022 23:16:31 -0700 (PDT) Received: from hades ([46.103.15.185]) by smtp.gmail.com with ESMTPSA id ku2-20020a170907788200b007708635be05sm3617194ejc.4.2022.09.22.23.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 23:16:31 -0700 (PDT) Date: Fri, 23 Sep 2022 09:16:28 +0300 From: Ilias Apalodimas To: Sughosh Ganu Cc: u-boot@lists.denx.de, Heinrich Schuchardt , Takahiro Akashi , Patrick Delaunay , Patrice Chotard , Simon Glass , Bin Meng , Tom Rini , Etienne Carriere , Michal Simek , Jassi Brar Subject: Re: [PATCH v10 06/15] FWU: Add helper functions for accessing FWU metadata Message-ID: References: <20220915081451.633983-1-sughosh.ganu@linaro.org> <20220915081451.633983-7-sughosh.ganu@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 [...] > > > +static int fwu_gpt_get_alt_num(struct blk_desc *desc, efi_guid_t *image_guid, > > > + u8 *alt_num, unsigned char dfu_dev) > > > +{ > > > + int ret = -1; > > > + int i, part, dev_num; > > > + int nalt; > > > + struct dfu_entity *dfu; > > > + > > > + dev_num = desc->devnum; > > > + part = get_gpt_dfu_identifier(desc, image_guid); > > > + if (part < 0) > > > + return -ENOENT; > > > + > > > + dfu_init_env_entities(NULL, NULL); > > > + > > > + nalt = 0; > > > + list_for_each_entry(dfu, &dfu_list, list) > > > + nalt++; > > > + > > > + if (!nalt) { > > > + log_warning("No entities in dfu_alt_info\n"); > > > + dfu_free_entities(); > > > + return -ENOENT; > > > + } > > > + > > > + for (i = 0; i < nalt; i++) { > > > + dfu = dfu_get_entity(i); > > > + > > > + if (!dfu) > > > + continue; > > > + > > > + /* > > > + * Currently, Multi Bank update > > > + * feature is being supported > > > + * only on GPT partitioned > > > + * MMC/SD devices. > > > + */ > > > + if (dfu->dev_type != dfu_dev) > > > + continue; > > > + > > > + if (dfu->layout == DFU_RAW_ADDR && > > > + dfu->data.mmc.dev_num == dev_num && > > > + dfu->data.mmc.part == part) { > > > + *alt_num = dfu->alt; > > > + ret = 0; > > > + break; > > > > I get that we only currently support it on mmc, but the if above is not > > going to scale as we add devices. Is there something better we can come > > up with? Probably a helper in the dfu layer? > > Currently, the DFU supports only the mmc which will be a GPT > partitioned device. But yes, yours is a valid point in terms of > scalability. However, I am wondering if this check should instead be > in the board file. Every platform would know which is the device being > used for storing the firmware images. Will this check not be more apt > in a board function? Isn't this supposed to come from the dfu_alt_info in the command line? IOW What you are trying to prevent here is a user misconfiguration? Thanks /Ilias > > -sughosh > > > > > Cheers > > /Ilias > > > > > > > + } > > > + } > > > + > > > + dfu_free_entities(); > > > + > > > + return ret; > > > +} > > > + > > > +/** > > > + * fwu_plat_get_alt_num() - Get the DFU alt number > > > + * @dev: FWU metadata device > > > + * @image_guid: GUID value of the image for which the alt num is to > > > + * be obtained > > > + * @alt_num: The DFU alt number for the image that is to be updated > > > + * > > > + * Get the DFU alt number for the image that is to be updated. The > > > + * image is identified with the image_guid parameter that is passed > > > + * to the function. > > > + * > > > + * Note: This is a weak function and platforms can override this with > > > + * their own implementation for obtaining the alt number value. > > > + * > > > + * Return: 0 if OK, -ve on error > > > + * > > > + */ > > > +__weak int fwu_plat_get_alt_num(struct udevice *dev, efi_guid_t *image_guid, > > > + u8 *alt_num) > > > +{ > > > + struct fwu_mdata_gpt_blk_priv *priv = dev_get_priv(dev); > > > + > > > + return fwu_gpt_get_alt_num(dev_get_uclass_plat(priv->blk_dev), > > > + image_guid, alt_num, DFU_DEV_MMC); > > > +} > > > -- > > > 2.34.1 > > >