All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: "Gupta, Pekon" <pekon@ti.com>
Cc: Huang Shijie <b32955@freescale.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"dedekind1@gmail.com" <dedekind1@gmail.com>
Subject: Re: [PATCH 01/10] mtd: set the cell information for ONFI nand
Date: Mon, 12 Aug 2013 17:49:38 -0700	[thread overview]
Message-ID: <20130813004938.GD7267@brian-ubuntu> (raw)
In-Reply-To: <20980858CB6D3A4BAE95CA194937D5E73E9F2A6B@DBDE04.ent.ti.com>

On Mon, Aug 12, 2013 at 07:22:38AM +0000, Gupta, Pekon wrote:
> > The current code does not set the SLC/MLC information for onfi nand.
> > (This makes that the kernel treats all the onfi nand as SLC nand.)
> > 
> > This patch fills the chip->cellinfo when the onfi nand is a MLC(or TLC) nand
> > (p->bits_per_cell > 1).
> > 
> > The macro NAND_CI_CELLTYPE_SHIFT is added to avoid the hardcode.
> > 
> > Signed-off-by: Huang Shijie <b32955@freescale.com>
> > ---
> >  drivers/mtd/nand/nand_base.c |    3 +++
> >  include/linux/mtd/nand.h     |    1 +
> >  2 files changed, 4 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > index ff605c8..ee1aa52 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -2988,6 +2988,9 @@ static int nand_flash_detect_onfi(struct mtd_info
> > *mtd, struct nand_chip *chip,
> >  	chip->chipsize = le32_to_cpu(p->blocks_per_lun);
> >  	chip->chipsize *= (uint64_t)mtd->erasesize * p->lun_count;
> > 
> > +	/* @bits_per_cell equals 1 means this is a SLC nand. */
> > +	chip->cellinfo = (p->bits_per_cell - 1) << NAND_CI_CELLTYPE_SHIFT;
> > +
> [Pekon]: For future scalability, good to update only MLC related bit-fields
> So ORing instead of assigning..
> chip->cellinfo |= (p->bits_per_cell - 1) << NAND_CI_CELLTYPE_SHIFT;

I was thinking of an alternate approach: since nand_chip.cellinfo is
only used for checking SLC vs. MLC (and it is admittedly bad at that,
currently), we should modify it so that is a reliable source of *only* 1
piece of information -- the number of bits per cell. Currently, it
contains unused (and potentially unmaintainable) information for some
chips about number of simultaneously-programmed pages, write caching,
internal chip numbering, etc.

So personally, I would rename cellinfo to bits_per_cell and make sure
it is set properly. That is, for the legacy chips, make sure we
initialize it 1 (SLC); for extended-ID chips, make sure the third ID
byte has the correct info (you can refer to [1]) and set it with
something like this:

  chip->bits_per_cell = id_data[2] & NAND_CI_CELLTYPE_MSK
  chip->bits_per_cell >>= NAND_CI_CELLTYPE_SHIFT;
  chip->bits_per_cell += 1;

for chips listed by full-ID, add an appropriate flag/field; and for ONFI
chips, just use p->bits_per_cell.

If you really need the other cellinfo fields in the future, we can add
more fields to nand_chip.

> 
> >  	if (onfi_feature(chip) & ONFI_FEATURE_16_BIT_BUS)
> >  		*busw = NAND_BUSWIDTH_16;
> >  	else

Thanks,
Brian

[1] An incomplete NAND ID table:

  http://www.linux-mtd.infradead.org/nand-data/nanddata.html

  parent reply	other threads:[~2013-08-13  0:50 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-12  5:42 [PATCH 00/10] About the SLC/MLC Huang Shijie
2013-08-12  5:42 ` [PATCH 01/10] mtd: set the cell information for ONFI nand Huang Shijie
2013-08-12  7:22   ` Gupta, Pekon
2013-08-12  7:27     ` Huang Shijie
2013-08-13  0:49     ` Brian Norris [this message]
2013-08-13  2:32       ` Huang Shijie
2013-08-13  2:59         ` Brian Norris
     [not found]       ` <5209A1F2.80600@freescale.com>
2013-08-13  3:17         ` Brian Norris
2013-08-13  3:21           ` Huang Shijie
2013-08-13  4:10           ` Gupta, Pekon
2013-08-13  6:19             ` Huang Shijie
2013-08-12  5:42 ` [PATCH 02/10] mtd: add a helper to check the SLC/MLC nand chip Huang Shijie
2013-08-13  0:52   ` Brian Norris
2013-08-13  2:35     ` Huang Shijie
2013-08-13  2:52       ` Brian Norris
2013-08-12  5:42 ` [PATCH 03/10] mtd: print out the cell information for " Huang Shijie
2013-08-12  5:42 ` [PATCH 04/10] mtd: gpmi: rewrite the gpmi_ecc_write_oob() to support the jffs2 Huang Shijie
2013-08-12  5:42 ` [PATCH 05/10] mtd: add more comment for MTD_NANDFLASH/MTD_MLCNANDFLASH Huang Shijie
2013-08-12  5:42 ` [PATCH 06/10] mtd: fix the wrong mtd->type for nand chip Huang Shijie
2013-08-12  5:42 ` [PATCH 07/10] jffs2: init the ret with -EINVAL Huang Shijie
2013-08-12  5:42 ` [PATCH 08/10] mtd: add MTD_MLCNANDFLASH case for mtd_type_show() Huang Shijie
2013-08-13  1:05   ` Brian Norris
2013-08-13  2:20     ` Huang Shijie
2013-08-13  3:10       ` Brian Norris
2013-08-13  3:18         ` Huang Shijie
2013-08-12  5:42 ` [PATCH 09/10] mtd: add more information for the MTD_NANDFLASH case Huang Shijie
2013-08-13  1:07   ` Brian Norris
2013-08-12  5:42 ` [PATCH 10/10] mtd: add a helper to detect the nand type Huang Shijie

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=20130813004938.GD7267@brian-ubuntu \
    --to=computersforpeace@gmail.com \
    --cc=b32955@freescale.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=pekon@ti.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.