* oobavail size calculation error in nand_base.c
@ 2009-05-14 8:28 Jinyoung Park
2009-05-15 14:11 ` Artem Bityutskiy
0 siblings, 1 reply; 3+ messages in thread
From: Jinyoung Park @ 2009-05-14 8:28 UTC (permalink / raw)
To: tglx; +Cc: linux-mtd
Hello.
I found error in nand_base.c.
In nand_scan_tail() function, oobavail size calculation result is
wrong as follow circumstances.
- Define nand_ecclayout using full oobfree array like below.
.oobfree = { {2, 6}, {11, 2}, {16, 8}, {27, 2}, {32, 8}, {43, 2},{48,
8}, {59, 2} }
- Using ARM EABI cross compiler when kernel compile also enable
"Use the ARM EABI to compile the kernl" feature in kernel menuconfig.
I using ARM EABI compiler that codesourcery release arm-2008q3-51.
In this case, right oobavail size is 38 but result is too much
value(e.g. 2703572308...). It's random.
I think sometimes happen that after beyond oobfree array(oobfree[8])
is not 0 when ARM EABI compilation.
Below codes are my modified code. Please check...
Thanks.
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 3d7ed43..abb5998 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2756,9 +2756,12 @@ int nand_scan_tail(struct mtd_info *mtd)
* the out of band area
*/
chip->ecc.layout->oobavail = 0;
- for (i = 0; chip->ecc.layout->oobfree[i].length; i++)
+ for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) {
+ if (chip->ecc.layout->oobfree[i].length == 0)
+ break;
chip->ecc.layout->oobavail +=
chip->ecc.layout->oobfree[i].length;
+ }
mtd->oobavail = chip->ecc.layout->oobavail;
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: oobavail size calculation error in nand_base.c
[not found] <37597.192.168.10.89.1242365806.squirrel@dbdmail.itg.ti.com>
@ 2009-05-15 6:23 ` Park Jinyoung
0 siblings, 0 replies; 3+ messages in thread
From: Park Jinyoung @ 2009-05-15 6:23 UTC (permalink / raw)
To: vimal singh; +Cc: tglx, linux-mtd
I didn't realize that problem was patched, sorry.
And thanks for your reply.
Jinyoung Park
-----Original Message-----
From: vimal singh [mailto:vimalsingh@ti.com]
Sent: Friday, May 15, 2009 2:37 PM
To: Park Jinyoung
Cc: tglx@linutronix.de; linux-mtd@lists.infradead.org
Subject: Re: oobavail size calculation error in nand_base.c
This issue is already noticed by Snehaprabha Narnakaje. And a patch is
already
sent to fix this by David Brownell.
http://lists.infradead.org/pipermail/linux-mtd/2009-April/025205.html
Sorry, last time I replied on wrong subject line... :)
---
Vimal
On Thu, May 14, 2009 at 1:58 PM, Jinyoung Park <parkjy@mtekvision.com>
wrote:
> Hello.
>
> I found error in nand_base.c.
> In nand_scan_tail() function, oobavail size calculation result is
> wrong as follow circumstances.
> - Define nand_ecclayout using full oobfree array like below.
> .oobfree = { {2, 6}, {11, 2}, {16, 8}, {27, 2}, {32, 8}, {43,
2},{48,
> 8}, {59, 2} }
> - Using ARM EABI cross compiler when kernel compile also enable
> "Use the ARM EABI to compile the kernl" feature in kernel menuconfig.
> I using ARM EABI compiler that codesourcery release
arm-2008q3-51.
>
> In this case, right oobavail size is 38 but result is too much
> value(e.g. 2703572308...). It's random.
> I think sometimes happen that after beyond oobfree array(oobfree[8])
> is not 0 when ARM EABI compilation.
> Below codes are my modified code. Please check...
>
> Thanks.
>
> diff --git a/drivers/mtd/nand/nand_base.c
b/drivers/mtd/nand/nand_base.c
> index 3d7ed43..abb5998 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2756,9 +2756,12 @@ int nand_scan_tail(struct mtd_info *mtd)
> * the out of band area
> */
> chip->ecc.layout->oobavail = 0;
> - for (i = 0; chip->ecc.layout->oobfree[i].length; i++)
> + for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES; i++) {
> + if (chip->ecc.layout->oobfree[i].length == 0)
> + break;
> chip->ecc.layout->oobavail +=
> chip->ecc.layout->oobfree[i].length;
> + }
> mtd->oobavail = chip->ecc.layout->oobavail;
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: oobavail size calculation error in nand_base.c
2009-05-14 8:28 oobavail size calculation error in nand_base.c Jinyoung Park
@ 2009-05-15 14:11 ` Artem Bityutskiy
0 siblings, 0 replies; 3+ messages in thread
From: Artem Bityutskiy @ 2009-05-15 14:11 UTC (permalink / raw)
To: Jinyoung Park; +Cc: tglx, linux-mtd
On Thu, 2009-05-14 at 17:28 +0900, Jinyoung Park wrote:
> Hello.
>
> I found error in nand_base.c.
> In nand_scan_tail() function, oobavail size calculation result is
> wrong as follow circumstances.
> - Define nand_ecclayout using full oobfree array like below.
> .oobfree = { {2, 6}, {11, 2}, {16, 8}, {27, 2}, {32, 8}, {43, 2},{48,
> 8}, {59, 2} }
> - Using ARM EABI cross compiler when kernel compile also enable
> "Use the ARM EABI to compile the kernl" feature in kernel menuconfig.
> I using ARM EABI compiler that codesourcery release arm-2008q3-51.
>
> In this case, right oobavail size is 38 but result is too much
> value(e.g. 2703572308...). It's random.
> I think sometimes happen that after beyond oobfree array(oobfree[8])
> is not 0 when ARM EABI compilation.
> Below codes are my modified code. Please check...
It seems the following patch which sits in my l2-mtd-2.6.git fixes
this as well: http://git.infradead.org/users/dedekind/l2-mtd-2.6.git
Author: David Brownell <dbrownell@users.sourceforge.net>
Date: Tue Apr 21 19:51:20 2009 -0700
MTD: NAND: don't walk past end of oobfree[]
Resolve issue noted by Sneha: when computing oobavail from
the list of free areas in the OOB, don't assume there will
always be an unused slot at the end. With ECC_HW_SYNDROME
and 4KB page chips, it's fairly likely there *won't* be one.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: "Narnakaje, Snehaprabha" <nsnehaprabha@ti.com>"
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
--
Best regards,
Artem Bityutskiy (Битюцкий Артём)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-15 14:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-14 8:28 oobavail size calculation error in nand_base.c Jinyoung Park
2009-05-15 14:11 ` Artem Bityutskiy
[not found] <37597.192.168.10.89.1242365806.squirrel@dbdmail.itg.ti.com>
2009-05-15 6:23 ` Park Jinyoung
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).