public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Cc: bpqw@micron.com, Ionela Voinescu <ionela.voinescu@imgtec.com>,
	frankliu@micron.com, Andrew Bresticker <abrestic@chromium.org>,
	linux-mtd@lists.infradead.org, arnaud.mouiche@invoxia.com,
	Huang Shijie <shijie8@gmail.com>,
	James Hartley <james.hartley@imgtec.com>
Subject: Re: [PATCH 1/6] mtd: nand: Check length of ID before reading bits per cell
Date: Mon, 5 Jan 2015 12:38:08 -0800	[thread overview]
Message-ID: <20150105203808.GE9759@ld-irv-0074> (raw)
In-Reply-To: <1417525136-25731-2-git-send-email-ezequiel.garcia@imgtec.com>

A little tangential to the big-picture discussion, but I'll get this out
there:

On Tue, Dec 02, 2014 at 09:58:51AM -0300, Ezequiel Garcia wrote:
> The table-based NAND identification currently reads the number
> of bits per cell from the 3rd byte of the extended ID. This is done
> for the so-called 'full ID' devices; i.e. devices that have a known
> length ID.
> 
> However, if the ID length is shorter than three, there's no 3rd byte,
> and so it's wrong to read the bits per cell from there. Fix this by
> adding a check for the ID length.

You're right about the problem, but I'm not sure about the fix. I
actually don't know why we are using the ID bytes to guess at the number
of bits per cell here; the point of the full-id checks is that with some
NAND, we just can't decode all the information reliably from the ID.

I'd kinda rather just see bits-per-cell represented as a separate bit;
either a new field, or in the 'options' field.

> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
> ---
>  drivers/mtd/nand/nand_base.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 5b5c627..a4c9cee 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3589,7 +3589,8 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
>  		mtd->erasesize = type->erasesize;
>  		mtd->oobsize = type->oobsize;
>  
> -		chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]);
> +		if (type->id_len > 2)
> +			chip->bits_per_cell = nand_get_bits_per_cell(id_data[2]);
>  		chip->chipsize = (uint64_t)type->chipsize << 20;
>  		chip->options |= type->options;
>  		chip->ecc_strength_ds = NAND_ECC_STRENGTH(type);

Brian

  parent reply	other threads:[~2015-01-05 20:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 12:58 [PATCH 0/6] SPI NAND for everyone Ezequiel Garcia
2014-12-02 12:58 ` [PATCH 1/6] mtd: nand: Check length of ID before reading bits per cell Ezequiel Garcia
2014-12-13  0:51   ` Daniel Ehrenberg
2015-01-05 20:38   ` Brian Norris [this message]
2014-12-02 12:58 ` [PATCH 2/6] mtd: nand: Add JEDEC manufacturer ID for Gigadevice Ezequiel Garcia
2014-12-13  0:49   ` Daniel Ehrenberg
2015-04-21 23:04     ` Ezequiel Garcia
2015-04-22 17:47       ` Brian Norris
2014-12-02 12:58 ` [PATCH 3/6] mtd: nand: Allow to set a per-device ECC layout Ezequiel Garcia
2014-12-13  0:34   ` Daniel Ehrenberg
2014-12-02 12:58 ` [PATCH 4/6] mtd: Introduce SPI NAND framework Ezequiel Garcia
2014-12-15 21:18   ` Daniel Ehrenberg
2014-12-16  0:08     ` Ezequiel Garcia
     [not found]   ` <87F60714EC601C4C83DFF1D2E3D390A049EE77@NTXXIAMBX02.xacn.micron.com>
2014-12-22  4:34     ` Qi Wang 王起 (qiwang)
2014-12-22 15:44       ` Ezequiel Garcia
2015-01-05 20:47         ` Brian Norris
2014-12-02 12:58 ` [PATCH 5/6] mtd: spi-nand: Add devicetree binding Ezequiel Garcia
2014-12-13  1:27   ` Daniel Ehrenberg
2014-12-02 12:58 ` [PATCH 6/6] mtd: spi-nand: Support common SPI NAND devices Ezequiel Garcia
2014-12-13  1:27   ` Daniel Ehrenberg
2014-12-15 19:36     ` Ezequiel Garcia
2014-12-15 20:17       ` Daniel Ehrenberg
     [not found]   ` <87F60714EC601C4C83DFF1D2E3D390A049EE65@NTXXIAMBX02.xacn.micron.com>
2014-12-22  4:34     ` Qi Wang 王起 (qiwang)
2014-12-22 16:16       ` Ezequiel Garcia
2014-12-10 17:41 ` [PATCH 0/6] SPI NAND for everyone Ezequiel Garcia
2015-01-06  3:30 ` Brian Norris
2015-01-06 21:03   ` Ezequiel Garcia
2015-01-07  0:55     ` Qi Wang 王起 (qiwang)
2015-01-07 12:13       ` Ezequiel Garcia

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=20150105203808.GE9759@ld-irv-0074 \
    --to=computersforpeace@gmail.com \
    --cc=abrestic@chromium.org \
    --cc=arnaud.mouiche@invoxia.com \
    --cc=bpqw@micron.com \
    --cc=ezequiel.garcia@imgtec.com \
    --cc=frankliu@micron.com \
    --cc=ionela.voinescu@imgtec.com \
    --cc=james.hartley@imgtec.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=shijie8@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox