public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Cyrille Pitchen - M19942 <cyrille.pitchen@microchip.com>
Cc: Tudor Ambarus <tudor.ambarus@microchip.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	<linux-mtd@lists.infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH 1/2] mtd: spi-nor: Make SFDP-based 4B_OPCODE support detection works correctly
Date: Fri, 19 Oct 2018 10:05:33 +0200	[thread overview]
Message-ID: <20181019100533.4f8ac8d4@bbrezillon> (raw)
In-Reply-To: <166fc7d5-695f-5c60-be07-c819736a123d@microchip.com>

On Fri, 19 Oct 2018 09:50:31 +0200
Cyrille Pitchen - M19942 <cyrille.pitchen@microchip.com> wrote:

> Hi Boris,
> 
> looks good, just a small remark below:
> 
> Le 17/10/2018 à 16:44, Boris Brezillon a écrit :
> > Some flash_info entries have the SPI_NOR_4B_OPCODES to let the core
> > know that the flash supports 4B opcode. While this solution works fine
> > for id-based caps detection, it doesn't work that well when relying on
> > SFDP-based caps detection. Let's add an SNOR_F_4B_OPCODES flag so that
> > spi_nor_parse_bfpt() can add it when the BFPT_DWORD1_ADDRESS_BYTES
> > field is set to BFPT_DWORD1_ADDRESS_BYTES_4_ONLY.
> > 
> > Reported-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
> > ---
> >  drivers/mtd/spi-nor/spi-nor.c | 11 ++++++++---
> >  include/linux/mtd/spi-nor.h   |  1 +
> >  2 files changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> > index 9407ca5f9443..85e57e9ea1b5 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -2643,6 +2643,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
> >  		break;
> >  
> >  	case BFPT_DWORD1_ADDRESS_BYTES_4_ONLY:
> > +		nor->flags |= SNOR_F_4B_OPCODES;  
> 
> if spi_nor_parse_sdfp() fails, there is a kind of roll-back operation done
> in spi_nor_init_params() to set the struct spi_nor *nor back to its previous
> state.
> 
> 		if (spi_nor_parse_sfdp(nor, &sfdp_params)) {
> 			nor->addr_width = 0;
> 			nor->mtd.erasesize = 0;
> 		} else {
> 			[...]
> 
> maybe "nor->flags &= ~SNOR_F_4B_OPCODES;" should be added there.

Actually, it should be

	if (!(info->flags & SPI_NOR_4B_OPCODES))
		nor->flags &= ~SNOR_F_4B_OPCODES;

but yes, this is missing. I'll fix that in v3.

> If this roll-back block grows too much, maybe we could introduce a
> void spi_nor_roll_back_sfdp(struct spi_nor *nor) function.
> Also it would make the roll back operation more explicit.

I'm wondering why we revert everything when a single bit is bit
reported as inconsistent in the SFDP table? I mean, it's not unusual
for NOR vendors to make mistake, and we should probably allow
vendor/chip specific code to fix the SFDP table at runtime instead of
discarding all the useful information we might have extracted.

Note that we recently introduced such a ->fixup() hook for the ONFI
param page in the raw NAND framework [1]. 

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/mtd/nand/raw?h=v4.19-rc8&id=00ce4e039ad5bded462931606c3063ff691964b7

  reply	other threads:[~2018-10-19  8:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-17 14:44 [PATCH 1/2] mtd: spi-nor: Make SFDP-based 4B_OPCODE support detection works correctly Boris Brezillon
2018-10-17 14:44 ` [PATCH 2/2] mtd: spi-nor: Use 4B opcodes when the NOR advertises both 3B and 4B Boris Brezillon
2018-10-18  9:43 ` [PATCH 1/2] mtd: spi-nor: Make SFDP-based 4B_OPCODE support detection works correctly Boris Brezillon
2018-10-19  7:50 ` Cyrille Pitchen - M19942
2018-10-19  8:05   ` Boris Brezillon [this message]
2018-10-19  8:29     ` Cyrille Pitchen
2018-10-19  8:53   ` Boris Brezillon

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=20181019100533.4f8ac8d4@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@microchip.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@microchip.com \
    /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