linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@collabora.com>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Boris Brezillon <bbrezillon@kernel.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	Rickard X Andersson <Rickard.Andersson@axis.com>
Subject: Re: [PATCH 2/2] mtd: rawnand: Add timings for Kioxia TH58NVG2S3HBAI4
Date: Wed, 20 May 2020 17:26:52 +0200	[thread overview]
Message-ID: <20200520172652.051b9d90@collabora.com> (raw)
In-Reply-To: <20200520171246.538823eb@xps13>

On Wed, 20 May 2020 17:12:46 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Hi Boris,
> 
> Boris Brezillon <boris.brezillon@collabora.com> wrote on Wed, 20 May
> 2020 16:50:22 +0200:
> 
> > On Wed, 20 May 2020 14:42:31 +0000
> > Rickard X Andersson <Rickard.Andersson@axis.com> wrote:
> >   
> > > > > If I understand you correctly you want me to use onfi_find_equivalent_sdr_mode in order to find the corresponding onfi mode. Then you want me to use onfi_fill_data_interface and loop towards mode 0 checking which mode the controller accepts? I just thought it was a "messy" to duplicate this code in all vendor drivers.
> > > > > Or do you mean that I should just use onfi_find_equivalent_sdr_mode to set ."timings.mode" and let nand_base to do the looping in case error is returned from th58nvg2s3hbai4_choose_data_interface (i.e specialized timings not accepted by the controller).      
> > > >
> > > > Sorry for the misunderstanding. What I think you should try is:
> > > > 1/ call onfi_find_equivalent_sdr_mode() to set the timings.mode field.
> > > > 2/ call nand_controller_supports_data_interface()
> > > > 3/ if the controller supports the timings, set
> > > > chip->default_timing_mode accordingly and return 0.    
> > 
> > Why do we have to set the default_timing_mode field? Can't we just set
> > timings.mode directly?
> >   
> > > > 4/ if the controller does not support the timings, you may want to
> > > > propose other standard timings to test by setting
> > > > chip->default_timing_mode anyway but returning an error which means
> > > > "best interface has not been found yet" so the rest of the
> > > > choose_data_interface() helper will try the remaining ONFI modes
> > > > automatically (fallbacks to 0 anyway).    
> > 
> > Again, I don't see why setting chip->default_timing_mode is needed here,
> > and I'm not sure trying remaining ONFI modes is useful, I guess we can
> > just fall back on mode 0 in that case.  
> 
> It is needed because of the logic in nand_reset() which does not apply
> the data interface after a reset if this field is null.

We should probably replace that check by a memcmp():

	if (!memcmp(&chip->data_interface, saved_data_intf,
		    sizeof(saved_data_intf)))
		return 0;

And maybe we should allocate this struct instead of copying things
around (have a "default/reset timings" object that's shared by all
drivers and matches timing mode 0, and a "best timing" object that's
allocated at init time).

> 
> Otherwise I also wondered if falling back to regular ONFI mode was
> useful. If this is not, we can just return after the call to
> chip->ops.choose_data_interface().

Or maybe we could expose this logic as a helper:

static int
nand_choose_best_sdr_timings(struct nand_chip *,
			     struct nand_sdr_timings *best_timings)
{
	/*
	 * 1/ pick the closest mode and assign best_timings->mode
	 *    using onfi_find_equivalent_sdr_mode()
	 * 2/ call controller->setup_data_interface(check_only, best_timings);
	 * 3/ pick timings of best_timings->mode - 1 if it fails and go back to
	 *    #2, return 0 otherwise.
	 */
}

This way the driver doesn't have to duplicate the logic, it only has
to fill the best_timings struct accordingly, and the core can simply
do:

	if (chip->ops.choose_data_interface)
		return chip->ops.choose_data_interface();

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2020-05-20 15:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 13:32 SV: [PATCH 2/2] mtd: rawnand: Add timings for Kioxia TH58NVG2S3HBAI4 Rickard X Andersson
2020-05-20 13:43 ` Miquel Raynal
2020-05-20 14:16   ` SV: " Rickard X Andersson
2020-05-20 14:29     ` Miquel Raynal
2020-05-20 14:42       ` SV: " Rickard X Andersson
2020-05-20 14:50         ` Boris Brezillon
2020-05-20 15:12           ` Miquel Raynal
2020-05-20 15:26             ` Boris Brezillon [this message]
2020-05-20 20:43               ` Miquel Raynal
2020-05-20 20:57                 ` Boris Brezillon
     [not found] <richard@nod.at;>
2020-05-14  9:13 ` [PATCH 1/2] mtd: rawnand: Use the ->init_data_interface() hook Rickard Andersson
2020-05-14  9:13   ` [PATCH 2/2] mtd: rawnand: Add timings for Kioxia TH58NVG2S3HBAI4 Rickard Andersson
2020-05-19 12:08     ` Miquel Raynal

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=20200520172652.051b9d90@collabora.com \
    --to=boris.brezillon@collabora.com \
    --cc=Rickard.Andersson@axis.com \
    --cc=bbrezillon@kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.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;
as well as URLs for NNTP newsgroup(s).