All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Stefan Agner <stefan@agner.ch>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>,
	dwmw2@infradead.org, computersforpeace@gmail.com,
	marek.vasut@gmail.com, robh+dt@kernel.org, mark.rutland@arm.com,
	thierry.reding@gmail.com, mturquette@baylibre.com,
	sboyd@kernel.org, dev@lynxeye.de, richard@nod.at,
	marcel@ziswiler.com, krzk@kernel.org, digetx@gmail.com,
	benjamin.lindqvist@endian.se, jonathanh@nvidia.com,
	pdeschrijver@nvidia.com, pgaikwad@nvidia.com,
	mirza.krak@gmail.com, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH 2/5] mtd: rawnand: add NVIDIA Tegra NAND Flash controller driver
Date: Sun, 27 May 2018 16:06:48 +0200	[thread overview]
Message-ID: <20180527160648.0f368563@xps13> (raw)
In-Reply-To: <78b7b43b4284e73cd6a3255e4e5075ed@agner.ch>

Hi Stefan,

On Fri, 25 May 2018 00:56:23 +0200, Stefan Agner <stefan@agner.ch>
wrote:

> On 24.05.2018 14:41, Boris Brezillon wrote:
> > On Thu, 24 May 2018 14:23:56 +0200
> > Boris Brezillon <boris.brezillon@bootlin.com> wrote:
> >   
> >> On Thu, 24 May 2018 13:09:53 +0200
> >> Stefan Agner <stefan@agner.ch> wrote:
> >>  
> >> > On 24.05.2018 10:56, Boris Brezillon wrote:  
> >> > > On Thu, 24 May 2018 10:46:27 +0200
> >> > > Stefan Agner <stefan@agner.ch> wrote:
> >> > >  
> >> > >> Hi Boris,
> >> > >>
> >> > >> Thanks for the initial review! One small question below:
> >> > >>
> >> > >> On 23.05.2018 16:18, Boris Brezillon wrote:  
> >> > >> > Hi Stefan,
> >> > >> >
> >> > >> > On Tue, 22 May 2018 14:07:06 +0200
> >> > >> > Stefan Agner <stefan@agner.ch> wrote:  
> >> > >> >> +
> >> > >> >> +struct tegra_nand {
> >> > >> >> +	void __iomem *regs;
> >> > >> >> +	struct clk *clk;
> >> > >> >> +	struct gpio_desc *wp_gpio;
> >> > >> >> +
> >> > >> >> +	struct nand_chip chip;
> >> > >> >> +	struct device *dev;
> >> > >> >> +
> >> > >> >> +	struct completion command_complete;
> >> > >> >> +	struct completion dma_complete;
> >> > >> >> +	bool last_read_error;
> >> > >> >> +
> >> > >> >> +	dma_addr_t data_dma;
> >> > >> >> +	void *data_buf;
> >> > >> >> +	dma_addr_t oob_dma;
> >> > >> >> +	void *oob_buf;
> >> > >> >> +
> >> > >> >> +	int cur_chip;
> >> > >> >> +};  
> >> > >> >
> >> > >> > This struct should be split in 2 structures: one representing the NAND
> >> > >> > controller and one representing the NAND chip:
> >> > >> >
> >> > >> > struct tegra_nand_controller {
> >> > >> > 	struct nand_hw_control base;
> >> > >> > 	void __iomem *regs;
> >> > >> > 	struct clk *clk;
> >> > >> > 	struct device *dev;
> >> > >> > 	struct completion command_complete;
> >> > >> > 	struct completion dma_complete;
> >> > >> > 	bool last_read_error;
> >> > >> > 	int cur_chip;
> >> > >> > };
> >> > >> >
> >> > >> > struct tegra_nand {
> >> > >> > 	struct nand_chip base;
> >> > >> > 	dma_addr_t data_dma;
> >> > >> > 	void *data_buf;
> >> > >> > 	dma_addr_t oob_dma;
> >> > >> > 	void *oob_buf;
> >> > >> > };  
> >> > >>
> >> > >> Is there a particular reason why you would leave DMA buffers in the chip
> >> > >> structure? It seems that is more a controller thing...  
> >> > >
> >> > > The size of those buffers is likely to be device dependent, so if you
> >> > > have several NANDs connected to the controller, you'll either have to
> >> > > have one buffer at the controller level which is max(all-chip-buf-size)
> >> > > or a buffer per device.
> >> > >
> >> > > Also, do you really need these buffers? The core already provide some
> >> > > which are suitable for DMA (chip->oob_poi and chip->data_buf).
> >> > >  
> >> >
> >> > Good question, I am not sure, that was existing code.
> >> >
> >> > Are you sure data_buf it is DMA capable?
> >> >
> >> > nand_scan_tail allocates with kmalloc:
> >> >
> >> > chip->data_buf = kmalloc(mtd->writesize + mtd->oobsize, GFP_KERNEL);  
> >>
> >> Yes, kmalloc() allocates DMA-able buffers, so those are DMA-safe.  
> > 
> > Hm, that's not exactly true. It depends on the dma_mask attached to the
> > device.  
> 
> It seems to work (tm).
> 
> I am not sure how to deal with the OOB buffer. I now use the given
> pointer also for oob (offset writesize). I think mtk_nand does the same
> thing.
> 
> dma_len = mtd->writesize + (oob_required ? mtd->oobsize : 0);        
> dma_addr = dma_map_single(ctrl->dev, buf, dma_len, DMA_FROM_DEVICE);
> 
> ...
> 
> Is there a test which allows to test my (read|write)_page implementation
> with oob_required set?

I don't think there is a test in mtd-utils that does train both
implementations with oob_required set, but you should be able to test
it manually with nanddump/nandwrite --oob.

Thanks,
Miquèl

  reply	other threads:[~2018-05-27 14:06 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 12:07 [RESEND PATCH 0/5] mtd: rawnand: add NVIDIA Tegra NAND flash support Stefan Agner
2018-05-22 12:07 ` [RESEND PATCH 1/5] mtd: rawnand: tegra: add devicetree binding Stefan Agner
2018-05-22 17:52   ` Boris Brezillon
2018-05-22 12:07 ` [RESEND PATCH 2/5] mtd: rawnand: add NVIDIA Tegra NAND Flash controller driver Stefan Agner
2018-05-22 12:16   ` Dmitry Osipenko
2018-05-22 12:19   ` Stefan Agner
2018-05-22 13:34     ` Dmitry Osipenko
2018-05-22 14:28       ` Stefan Agner
2018-05-22 14:53   ` Stefan Agner
2018-05-22 17:55     ` Boris Brezillon
2018-05-23 14:18   ` Boris Brezillon
2018-05-24  8:46     ` Stefan Agner
2018-05-24  8:56       ` Boris Brezillon
2018-05-24 11:09         ` Stefan Agner
2018-05-24 12:23           ` Boris Brezillon
2018-05-24 12:41             ` Boris Brezillon
2018-05-24 22:56               ` Stefan Agner
2018-05-27 14:06                 ` Miquel Raynal [this message]
2018-05-24 12:27           ` Boris Brezillon
2018-05-24  7:40   ` Benjamin Lindqvist
2018-05-24  7:45   ` Benjamin Lindqvist
2018-05-24 11:00     ` Stefan Agner
2018-05-24 11:07       ` Boris Brezillon
2018-05-24 11:30       ` Benjamin Lindqvist
2018-05-24 11:53         ` Boris Brezillon
2018-05-24 12:19           ` Stefan Agner
2018-05-27 14:18             ` Miquel Raynal
2018-05-27 15:13               ` Boris Brezillon
2018-05-27 15:54                 ` Miquel Raynal
2018-05-27 16:30                   ` Boris Brezillon
2018-05-27 19:08                     ` Stefan Agner
2018-05-27 22:04   ` Miquel Raynal
2018-05-27 22:04     ` Miquel Raynal
2018-05-28 12:39     ` Stefan Agner
2018-05-31 17:54     ` Stefan Agner
2018-05-31 20:30       ` Boris Brezillon
2018-05-31 21:44         ` Stefan Agner
2018-05-22 12:07 ` [RESEND PATCH 3/5] clk: tegra20: init NDFLASH clock to sensible rate Stefan Agner
2018-05-22 12:07 ` [RESEND PATCH 4/5] ARM: tegra: add Tegra20 NAND flash controller node Stefan Agner
2018-05-22 12:07 ` [RESEND PATCH 5/5] ARM: tegra: enable NAND flash on Colibri T20 Stefan Agner

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=20180527160648.0f368563@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=benjamin.lindqvist@endian.se \
    --cc=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=dev@lynxeye.de \
    --cc=digetx@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marcel@ziswiler.com \
    --cc=marek.vasut@gmail.com \
    --cc=mark.rutland@arm.com \
    --cc=mirza.krak@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=pdeschrijver@nvidia.com \
    --cc=pgaikwad@nvidia.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=stefan@agner.ch \
    --cc=thierry.reding@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.