Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4228127pxf; Tue, 16 Mar 2021 08:29:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw88691MIVr/Co+pY3kbioAbSrHS9BIg0IZp5bJfBN/FW37QgfjHtemTXYAZX1RiFhGpaI X-Received: by 2002:a05:6402:50c8:: with SMTP id h8mr36128442edb.360.1615908546733; Tue, 16 Mar 2021 08:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615908546; cv=none; d=google.com; s=arc-20160816; b=dXgK7r2bkhkLqqFNGbJBVlPCmJrcQPB78CLntBPRASPjJnMQVBSIxlyQFuM6p/drLl SJrmxGMHtLdMoGFjzMY3+rGB6NPuIkH0u8wcnj5weod9lXoYYLDQba/DZDm0QwU5zShF GUoVUfuUof2oyXIxK4EpgPLWWFt01174E5tDNBQ4IffHEw482mPhQJUt0Ms6AIGCXRap /UuNuutTBlEUDH+SzYVQXk8gl3r05SajxFOdgK6bO/uWV2rpa79vZlaph+RTa3asvIT9 yqJiXhvlYCBCl7nSZSfT8GXWqMjhILTuX1ZZrINmO+6k+xprQX2fboBt/aYW1Ia1IJKI UGoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=WBKI5HqpKGD/CDbdtKBZ6BpnHmwmYnhqrgtw6eCylnw=; b=Bn1LrJIHMaa+5wER13c9QnMGy2IKwI3UhiW5TyrdBMBTBCI134QhuwSY9P4Iwfq3tk W0mXzcWADxOm841FCj0Hg5651eb9Uvxm9zkToupH8F8xlB+OZua4bbn+D91cR4YXWhmb uASG7mRZNRXvq93PkHTkns5gJHWuN7EoEElSbKjjcHLfD9H/2OqE7yAXfr7uu1mKNmiV tVajn4EQz1AKYNyYzxaPbMYs2JFbD1WLV7JXojDifKYKwIiJ3/Lv7SnO99lKMHf/kUqe lnOooAKjCkTdKFP+WBeIjKbcAc4pRH/UFicWvIo+g3HS7hZCgI1u7p/4ojJCRm4DOgHd oUnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Zb02Wr8c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b59si12254118edf.40.2021.03.16.08.28.44; Tue, 16 Mar 2021 08:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Zb02Wr8c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbhCPLB5 (ORCPT + 99 others); Tue, 16 Mar 2021 07:01:57 -0400 Received: from ssl.serverraum.org ([176.9.125.105]:56157 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237002AbhCPLBX (ORCPT ); Tue, 16 Mar 2021 07:01:23 -0400 Received: from ssl.serverraum.org (web.serverraum.org [172.16.0.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 71D4122238; Tue, 16 Mar 2021 12:01:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1615892481; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WBKI5HqpKGD/CDbdtKBZ6BpnHmwmYnhqrgtw6eCylnw=; b=Zb02Wr8c797LE+nu+kZ+tgi/grN+PLND2cXVZzd3yA+U4f2w+ErJFzbRfoftlJINrUWz/8 9RarBnws8jtYLnxE81djCexekw5vMVCo/5YBljGEF+mlWq3DDgnYmfAok0GCVB+Cfa1UGh K/JUZ2vNG6H5zo8JvqVAn6EyaLtsfhk= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 16 Mar 2021 12:01:21 +0100 From: Michael Walle To: Pratyush Yadav Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Subject: Re: [RFC PATCH 1/3] mtd: spi-nor: sfdp: remember sfdp_size In-Reply-To: <20210316104223.42tdob3uwjxc5vdz@ti.com> References: <20210312190548.6954-1-michael@walle.cc> <20210312190548.6954-2-michael@walle.cc> <20210316104223.42tdob3uwjxc5vdz@ti.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <065642fa4d4282d3d16e1d4f4c176ce8@walle.cc> X-Sender: michael@walle.cc Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pratyush, Am 2021-03-16 11:42, schrieb Pratyush Yadav: > On 12/03/21 08:05PM, Michael Walle wrote: >> Save the sftp_size in the spi_nor struct so we can use it to dump the >> SFDP table without parsing the headers again. >> >> Signed-off-by: Michael Walle >> --- >> drivers/mtd/spi-nor/sfdp.c | 12 ++++++++++++ >> include/linux/mtd/spi-nor.h | 1 + >> 2 files changed, 13 insertions(+) >> >> diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c >> index 25142ec4737b..b1814afefc33 100644 >> --- a/drivers/mtd/spi-nor/sfdp.c >> +++ b/drivers/mtd/spi-nor/sfdp.c >> @@ -16,6 +16,7 @@ >> (((p)->parameter_table_pointer[2] << 16) | \ >> ((p)->parameter_table_pointer[1] << 8) | \ >> ((p)->parameter_table_pointer[0] << 0)) >> +#define SFDP_PARAM_HEADER_PARAM_LEN(p) ((p)->length * 4) >> >> #define SFDP_BFPT_ID 0xff00 /* Basic Flash Parameter Table */ >> #define SFDP_SECTOR_MAP_ID 0xff81 /* Sector Map Table */ >> @@ -1263,6 +1264,7 @@ int spi_nor_parse_sfdp(struct spi_nor *nor, >> struct sfdp_parameter_header *param_headers = NULL; >> struct sfdp_header header; >> struct device *dev = nor->dev; >> + size_t param_max_offset; >> size_t psize; >> int i, err; >> >> @@ -1285,6 +1287,9 @@ int spi_nor_parse_sfdp(struct spi_nor *nor, >> bfpt_header->major != SFDP_JESD216_MAJOR) >> return -EINVAL; >> >> + nor->sfdp_size = SFDP_PARAM_HEADER_PTP(bfpt_header) + >> + SFDP_PARAM_HEADER_PARAM_LEN(bfpt_header); >> + >> /* >> * Allocate memory then read all parameter headers with a single >> * Read SFDP command. These parameter headers will actually be >> parsed >> @@ -1311,6 +1316,13 @@ int spi_nor_parse_sfdp(struct spi_nor *nor, >> } >> } >> >> + for (i = 0; i < header.nph; i++) { >> + param_header = ¶m_headers[i]; >> + param_max_offset = SFDP_PARAM_HEADER_PTP(param_header) + >> + SFDP_PARAM_HEADER_PARAM_LEN(param_header); >> + nor->sfdp_size = max(nor->sfdp_size, param_max_offset); >> + } >> + > > I don't see any mention in the SFDP spec (JESD216D-01) that parameter > tables have to be contiguous. ch. 6.1, fig.10 looks like all the headers come after the initial SFDP header. If that wasn't the case, how would you find the headers then? Also ch. 6.3 """All subsequent parameter headers need to be contiguous and may be specified...""" > In fact, it says that "Parameter tables > may be located anywhere in the SFDP space. They do not need to > immediately follow the parameter headers". The tables itself, yes, but not the headers for the tables. > But I guess we can just say > the sysfs entry exports the entire SFDP space instead of just the > tables > so that is OK. > > This patch looks good to me other than the small nitpick that we can > merge this loop and the one below that tries to find the latest BFPT > version. btw. I've also added an export for the jedec id and the flash name to this patch, which will be included in the next version. >> /* >> * Check other parameter headers to get the latest revision of >> * the basic flash parameter table. >> diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h >> index a0d572855444..a58118b8b002 100644 >> --- a/include/linux/mtd/spi-nor.h >> +++ b/include/linux/mtd/spi-nor.h >> @@ -404,6 +404,7 @@ struct spi_nor { >> bool sst_write_second; >> u32 flags; >> enum spi_nor_cmd_ext cmd_ext_type; >> + size_t sfdp_size; > > Documentation for this variable missing. > >> >> const struct spi_nor_controller_ops *controller_ops; >> >> -- >> 2.20.1 >> -- -michael