Re: Resend: NAND 16bit ONFI problem

Alexander Shiyan shc_work at mail.ru
Thu Jul 18 03:42:55 EDT 2013


> Adding Matthieu, since he introduced NAND_BUSWIDTH. Leaving full context intact.
> 
> On Wed, Jul 10, 2013 at 1:39 AM, Alexander Shiyan <shc_work at mail.ru> wrote:
> > Hello.
> >
> > Updated: Same effect for 3.10 kernel.
> >
> > --------
> >
> > I have a problem with attach NAND UBI in 16 bit mode.
> > NAND works fine if I specify NAND_BUSWIDTH_16 option, but not
> > working with NAND_BUSWIDTH_AUTO option. In second case NAND
> > chip is identifyed with ONFI. Logs below.
> > Can anyone help me with this issue? Is it a known problem?
> > Thanks.
> > PS: Kernel 3.9.3
> 
> I'm inspecting the NAND_BUSWIDTH_AUTO code and it looks rather broken.
> For chips with NAND_BUSWIDTH_AUTO, it calls nand_set_defaults() twice.
> The second call will do exactly nothing. To do this right, you'll
> probably have to hack up nand_set_defaults() so that it will check if
> the function pointer is one of two options:
> 
> 1. NULL
> 2. the 8-bit version
> 
> My (untested, not compiled, and possibly line-wrapped) patch:
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index acd2fc9..26aad56 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2786,7 +2786,7 @@ static void nand_set_defaults(struct nand_chip
> *chip, int busw)
> 
>  	if (!chip->select_chip)
>  		chip->select_chip = nand_select_chip;
> -	if (!chip->read_byte)
> +	if (!chip->read_byte || chip->read_byte == nand_read_byte)
>  		chip->read_byte = busw ? nand_read_byte16 : nand_read_byte;
>  	if (!chip->read_word)
>  		chip->read_word = nand_read_word;
> @@ -2794,9 +2794,9 @@ static void nand_set_defaults(struct nand_chip
> *chip, int busw)
>  		chip->block_bad = nand_block_bad;
>  	if (!chip->block_markbad)
>  		chip->block_markbad = nand_default_block_markbad;
> -	if (!chip->write_buf)
> +	if (!chip->write_buf || chip->write_buf == nand_write_buf)
>  		chip->write_buf = busw ? nand_write_buf16 : nand_write_buf;
> -	if (!chip->read_buf)
> +	if (!chip->read_buf || chip->read_buf == nand_read_buf)
>  		chip->read_buf = busw ? nand_read_buf16 : nand_read_buf;
>  	if (!chip->scan_bbt)
>  		chip->scan_bbt = nand_default_bbt;
> 

Thanks Brian! Tested by me and it works now as expected.

ONFI param page 0 valid
ONFI flash detected
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xca (Micron MT29F2G16ABAEAWP), 256MiB, page size: 2048, OOB size: 64
Scanning device for bad blocks
Creating 1 MTD partitions on "MT29F2G16ABAEAWP":
0x000000000000-0x000010000000 : "nand-gpio"
UBI: attaching mtd4 to ubi0
UBI: scanning is finished
UBI: attached mtd4 (name "nand-gpio", size 256 MiB) to ubi0
UBI: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
UBI: VID header offset: 512 (aligned 512), data offset: 2048
UBI: good PEBs: 2048, bad PEBs: 0, corrupted PEBs: 0
UBI: user volume: 1, internal volumes: 1, max. volumes count: 128
UBI: max/mean erase counter: 2/1, WL threshold: 4096, image sequence number: 3483347360
UBI: available PEBs: 0, total reserved PEBs: 2048, PEBs reserved for bad PEB handling: 40
UBI: background thread "ubi_bgt0d" started, PID 28
...
UBIFS: default file-system created
UBIFS: background thread "ubifs_bgt0_0" started, PID 45
UBIFS: mounted UBI device 0, volume 0, name "bbox"(null)
UBIFS: LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
UBIFS: FS size: 256886784 bytes (244 MiB, 1991 LEBs), journal size 12902400 bytes (12 MiB, 100 LEBs)
UBIFS: reserved for root: 4952683 bytes (4836 KiB)
UBIFS: media format: w4/r0 (latest is w4/r0), UUID 39D861DA-6C42-4A27-97F2-F11FA4A5B334, small LPT model

Can you make a patch for stable?
Thanks again.

---


More information about the linux-mtd mailing list