Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7879068imu; Thu, 15 Nov 2018 03:04:12 -0800 (PST) X-Google-Smtp-Source: AJdET5cqbcFgpYRbzt8JQkBsDnVtn/Nox7relF44Sm1wCd9kQ1MxczjJofD3JN9QpkRVoW4JkoRj X-Received: by 2002:a63:5517:: with SMTP id j23-v6mr5274375pgb.208.1542279852420; Thu, 15 Nov 2018 03:04:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542279852; cv=none; d=google.com; s=arc-20160816; b=kD1tkIZKKkpoOO8dRsczsjaCcHy4Lu3b5WhtMH/Re+omFYftG/gbjFgDwacHeBAoVv fZZxk2y7ISDanef0XAr9H2VB8KT/FwDUifAQqAm2XxYER0AD9OJuMnYMiRY1z+TS35CW g1Kmia2wbfnjW6T2H7fkYgXdslElD6JxzHy2wwJwzWsltU+aS+WBwbo7KsWtsp6B810x GPgKSgd1xbzBOfuuIYTjTt4zQXKNzW9cUakNOuOhcjRRaIx/mUQWGVDRe3Uvk9B6I6k8 NHN6UAC43tpirkW8XRyjkovx7ym2AAa6qKpYAWtB9+OgkK5lqSOWFx+T7tCU22/OLDCk 86cA== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=wCspDyzI09ThEfZDiM0F9GjUXuhSeudu0iGmRbLdw+k=; b=Jc62d8229hdPOVuqWDIHCp3YEVSjhkjjnQyJ75a3m80WXvnb4xWCuD/xWK0ppv2V0j 6kqzNjjgySOTpr63FPNrT8OiUG+WQL13U6QDAJ6FTjheZAVnTTc9lGB9F/tRpnz1ucwk MEAR3DmK8KM5i2LV8PUiWPsksw7Oo0+UkhrrIGVcp4nCEe49kXO3GPaBMHVCskrm0DjV G4IJCWG6wPG4dOF2hiW2VnoebTF4W0VLzhmjs5e5HM6Tl/xX9MyUcOWecEvb1MX3+AT2 EXGz/ZF2wh/sNH2srKAMHy3myR1NzxpptthXZ/XNbNTTf30XSiFS0NCWNuN/5Git/b5Q WVPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q76-v6si21112835pfa.211.2018.11.15.03.03.56; Thu, 15 Nov 2018 03:04:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732953AbeKOVKa (ORCPT + 99 others); Thu, 15 Nov 2018 16:10:30 -0500 Received: from mail.bootlin.com ([62.4.15.54]:36615 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728984AbeKOVKa (ORCPT ); Thu, 15 Nov 2018 16:10:30 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 15B8A20746; Thu, 15 Nov 2018 12:03:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (aaubervilliers-681-1-13-146.w90-88.abo.wanadoo.fr [90.88.134.146]) by mail.bootlin.com (Postfix) with ESMTPSA id BA94D2039F; Thu, 15 Nov 2018 12:02:56 +0100 (CET) Date: Thu, 15 Nov 2018 12:02:56 +0100 From: Boris Brezillon To: Cc: , , , , , , , , Subject: Re: [PATCH] mtd: spi-nor: Return error when nor->addr_width not match the device size Message-ID: <20181115120256.4e1a86b2@bbrezillon> In-Reply-To: <96397ec0-14de-f09a-a18d-c67396e33fba@microchip.com> References: <1542200165-3073-1-git-send-email-liu.xiang6@zte.com.cn> <20181114145129.568e4bb3@bbrezillon> <96397ec0-14de-f09a-a18d-c67396e33fba@microchip.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 15 Nov 2018 10:54:39 +0000 wrote: > Hi, Liu, Boris, Cyrille, > > On 11/14/2018 03:51 PM, Boris Brezillon wrote: > > On Wed, 14 Nov 2018 20:56:05 +0800 > > Liu Xiang wrote: > > > >> In is25lp256, the DWORD1 of JEDEC Basic Flash Parameter Header > >> is 0xfff920e5. So the DWORD1[18:17] Address Bytes bits are 0b00, > > Liu, can you point us to a datasheet that has the JEDEC BFPT tables described? I > couldn't find one ... > > >> means that 3-Byte only addressing. > > > > According to your other patch this NOR supports 4B opcode, which means > > the SFDP table is wrong. > > > >> But the device size is larger > >> than 16MB, nor->addr_width must be 4 to access the whole address. > >> An error should be returned when nor->addr_width not match > > > > ^does not > > > >> the device size in spi_nor_parse_sfdp(). > >> > >> Suggested-by: Boris Brezillon > >> Signed-off-by: Liu Xiang > >> --- > >> drivers/mtd/spi-nor/spi-nor.c | 4 ++++ > >> 1 file changed, 4 insertions(+) > >> > >> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > >> index 3eba13a..77eaf22 100644 > >> --- a/drivers/mtd/spi-nor/spi-nor.c > >> +++ b/drivers/mtd/spi-nor/spi-nor.c > >> @@ -2669,6 +2669,10 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor, > >> } > >> params->size >>= 3; /* Convert to bytes. */ > >> > >> + /*if the device exceeds 16MiB, addr_width must be 4*/ > > > > Please add a white space after '/*' and before '*/': > > > > /* If the device exceeds 16MiB, ->addr_width must be 4. */ > > > >> + if ((params->size > 0x1000000) && (nor->addr_width == 3)) > > > > Parens are not needed around sub-conditions: > > > > if (params->size > 0x1000000 && nor->addr_width == 3) > > > >> + return -EINVAL; > >> + > > > > I'm not sure this is correct. Looks like some NORs only support 3B > > opcodes but have a "4-byte addressing" mode (see set_4byte() [1]). > > Don't know what's reported by the BFPT section in this case though > > (BFPT_DWORD1_ADDRESS_BYTES_3_ONLY or BFPT_DWORD1_ADDRESS_BYTES_3_OR_4). > > Boris, this is in close relation with your second patch: [PATCH v3 2/2] mtd: > spi-nor: Use 4B opcodes when the NOR advertises both 3B and 4B. > > When looking again at this, I would say that for the flashes that have a "4-byte > addressing" mode, but just 3B opcodes, I would expect the DWORD1[18:17] to be of > value BFPT_DWORD1_ADDRESS_BYTES_3_OR_4 (enters 4-Byte mode on command - uses 3B > opcodes). The NOR we have and which is exposing BFPT_DWORD1_ADDRESS_BYTES_3_OR_4 actually supports both 3B and 4B commands, so, in this particular case, BFPT_DWORD1_ADDRESS_BYTES_3_OR_4 does not mean "3B opcode+4-byte addressing mode" > > If BFPT_DWORD1_ADDRESS_BYTES_3_OR_4 and 4B opcodes, then we can query BFPT > DWORD16[31:24]: it should have value xx1x_xxxxb to indicate that 4B opcodes are > supported. But which 4B opcodes are supported? I hope all of them. Wouldn't make sense to have only some of them supported. > Do all 3B opcodes have a 4B > opcode correspondent if SFDP 4-byte table is not available? This might be a good > assumption, but I can't see it anywhere in jesd216c. I hope so...