Re: [PATCH 2/2] mtd: rawnand: Add timings for Kioxia TH58NVG2S3HBAI4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Boris,

Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote on Wed, 20 May
2020 17:26:52 +0200:

> On Wed, 20 May 2020 17:12:46 +0200
> Miquel Raynal <miquel.raynal@xxxxxxxxxxx> wrote:
> 
> > Hi Boris,
> > 
> > Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> wrote on Wed, 20 May
> > 2020 16:50:22 +0200:
> >   
> > > On Wed, 20 May 2020 14:42:31 +0000
> > > Rickard X Andersson <Rickard.Andersson@xxxxxxxx> 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).

Indeed, checking if a pointer has been set is much less expensive than
a memcmp I suppose. I'll try to come up with something.

> 
> > 
> > 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();

Well, that's very close to what I just proposed, no? The
difference being that I was reusing the existing code (and
already adapted it to DDR modes BTW) because "picking timings of
best_timings->mode - 1 if it fails and go back to #2" is precisely what
nand_choose_data_interface() does.

Let me propose something with the above changes.


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



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux