From: Boris Brezillon <boris.brezillon@bootlin.com>
To: <Tudor.Ambarus@microchip.com>
Cc: <liu.xiang6@zte.com.cn>, <cyrille.pitchen@wedev4u.fr>,
<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<marek.vasut@gmail.com>, <dwmw2@infradead.org>,
<computersforpeace@gmail.com>, <richard@nod.at>,
<liuxiang_1999@126.com>
Subject: Re: [PATCH] mtd: spi-nor: Return error when nor->addr_width not match the device size
Date: Thu, 15 Nov 2018 12:02:56 +0100 [thread overview]
Message-ID: <20181115120256.4e1a86b2@bbrezillon> (raw)
In-Reply-To: <96397ec0-14de-f09a-a18d-c67396e33fba@microchip.com>
On Thu, 15 Nov 2018 10:54:39 +0000
<Tudor.Ambarus@microchip.com> 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 <liu.xiang6@zte.com.cn> 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 <boris.brezillon@bootlin.com>
> >> Signed-off-by: Liu Xiang <liu.xiang6@zte.com.cn>
> >> ---
> >> 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...
next prev parent reply other threads:[~2018-11-15 11:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-14 12:56 [PATCH] mtd: spi-nor: Return error when nor->addr_width not match the device size Liu Xiang
2018-11-14 13:51 ` Boris Brezillon
2018-11-14 14:46 ` Liu Xiang
2018-11-15 10:54 ` Tudor.Ambarus
2018-11-15 11:02 ` Boris Brezillon [this message]
2018-11-16 13:24 ` Liu Xiang
2019-03-13 13:20 ` Liu Xiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181115120256.4e1a86b2@bbrezillon \
--to=boris.brezillon@bootlin.com \
--cc=Tudor.Ambarus@microchip.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=liu.xiang6@zte.com.cn \
--cc=liuxiang_1999@126.com \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox