linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Schrempf Frieder <frieder.schrempf@kontron.de>
Cc: Mason Yang <masonccyang@mxic.com.tw>, Vignesh R <vigneshr@ti.com>,
	Tudor Ambarus <Tudor.Ambarus@microchip.com>,
	Julien Su <juliensu@mxic.com.tw>,
	Richard Weinberger <richard@nod.at>,
	Boris Brezillon <bbrezillon@kernel.org>,
	Marek Vasut <marek.vasut@gmail.com>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 07/15] mtd: rawnand: Fill memorg during detection
Date: Tue, 26 Feb 2019 14:09:03 +0100	[thread overview]
Message-ID: <20190226140903.7d0f3916@xps13> (raw)
In-Reply-To: <2442d400-d50d-bbe9-4275-cce2241f6609@kontron.de>

Hi Frieder,

Schrempf Frieder <frieder.schrempf@kontron.de> wrote on Sat, 23 Feb
2019 13:00:14 +0000:

> On 21.02.19 10:15, Miquel Raynal wrote:
> > From: Boris Brezillon <bbrezillon@kernel.org>
> > 
> > If we want to use the generic NAND layer, we need to have the memorg
> > struct appropriately filled. Patch the detection code to fill this
> > struct.
> > 
> > Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> >   drivers/mtd/nand/raw/denali.c       |  5 +++
> >   drivers/mtd/nand/raw/diskonchip.c   |  4 ++
> >   drivers/mtd/nand/raw/jz4740_nand.c  |  4 ++
> >   drivers/mtd/nand/raw/nand_amd.c     | 11 ++++--
> >   drivers/mtd/nand/raw/nand_base.c    | 60 ++++++++++++++++++++++++++---
> >   drivers/mtd/nand/raw/nand_hynix.c   | 48 +++++++++++++++--------
> >   drivers/mtd/nand/raw/nand_jedec.c   | 22 ++++++++---
> >   drivers/mtd/nand/raw/nand_onfi.c    | 23 ++++++++---
> >   drivers/mtd/nand/raw/nand_samsung.c | 24 ++++++++----
> >   drivers/mtd/nand/raw/nand_toshiba.c |  9 ++++-
> >   drivers/mtd/nand/raw/nandsim.c      |  6 +++
> >   11 files changed, 172 insertions(+), 44 deletions(-)
> >   
> [...]
> > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> > index d3092c9a3e21..cb03877c775c 100644
> > --- a/drivers/mtd/nand/raw/nand_base.c
> > +++ b/drivers/mtd/nand/raw/nand_base.c
> > @@ -4530,21 +4530,30 @@ static int nand_get_bits_per_cell(u8 cellinfo)
> >    */
> >   void nand_decode_ext_id(struct nand_chip *chip)
> >   {
> > +	struct nand_memory_organization *memorg;
> >   	struct mtd_info *mtd = nand_to_mtd(chip);
> >   	int extid;
> >   	u8 *id_data = chip->id.data;
> > +
> > +	memorg = nanddev_get_memorg(&chip->base);
> > +
> >   	/* The 3rd id byte holds MLC / multichip data */
> > +	memorg->bits_per_cell = nand_get_bits_per_cell(id_data[2]);
> >   	chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]);
> >   	/* The 4th id byte is the important one */
> >   	extid = id_data[3];
> >   
> >   	/* Calc pagesize */
> > -	mtd->writesize = 1024 << (extid & 0x03);
> > +	memorg->pagesize = 1024 << (extid & 0x03);
> > +	mtd->writesize = memorg->pagesize;
> >   	extid >>= 2;
> >   	/* Calc oobsize */
> > -	mtd->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
> > +	memorg->oobsize = (8 << (extid & 0x01)) * (mtd->writesize >> 9);
> > +	mtd->oobsize = memorg->oobsize;
> >   	extid >>= 2;
> >   	/* Calc blocksize. Blocksize is multiples of 64KiB */
> > +	memorg->pages_per_eraseblock = ((64 * 1024) << (extid & 0x03)) /
> > +				       memorg->pagesize;
> >   	mtd->erasesize = (64 * 1024) << (extid & 0x03);
> >   	extid >>= 2;
> >   	/* Get buswidth information */
> > @@ -4561,12 +4570,19 @@ EXPORT_SYMBOL_GPL(nand_decode_ext_id);
> >   static void nand_decode_id(struct nand_chip *chip, struct nand_flash_dev *type)
> >   {
> >   	struct mtd_info *mtd = nand_to_mtd(chip);
> > +	struct nand_memory_organization *memorg;
> >   
> > +	memorg = nanddev_get_memorg(&chip->base);
> > +
> > +	memorg->pages_per_eraseblock = type->erasesize / type->pagesize;
> >   	mtd->erasesize = type->erasesize;
> > -	mtd->writesize = type->pagesize;
> > -	mtd->oobsize = mtd->writesize / 32;
> > +	memorg->pagesize = type->pagesize;
> > +	mtd->writesize = memorg->pagesize;
> > +	memorg->oobsize = memorg->pagesize / 32;
> > +	mtd->oobsize = memorg->oobsize;
> >   
> >   	/* All legacy ID NAND are small-page, SLC */
> > +	memorg->bits_per_cell = 1;
> >   	chip->bits_per_cell = 1;
> >   }
> >   
> > @@ -4595,13 +4611,21 @@ static bool find_full_id_nand(struct nand_chip *chip,
> >   			      struct nand_flash_dev *type)
> >   {
> >   	struct mtd_info *mtd = nand_to_mtd(chip);
> > +	struct nand_memory_organization *memorg;
> >   	u8 *id_data = chip->id.data;
> >   
> > +	memorg = nanddev_get_memorg(&chip->base);
> > +
> >   	if (!strncmp(type->id, id_data, type->id_len)) {
> > -		mtd->writesize = type->pagesize;
> > +		memorg->pagesize = type->pagesize;
> > +		mtd->writesize = memorg->pagesize;
> > +		memorg->pages_per_eraseblock = type->erasesize /
> > +					       type->erasesize;  
> 
> This should be:
> 		memorg->pages_per_eraseblock = type->erasesize /
> 					       type->pagesize;

Good catch!

I will correct that, and also clean the mixed declarations between
patch 7 and patch 13 you spotted.

Thanks,
Miquèl

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-02-26 13:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21  9:15 [PATCH 00/15] mtd: rawnand: 5th batch of cleanups Miquel Raynal
2019-02-21  9:15 ` [PATCH 01/15] mtd: nand: Add max_bad_eraseblocks_per_lun info to memorg Miquel Raynal
2019-02-23 13:03   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 02/15] mtd: nand: Add an helper returning the number of eraseblocks per target Miquel Raynal
2019-02-23 13:04   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 03/15] mtd: nand: Add an helper to retrieve the number of pages " Miquel Raynal
2019-02-23 13:04   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 04/15] mtd: spinand: Implement mtd->_max_bad_blocks Miquel Raynal
2019-02-23 13:05   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 05/15] mtd: rawnand: Use nand_to_mtd() in nand_{set, get}_flash_node() Miquel Raynal
2019-02-23 13:05   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 06/15] mtd: rawnand: Prepare things to reuse the generic NAND layer Miquel Raynal
2019-02-23 13:06   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 07/15] mtd: rawnand: Fill memorg during detection Miquel Raynal
2019-02-23 13:00   ` Schrempf Frieder
2019-02-26 13:09     ` Miquel Raynal [this message]
2019-02-21  9:15 ` [PATCH 08/15] mtd: rawnand: Initialize the nand_device object Miquel Raynal
2019-02-23 13:20   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 09/15] mtd: rawnand: Provide an helper to get chip->data_buf Miquel Raynal
2019-02-23 13:13   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 10/15] mtd: rawnand: Move all page cache related fields to a sub-struct Miquel Raynal
2019-02-23 13:13   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 11/15] mtd: rawnand: Use nanddev_mtd_max_bad_blocks() Miquel Raynal
2019-02-23 13:14   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 12/15] mtd: rawnand: Get rid of chip->bits_per_cell Miquel Raynal
2019-02-23 13:14   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 13/15] mtd: rawnand: Get rid of chip->chipsize Miquel Raynal
2019-02-23 13:01   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 14/15] mtd: rawnand: Get rid of chip->numchips Miquel Raynal
2019-02-23 13:15   ` Schrempf Frieder
2019-02-21  9:15 ` [PATCH 15/15] mtd: rawnand: Get rid of chip->ecc_{strength,step}_ds Miquel Raynal
2019-02-23 13:15   ` Schrempf Frieder

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=20190226140903.7d0f3916@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=bbrezillon@kernel.org \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=frieder.schrempf@kontron.de \
    --cc=juliensu@mxic.com.tw \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=masonccyang@mxic.com.tw \
    --cc=richard@nod.at \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=vigneshr@ti.com \
    --cc=yamada.masahiro@socionext.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).