Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3562068ybz; Mon, 27 Apr 2020 18:38:00 -0700 (PDT) X-Google-Smtp-Source: APiQypIQiicTb0F2SazoklSOuChV/LIiz3fQVmSn3cMM+kmIQSDGCBMPhJCwzfcHR2OpQMMlZHuQ X-Received: by 2002:a17:906:804a:: with SMTP id x10mr23306017ejw.86.1588037880210; Mon, 27 Apr 2020 18:38:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588037880; cv=none; d=google.com; s=arc-20160816; b=HZ6WvFuSAOKdBQXnj9J+rUIxiAhSI8KSgqebNoX9TSnymwsgiKqM5JgwKLULIX6VGs VlxEBYAQFrE4mxPsdtc4O5fSIW7ves0jm+rfKpM2WT0DUrAdl92RJFcbWnIDjym2wGs+ sbRriIDt+P9MNAEkYhzGNpC7216Wq6FJTqP/wnfd3J8YIowcRSULOM3s3aDc7elmNOic vVGtJ6/gz/QDPIJN4r4E4pijqDFb8+R+G3uQcDYdLYNdLOgbb2SEc0QK0a6mJS2taL65 6gcu3RklzuF+jwMyCNQo9s4IE6qUCZI0ZCfe/pqzpAJU4EmRgwnm4H0oOqrjVnuVvljX B+rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=yfMJBFMmEi/OeVQaEhLGDkEb8PFG/DMcsN/RfTd18dw=; b=NO5d+RYr3BkXHpksJO85kGeZcjyvYNJZzpP3z5UReOOEJlpL0s6ye2/9F7pqjG6GpN T1h54hwFgKZLXy6LxB268eBuysYhl9NY9zeV+D+Cqb6egP0ZrgPrL/Vx/xgxqS8KlxMI phMiblqXLqekJ7ezYa5yBBAavaP5fDwA/ods/Nxfcn9VP826nfVemMf9Rt4u4CwtFd2a Y9Eul1cYrkwTfcnWB244QbLLK7tFlplQIw6CH3RSjsDyWr7kPg+DGPmUnZ01sFkbpHlU RVo7FQMyN5UEQJh8/ac+rKldyagL5tW5RuUFxxCxVa6eTdET3W2X1Uxb8ZrIvq3D9H5C ixpg== ARC-Authentication-Results: i=1; mx.google.com; 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 cd11si821998ejb.435.2020.04.27.18.37.34; Mon, 27 Apr 2020 18:38:00 -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; 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 S1726303AbgD1BeN (ORCPT + 99 others); Mon, 27 Apr 2020 21:34:13 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3315 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726233AbgD1BeM (ORCPT ); Mon, 27 Apr 2020 21:34:12 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D0A9999B00C42AE7E8BD; Tue, 28 Apr 2020 09:34:09 +0800 (CST) Received: from [10.65.58.147] (10.65.58.147) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Tue, 28 Apr 2020 09:34:07 +0800 Subject: Re: [PATCH v4 05/16] mtd: spi-nor: default to address width of 3 for configurable widths To: Pratyush Yadav References: <20200424184410.8578-1-p.yadav@ti.com> <20200424184410.8578-6-p.yadav@ti.com> <6b6384ad-d37a-eea6-af29-322e83924912@hisilicon.com> <20200427172336.ihezwq3wn75m7k3l@yadavpratyush.com> CC: Pratyush Yadav , Tudor Ambarus , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Mark Brown , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , , , , , Sekhar Nori From: Yicong Yang Message-ID: Date: Tue, 28 Apr 2020 09:34:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20200427172336.ihezwq3wn75m7k3l@yadavpratyush.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.65.58.147] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Pratyush, On 2020/4/28 1:23, Pratyush Yadav wrote: > Hi Yicong, > > On 26/04/20 11:53AM, Yicong Yang wrote: >> On 2020/4/25 2:43, Pratyush Yadav wrote: >>> JESD216D.01 says that when the address width can be 3 or 4, it defaults >>> to 3 and enters 4-byte mode when given the appropriate command. So, when >>> we see a configurable width, default to 3 and let flash that default to >>> 4 change it in a post-bfpt fixup. >>> >>> This fixes SMPT parsing for flashes with configurable address width. If >>> the SMPT descriptor advertises variable address width, we use >>> nor->addr_width as the address width. But since it was not set to any >>> value from the SFDP table, the read command uses an address width of 0, >>> resulting in an incorrect read being issued. >>> >>> Signed-off-by: Pratyush Yadav >>> --- >>> drivers/mtd/spi-nor/sfdp.c | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c >>> index f917631c8110..5cecc4ba2141 100644 >>> --- a/drivers/mtd/spi-nor/sfdp.c >>> +++ b/drivers/mtd/spi-nor/sfdp.c >>> @@ -460,6 +460,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, >>> /* Number of address bytes. */ >>> switch (bfpt.dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) { >>> case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY: >>> + case BFPT_DWORD1_ADDRESS_BYTES_3_OR_4: >>> nor->addr_width = 3; >>> break; >> Should we also assign address width to 3 in default condition. At least we should not >> leave it uninitialized here. > The default condition would be taken when this field is 3. The value 3 > is reserved, and so no current device should use this value. That said, > I don't see any downsides of doing so. If the value 3 means something > else in later revisions of the standard, this code would need to change > anyway. If not, we would use a relatively sane default for devices with > a faulty BFPT. The purpose is to set one possible value which may be used later in parsing smpt. In current driver, if we do nothing with the post-bfpt fixup, then the width will be unset. Otherwise, maybe the width can also be set in spi_nor_smpt_addr_width() default: + if (!nor->addr_width) + nor->addr_width = 3; return nor->addr_width; But set when parsing bfpt seems more reasonable. > I haven't received any comments on my series so far. If end up having to > re-roll it, I will add this change. Otherwise, I'm not sure if it is a > good idea to re-roll a 16-patch series for a one liner that isn't fixing > some major bug. In that case, maybe you can send an independent patch > that does this after mine is merged? Fine. :) Regards, Yicong