public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Marek Vasut" <marek.vasut@gmail.com>,
	linux-mtd@lists.infradead.org
Cc: Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH 10/10] mtd: spi-nor: aspeed: optimize read mode
Date: Tue, 11 Apr 2017 18:23:58 +1000	[thread overview]
Message-ID: <1491899038.4166.236.camel@kernel.crashing.org> (raw)
In-Reply-To: <e27b9f19-947f-ab72-056d-d71812e69356@kaod.org>

On Tue, 2017-04-11 at 10:13 +0200, Cédric Le Goater wrote:
> 
> > Something tells me this is likely gonna be pretty flaky and might lead
> > to unreliable configurations. The hardware manufacturer should be able
> > to determine the limits of the hardware and those should be put into DT
> > at manufacturing time IMO.
> 
> It is not a common method but we have been using it on many OpenPOWER
> platforms (P8) using the AST2400 (palmetto, habanero, firestone, 
> garrison, etc) and also on the newer P9 platforms using the AST2500
> (romulus, zaius, witherspoon). So I would say that experience 'proves' 
> that it works. We didn't invent the SPI Timing Calibration algo, it is
> described in the specs of the manufacturer.

 ... Partially ;-) I wrote the original pflash so I can take the blame
for that one but yes, it's proven actually more reliable than any
attempt at hard wiring the settings for a given board/chip combination.

> Also, all these platforms use sockets to hold the different flash 
> modules of the system. We don't know in advance what we will find 
> and so it makes difficult to put any timing in the DT.    

Correct. Plus random revisions changing the trace length etc... the
problem isn't so much the SPI frequency which can theorically be
derived from the detected chip, as long as we stay within reasonable
limits. There seem to be sub-cycle read delays that need to be inserted
for reads to be reliable. The controller allow to manipulate those
delays rather precisely but the "right" value is hard to guess and
depend on a given combination of system trace length, flash chip, flash
chip revision even etc...

The algorithm we use goes through several passes over ranges of timings
and delays and picks a "safe" middle ground, ie, picks a combination
that is good *and* have both adjacent combinations good.

It also makes sure that there's a good enough distribution of 0's and
1's in the flash.

If any of the above fails, it falls back to slow and safe timings.

I suggested to Cedric the stuff he proposed below, which is to make it
a manufacturer choice to use the auto calibration or not via the DT.

However ...

> And the values of the "data input delay cycle" (REG94) depend on the 
> chip model and on the length of the wires of the board. If we were to 
> hard-code such values in the DT, we would need to put only safe and slow 
> settings known to work in all configurations. which is a bit what we 
> do in the current driver using really slow ones.
> 
> Here is a proposal. We could activate this algo using a property such
> as :
>  
> 	"speed-mode" = "freq" or "auto-adjust"

You need more than just "freq".

At the moment we use a command freq which is somewhat safe and a
different read freq. There's also a write freq which could be different
based on the flash chip. It also depends on the command mode used (fast
read, dual IO, ...).

The problem is that you need to also provide a way to specify that gate
delay correction (REG94) in addition too. My original implementation in
pflash was forced to slow commands right down (which sucks for write
and erase) because it didn't apply that correction factor to the reads
of the status register and thus was getting occasional garbage there
which can be fatal.

So I would provide a way to specify the "normal+write+erase command"
and the "read command" timing separately, and not as a frequency but as
a precise set of divider and REG94 since the exact frequency obtained
from the divider rather than the "target" frequency is what matters.

> How's that ? 
> 
> Thanks,
> 
> C.

  reply	other threads:[~2017-04-11  8:46 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 16:56 [PATCH 00/10] mtd: spi-nor: aspeed: support extensions Cédric Le Goater
2017-04-06 16:56 ` [PATCH 01/10] mtd: spi-nor: aspeed: fix the AST2400 SMC window size Cédric Le Goater
2017-04-06 19:17   ` Marek Vasut
2017-04-11 10:18     ` Cédric Le Goater
2017-04-11 10:42       ` Marek Vasut
2017-04-11 16:10         ` Cédric Le Goater
2017-04-06 16:56 ` [PATCH 02/10] mtd: spi-nor: aspeed: remove dummies from keep mask Cédric Le Goater
2017-04-06 16:56 ` [PATCH 03/10] mtd: spi-nor: aspeed: add DMA support Cédric Le Goater
2017-04-06 19:07   ` Cyrille Pitchen
2017-04-06 19:13     ` Cyrille Pitchen
2017-04-19 14:36     ` Cédric Le Goater
2017-04-06 16:56 ` [PATCH 04/10] mtd: spi-nor: aspeed: add support for SPI dual IO read mode Cédric Le Goater
2017-04-06 19:21   ` Marek Vasut
2017-04-11  8:53     ` Cédric Le Goater
2017-04-11 10:43       ` Marek Vasut
2017-04-06 16:56 ` [PATCH 05/10] mtd: spi-nor: Add support for Macronix mx66l1g45g spi flash Cédric Le Goater
2017-04-06 19:21   ` Marek Vasut
2017-04-06 16:56 ` [PATCH 06/10] mtd: spi-nor: add SPI_NOR_DUAL_READ to some flash devices Cédric Le Goater
2017-04-06 19:22   ` Marek Vasut
2017-04-11  8:15     ` Cédric Le Goater
2017-04-06 16:56 ` [PATCH 07/10] mtd: spi-nor: aspeed: configure chip window on AHB bus Cédric Le Goater
2017-04-06 19:25   ` Marek Vasut
2017-04-11 10:20     ` Cédric Le Goater
2017-04-11 10:44       ` Marek Vasut
2017-04-06 16:56 ` [PATCH 08/10] mtd: spi-nor: aspeed: use command mode for reads Cédric Le Goater
2017-04-06 16:56 ` [PATCH 09/10] mtd: spi-nor: aspeed: link controller with the ahb clock Cédric Le Goater
2017-04-06 16:56 ` [PATCH 10/10] mtd: spi-nor: aspeed: optimize read mode Cédric Le Goater
2017-04-06 19:28   ` Marek Vasut
2017-04-11  8:13     ` Cédric Le Goater
2017-04-11  8:23       ` Benjamin Herrenschmidt [this message]
2017-04-14 16:18       ` Marek Vasut
2017-04-14 21:40         ` Benjamin Herrenschmidt
2017-04-14 21:51           ` Marek Vasut
2017-04-14 22:11             ` Benjamin Herrenschmidt
2017-04-14 22:25               ` Marek Vasut
2017-04-14 22:42                 ` Benjamin Herrenschmidt
2017-04-16 18:46                   ` Marek Vasut
2017-04-18 15:46                   ` Cédric Le Goater
2017-04-18 16:51                     ` Marek Vasut
2017-04-18 22:41                     ` Benjamin Herrenschmidt

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=1491899038.4166.236.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=clg@kaod.org \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dwmw2@infradead.org \
    --cc=joel@jms.id.au \
    --cc=linux-mtd@lists.infradead.org \
    --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