NAND: DaVinci: Update 4 bit ECC correction
Subsystems (2)
PATCH 1/1 NAND: DaVinci: Update 4 bit ECC correction
From: Sandeep Paulraj <[email protected]>
There was a bug in the 4 bit ECC calculation routine in the DaVinci NAND driver. This becomes prominent when we use 4K page size NAND devices.
This is a fix for the issue.
--- drivers/mtd/nand/davinci_nand.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/mtd/nand/davinci_nand.c +11 -0
@@ -388,6 +388,17 @@ static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat, emif_regs->NANDFCR |=1 <<13 ;/* +* ECC_STATE in NANDFSR register reads 0x3 (Error correction complete) +* immediately after setting the 4BITECC_ADD_CALC_START bit. So if we +* begin trying to poll for the state, we may fall right out of your +* loop without any of the correction calculations having taken place. +* So wait till ECC_STATE reads less than 4. +*/ +do { + val = ((emif_regs->NANDFSR >>8 ) &0xf ); + }while (val <4 ); + +/* * Wait for the corr_state field (bits 8 to 11)in the * NAND Flash Status register to be equal to 0x0, 0x1, 0x2, or 0x3. */
Signature · 1 line
1.6.0.4
PATCH 1/1 NAND: DaVinci: Update 4 bit ECC correction
Quoted 17 lines · s-paulraj at ti.com
From: Sandeep Paulraj <[email protected]>
There was a bug in the 4 bit ECC calculation routine in the DaVinci NAND driver. This becomes prominent when we use 4K page size NAND devices.
This is a fix for the issue.Signed-off-by Sandeep Paulraj <[email protected]>--- drivers/mtd/nand/davinci_nand.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)drivers/mtd/nand/davinci_nand.c +0
-0
drivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat, · line 394
Quoted 7 lines
drivers/mtd/nand/davinci_nand.c +4
-0@@ -388,6 +388,17 @@ static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat, emif_regs->NANDFCR |=1 <<13 ;/* +* ECC_STATE in NANDFSR register reads 0x3 (Error correction complete) +* immediately after setting the 4BITECC_ADD_CALC_START bit. So if we +* begin trying to poll for the state, we may fall right out of your +* loop
"your" loop?
drivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat, · line 399
Quoted 6 lines
drivers/mtd/nand/davinci_nand.c +5
-0without any of the correction calculations having taken place. +* So wait till ECC_STATE reads less than 4. +*/ +do { + val = ((emif_regs->NANDFSR >>8 ) &0xf ); + }while (val <4 );
Comment says wait until less than 4, code says wait until@least 4. Could symbolic constants be used to describe the states instead of magic numbers like 4 and 0xc00?
Is it possible that there could be a race, whereby the hardware finishes before you read NANDFSR for the first time, and thus you never see it be greater than 3?
-Scott
Paulraj
PATCH 1/1 NAND: DaVinci: Update 4 bit ECC correction
Quoted 32 lines
Quoted 8 lines
From: Sandeep Paulraj <[email protected]>
There was a bug in the 4 bit ECC calculation routine in the DaVinci NAND driver. This becomes prominent when we use 4K page size NAND devices.
This is a fix for the issue.Review
Quoted 6 lines
Signed-off-by Sandeep Paulraj <[email protected]>--- drivers/mtd/nand/davinci_nand.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)(quoted diff) +0
-0
b/drivers/mtd/nand/davinci_nand.cdrivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct
Quoted 4 lines
index 41a9568..68a0e15 100644
drivers/mtd/nand/davinci_nand.c +0
-0@@ -388,6 +388,17 @@ static int nand_davinci_4bit_correct_data(struct
mtd_info*mtd,uint8_t*dat,drivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat,
Quoted 4 lines
drivers/mtd/nand/davinci_nand.c +1
-0emif_regs->NANDFCR |=1 <<13 ;/* +* ECC_STATE in NANDFSR register reads 0x3 (Error correction complete)
drivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct · line 392
Quoted 1 line
drivers/mtd/nand/davinci_nand.c +1
-0+* immediately after setting the 4BITECC_ADD_CALC_START bit. So if we
drivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct · line 394
Quoted 2 lines
drivers/mtd/nand/davinci_nand.c +2
-0+* begin trying to poll for the state, we may fall right out of your +* loop "your" loop?
Quoted 11 lines
drivers/mtd/nand/davinci_nand.c static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat, · line 399
Quoted 6 lines
drivers/mtd/nand/davinci_nand.c +5
-0without any of the correction calculations having taken place. +* So wait till ECC_STATE reads less than 4. +*/ +do { + val = ((emif_regs->NANDFSR >>8 ) &0xf ); + }while (val <4 );Comment says wait until less than 4, code says wait until at least 4. Could
symbolic constants be used to describe the states instead of magic numbers like 4 and0xc00?
I'll update my explanations and use symbolic constants
Quoted 4 lines
Is it possible that there could be a race, whereby the hardware finishes before you read NANDFSR for the first time, and thus you never see it be greater than 3?
There are other check conditions after this check condition in the driver.
If we never see the concetned value greater than 3, that actually means that ECC calculation has finished or not required at all because there were no errors
Quoted 2 lines
-Scott
PATCH 1/1 NAND: DaVinci: Update 4 bit ECC correction
Quoted 8 lines · Sandeep
Quoted 3 lines
Is it possible that there could be a race, whereby the hardware finishes before you read NANDFSR for the first time, and thus you never see it be greater than 3?
There are other check conditions after this check condition in the driver. If we never see the concetned value greater than 3, that actually means that ECC calculation has finished or not required at all because there were no errors
And this patch will respond to that by hanging, waiting for a value greater than 3.
-Scott