All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Frieder Schrempf <frieder.schrempf@exceet.de>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd@lists.infradead.org,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Peter Pan <peterpansjtu@gmail.com>, Vignesh R <vigneshr@ti.com>,
	Xiangsheng Hou <xiangsheng.hou@mediatek.com>,
	Peter Pan <peterpandong@micron.com>
Subject: Re: [PATCH v7 2/5] mtd: nand: Add core infrastructure to support SPI NANDs
Date: Tue, 29 May 2018 15:35:19 +0200	[thread overview]
Message-ID: <20180529153519.393741f8@bbrezillon> (raw)
In-Reply-To: <31e7dfaf-a083-e750-feb0-34f5ae930eb3@exceet.de>

On Tue, 29 May 2018 12:57:33 +0200
Frieder Schrempf <frieder.schrempf@exceet.de> wrote:

> > +static int spinand_init(struct spinand_device *spinand)
> > +{
> > +	struct device *dev = &spinand->spimem->spi->dev;
> > +	struct mtd_info *mtd = spinand_to_mtd(spinand);
> > +	struct nand_device *nand = mtd_to_nanddev(mtd);
> > +	int ret, i;
> > +
> > +	/*
> > +	 * We need a scratch buffer because the spi_mem interface requires that
> > +	 * buf passed in spi_mem_op->data.buf be DMA-able.
> > +	 */
> > +	spinand->scratchbuf = kzalloc(SPINAND_MAX_ID_LEN, GFP_KERNEL);
> > +	if (!spinand->scratchbuf)
> > +		return -ENOMEM;
> > +
> > +	ret = spinand_detect(spinand);
> > +	if (ret)
> > +		goto err_free_bufs;
> > +
> > +	/*
> > +	 * Use kzalloc() instead of devm_kzalloc() here, because some drivers
> > +	 * may use this buffer for DMA access.
> > +	 * Memory allocated by devm_ does not guarantee DMA-safe alignment.
> > +	 */
> > +	spinand->databuf = kzalloc(nanddev_page_size(nand) +
> > +			       nanddev_per_page_oobsize(nand),
> > +			       GFP_KERNEL);
> > +	if (!spinand->databuf)
> > +		goto err_free_bufs;
> > +
> > +	spinand->oobbuf = spinand->databuf + nanddev_page_size(nand);
> > +
> > +	ret = spinand_init_cfg_cache(spinand);  
> 
> If the SPINAND_HAS_QE_BIT bit is set, then spinand_init_quad_enable() 
> will try to use the config cache, but it hasn't been initialized at that 
> time.

Oops, you're right. I wonder how I could miss that one when testing it.
I guess you get a NULL pointer exception, right?

> 
> So spinand_init_cfg_cache() should probably be called earlier, before 
> spinand_detect().

I'd prefer to move the spinand_init_quad_enable() just after the
spinand_init_cfg_cache() one. Calling spinand_init_cfg_cache() does not
work because we don't know how many dies we have and the cfg cache has
one entry per die.

  reply	other threads:[~2018-05-29 13:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 15:08 [PATCH v7 0/5] mtd: Add a SPI NAND driver Boris Brezillon
2018-05-15 15:08 ` [PATCH v7 1/5] mtd: nand: Pass mode information to nand_page_io_req Boris Brezillon
2018-06-01 10:11   ` Miquel Raynal
2018-06-01 10:17   ` Frieder Schrempf
2018-06-01 12:55   ` Boris Brezillon
2018-05-15 15:08 ` [PATCH v7 2/5] mtd: nand: Add core infrastructure to support SPI NANDs Boris Brezillon
2018-05-29 10:57   ` Frieder Schrempf
2018-05-29 13:35     ` Boris Brezillon [this message]
2018-05-29 14:59       ` Frieder Schrempf
2018-06-01 10:22         ` Frieder Schrempf
2018-05-31  7:30   ` Miquel Raynal
2018-05-31  7:38     ` Boris Brezillon
2018-05-15 15:08 ` [PATCH v7 3/5] dt-bindings: Add bindings for SPI NAND devices Boris Brezillon
2018-05-15 15:08 ` [PATCH v7 4/5] mtd: nand: spi: Add initial support for Micron MT29F2G01ABAGD Boris Brezillon
2018-05-15 15:08 ` [PATCH v7 5/5] mtd: nand: spi: Add initial support for Winbond W25M02GV Boris Brezillon
2018-05-15 22:59   ` Miquel Raynal
2018-05-16  7:07     ` Boris Brezillon
2018-05-17  6:33 ` [PATCH v7 0/5] mtd: Add a SPI NAND driver Prabhakar Kushwaha
2018-05-17  7:05   ` Boris Brezillon
2018-05-17 10:01     ` Prabhakar Kushwaha
2018-05-17 10:22       ` Frieder Schrempf

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=20180529153519.393741f8@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=frieder.schrempf@exceet.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=peterpandong@micron.com \
    --cc=peterpansjtu@gmail.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    --cc=xiangsheng.hou@mediatek.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.