Skip to contentSkip to conversation

MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

PATCH New John Rigby 4 participants 8 messages Sep 1, 2009 2 messages not in the archive

lore
Share & tools
lore

John Rigby

author
#1 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

In reply to a message not in the archive

Sorry for the late comments. We have been trying to use this code with the associated davinci 4-bit ecc patches and have some questions (inline).

.....

Review

Quoted 7 lines
(quoted diff) +6 -0
+       uint8_t *ecc_code = chip->buffers->ecccode;
+       uint32_t *eccpos = chip->ecc.layout->eccpos;
+       uint8_t *ecc_calc = chip->buffers->ecccalc;
+
+       /* Read the OOB area first */
+       chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);

What about chips that do not support the NAND_CMD_READOOB? Do I need to provide my own read routine for that case?

+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);

Review

Quoted 12 lines
(quoted diff) +11 -0
+       chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+
+       for (i = 0; i < chip->ecc.total; i++)
+               ecc_code[i] = chip->oob_poi[eccpos[i]];
+
+       for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
+               int stat;
+
+               chip->ecc.hwctl(mtd, NAND_ECC_READ);
+               chip->read_buf(mtd, p, eccsize);
+               chip->ecc.calculate(mtd, p, &ecc_calc[i]);

Here you calculate ecc then never use the result?

+

Quoted 10 lines
(quoted diff) +9 -0
+               stat = chip->ecc.correct(mtd, p, &ecc_code[i], NULL);
+               if (stat < 0)
+                       mtd->ecc_stats.failed++;
+               else
+                       mtd->ecc_stats.corrected += stat;
+       }
+       return 0;
+}
+
#2 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

Quoted 12 lines · John Rigby

Sorry for the late comments. We have been trying to use this code with the associated davinci 4-bit ecc patches and have some questions (inline).

.....
+ uint8_t *ecc_code = chip->buffers->ecccode;
+ uint32_t *eccpos = chip->ecc.layout->eccpos;
+ uint8_t *ecc_calc = chip->buffers->ecccalc;
+
+ /* Read the OOB area first */
+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);

Quoted 2 lines

What about chips that do not support the NAND_CMD_READOOB? Do I need to provide my own read routine for that case?

cmdfunc is supposed to fix that up. This is already the case with existing code.

Quoted 14 lines

+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+
+ for (i = 0; i < chip->ecc.total; i++)
+ ecc_code[i] = chip->oob_poi[eccpos[i]];
+
+ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
+ int stat;
+
+ chip->ecc.hwctl(mtd, NAND_ECC_READ);
+ chip->read_buf(mtd, p, eccsize);
+ chip->ecc.calculate(mtd, p, &ecc_calc[i]);

Quoted 1 line

Here you calculate ecc then never use the result?

Hmm, that looks wrong, both here and in the davinci driver. Are the two calls to nand_davinci_4bit_readecc reading different things? Does the calculate function have any side effects beyond producing data that is never used?

-Scott

#3 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

Quoted 4 lines
Quoted 2 lines · John Rigby

Sorry for the late comments. We have been trying to use this code with the associated davinci 4-bit ecc patches and have some questions

We use this internally and it works. Are you having any issues because we don't see any!! J-C has to apply a patch and you will need that for this to work properly. That patch updates the DM355 Config

Quoted 32 lines

(inline).

Quoted 10 lines

.....
+ uint8_t *ecc_code = chip->buffers->ecccode;
+ uint32_t *eccpos = chip->ecc.layout->eccpos;
+ uint8_t *ecc_calc = chip->buffers->ecccalc;
+
+ /* Read the OOB area first */
+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);

Quoted 2 lines

What about chips that do not support the NAND_CMD_READOOB? Do I need to provide my own read routine for that case?

cmdfunc is supposed to fix that up. This is already the case with existing code.

Quoted 7 lines

+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+
+ for (i = 0; i < chip->ecc.total; i++)
+ ecc_code[i] = chip->oob_poi[eccpos[i]];
+
+ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p +=

eccsize) {

Quoted 7 lines

+ int stat;
+
+ chip->ecc.hwctl(mtd, NAND_ECC_READ);
+ chip->read_buf(mtd, p, eccsize);
+ chip->ecc.calculate(mtd, p, &ecc_calc[i]);

Quoted 6 lines
Quoted 1 line

Here you calculate ecc then never use the result?

Hmm, that looks wrong, both here and in the davinci driver. Are the two calls to nand_davinci_4bit_readecc reading different things? Does the calculate function have any side effects beyond producing data that is never used?

Have you reads the patch description. Maybe that might help a bit

This patch adds the new mode NAND_ECC_HW_OOB_FIRST in the nand code to support 4-bit ECC on TI DaVinci devices with large page (up to 2K) NAND chips. This ECC mode is similar to NAND_ECC_HW, with the exception of read_page API that first reads the OOB area, reads the data in chunks, feeds the ECC from OOB area to the ECC hw engine and perform any correction on the data as per the ECC status reported by the engine.

Quoted 6 lines

-Scott
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

author
#4 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

Scott answered my question about chips that don't support NAND_CMD_READOOB, we need to take care of it in cmdfunc.

I still don't see why the calculate method is called. The results are ignored.

Quoted 63 lines · Sandeep
Quoted 4 lines
Quoted 2 lines · John Rigby

Sorry for the late comments. We have been trying to use this code with the associated davinci 4-bit ecc patches and have some questions

We use this internally and it works. Are you having any issues because we don't see any!!
J-C has to apply a patch and you will need that for this to work properly. That patch updates the DM355 Config

Quoted 32 lines

(inline).

Quoted 10 lines

.....
+ uint8_t *ecc_code = chip->buffers->ecccode;
+ uint32_t *eccpos = chip->ecc.layout->eccpos;
+ uint8_t *ecc_calc = chip->buffers->ecccalc;
+
+ /* Read the OOB area first */
+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);

Quoted 2 lines

What about chips that do not support the NAND_CMD_READOOB? Do I need to provide my own read routine for that case?

cmdfunc is supposed to fix that up. This is already the case with existing code.

Quoted 7 lines

+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+
+ for (i = 0; i < chip->ecc.total; i++)
+ ecc_code[i] = chip->oob_poi[eccpos[i]];
+
+ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p +=

eccsize) {

Quoted 7 lines

+ int stat;
+
+ chip->ecc.hwctl(mtd, NAND_ECC_READ);
+ chip->read_buf(mtd, p, eccsize);
+ chip->ecc.calculate(mtd, p, &ecc_calc[i]);

Quoted 6 lines
Quoted 1 line

Here you calculate ecc then never use the result?

Hmm, that looks wrong, both here and in the davinci driver. Are the two calls to nand_davinci_4bit_readecc reading different things? Does the calculate function have any side effects beyond producing data that is never used?

Have you reads the patch description. Maybe that might help a bit

This patch adds the new mode NAND_ECC_HW_OOB_FIRST in the nand code to support 4-bit ECC on TI DaVinci devices with large page (up to 2K) NAND chips. This ECC mode is similar to NAND_ECC_HW, with the exception of read_page API that first reads the OOB area, reads the data in chunks, feeds the ECC from OOB area to the ECC hw engine and perform any correction on the data as per the ECC status reported by the engine.

Quoted 6 lines

-Scott
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

author
#6 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

In reply to a message not in the archive

Thanks for the info.

Quoted 86 lines · Sandeep

This patch is fine.

I'll send an updated NAND Davinci driver patch soon which adds to what is already there. I have made a mistake and testing did not show it.

Have you noticed that not all e-mails reach the mailing list in the correct order? This is true for the conversation you two were having.

Thanks,
Sandeep

Quoted 9 lines

-----Original Message-----
From: Paulraj, Sandeep
Sent: Tuesday, September 01, 2009 12:04 PM
To: Scott Wood; John Rigby
Cc: u-boot at lists.denx.de; Paulraj, Sandeep; Narnakaje, Snehaprabha
Subject: RE: [U-Boot] [PATCH 2/2] MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

Quoted 7 lines
Quoted 2 lines
Quoted 1 line · John Rigby

Sorry for the late comments. We have been trying to use this code

with

Quoted 1 line
Quoted 1 line

the associated davinci 4-bit ecc patches and have some questions

We use this internally and it works. Are you having any issues because we don't see any!!
J-C has to apply a patch and you will need that for this to work

properly.

Quoted 13 lines

That patch updates the DM355 Config

Quoted 12 lines

(inline).

Quoted 11 lines

.....
+ uint8_t *ecc_code = chip->buffers->ecccode;
+ uint32_t *eccpos = chip->ecc.layout->eccpos;
+ uint8_t *ecc_calc = chip->buffers->ecccalc;
+
+ /* Read the OOB area first */
+ chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page);

What about chips that do not support the NAND_CMD_READOOB? Do I

need

Quoted 20 lines
Quoted 20 lines
Quoted 1 line

to provide my own read routine for that case?

cmdfunc is supposed to fix that up. This is already the case with existing code.

Quoted 7 lines

+ chip->read_buf(mtd, chip->oob_poi, mtd->oobsize);
+ chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page);
+
+ for (i = 0; i < chip->ecc.total; i++)
+ ecc_code[i] = chip->oob_poi[eccpos[i]];
+
+ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p +=

eccsize) {

Quoted 7 lines

+ int stat;
+
+ chip->ecc.hwctl(mtd, NAND_ECC_READ);
+ chip->read_buf(mtd, p, eccsize);
+ chip->ecc.calculate(mtd, p, &ecc_calc[i]);

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Here you calculate ecc then never use the result?

Hmm, that looks wrong, both here and in the davinci driver. Are the

two

Quoted 18 lines
Quoted 3 lines

calls to nand_davinci_4bit_readecc reading different things? Does the calculate function have any side effects beyond producing data that is never used?

Have you reads the patch description. Maybe that might help a bit

This patch adds the new mode NAND_ECC_HW_OOB_FIRST in the nand code to support 4-bit ECC on TI DaVinci devices with large page (up to 2K) NAND chips. This ECC mode is similar to NAND_ECC_HW, with the exception of read_page API that first reads the OOB area, reads the data in chunks, feeds the ECC from OOB area to the ECC hw engine and perform any correction on the data as per the ECC status reported by the engine.

Quoted 6 lines

-Scott
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#7 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

In reply to Paulraj
Quoted 4 lines · Sandeep
Quoted 3 lines
Quoted 2 lines · John Rigby

Sorry for the late comments. We have been trying to use this code with the associated davinci 4-bit ecc patches and have some questions

We use this internally and it works. Are you having any issues because we don't see any!!

Calm down, just because it works doesn't mean nobody should ask questions about the code.

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Here you calculate ecc then never use the result?

Hmm, that looks wrong, both here and in the davinci driver. Are the two calls to nand_davinci_4bit_readecc reading different things? Does the calculate function have any side effects beyond producing data that is never used?

Quoted 8 lines

Have you reads the patch description. Maybe that might help a bit

This patch adds the new mode NAND_ECC_HW_OOB_FIRST in the nand code to support 4-bit ECC on TI DaVinci devices with large page (up to 2K) NAND chips. This ECC mode is similar to NAND_ECC_HW, with the exception of read_page API that first reads the OOB area, reads the data in chunks, feeds the ECC from OOB area to the ECC hw engine and perform any correction on the data as per the ECC status reported by the engine.

Yes, I've read that. That doesn't explain why calculate_ecc is producing data, *after* everything has been read, that is never consumed by anything (hardware or software) AFAICT. It doesn't explain why the "generic" code is passing NULL to ecc.correct.

-Scott

#8 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

Hi Scott and Sandeep,

As long as we're looking at these patches again I had a question about patch 1 of 2 in this series.

The following part of the patch added a definition for:

chip->ecc.read_page = nand_read_page_hwecc_oob_first

but since there aren't any "break" statements until "case NAND_ECC_SOFT:" it looks like the chip->ecc.read_page definition ends up being set to:

chip->ecc.read_page = nand_read_page_swecc.

Maybe this is explains why things seem to be working???

Best regards,
Matt

+ case NAND_ECC_HW_OOB_FIRST:
+ /* Similar to NAND_ECC_HW, but a separate read_page handle */
+ if (!chip->ecc.calculate || !chip->ecc.correct ||
+ !chip->ecc.hwctl) {
+ printk(KERN_WARNING "No ECC functions supplied, "
+ "Hardware ECC not possible\n");
+ BUG();
+ }
+ if (!chip->ecc.read_page)
+ chip->ecc.read_page = nand_read_page_hwecc_oob_first;
+

Quoted 34 lines · Scott Wood
Quoted 4 lines · Sandeep
Quoted 3 lines
Quoted 2 lines · John Rigby

Sorry for the late comments. We have been trying to use this code with the associated davinci 4-bit ecc patches and have some questions

We use this internally and it works. Are you having any issues because we don't see any!!

Calm down, just because it works doesn't mean nobody should ask questions about the code.

Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Here you calculate ecc then never use the result?

Hmm, that looks wrong, both here and in the davinci driver. Are the two calls to nand_davinci_4bit_readecc reading different things? Does the calculate function have any side effects beyond producing data that is never used?

Quoted 8 lines

Have you reads the patch description. Maybe that might help a bit

This patch adds the new mode NAND_ECC_HW_OOB_FIRST in the nand code to support 4-bit ECC on TI DaVinci devices with large page (up to 2K) NAND chips. This ECC mode is similar to NAND_ECC_HW, with the exception of read_page API that first reads the OOB area, reads the data in chunks, feeds the ECC from OOB area to the ECC hw engine and perform any correction on the data as per the ECC status reported by the engine.

Yes, I've read that. That doesn't explain why calculate_ecc is producing data, *after* everything has been read, that is never consumed by anything (hardware or software) AFAICT. It doesn't explain why the "generic" code is passing NULL to ecc.correct.

-Scott
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#9 lore raw

PATCH 2/2 MTD:NAND: ADD new ECC mode NAND_ECC_HW_OOB_FIRST

Quoted 7 lines · Matt Waddel

Hi Scott and Sandeep,

As long as we're looking at these patches again I had a question about patch 1 of 2 in this series.

The following part of the patch added a definition for:

Quoted 8 lines

chip->ecc.read_page = nand_read_page_hwecc_oob_first

but since there aren't any "break" statements until "case NAND_ECC_SOFT:" it looks like the chip->ecc.read_page definition ends up being set to:

chip->ecc.read_page = nand_read_page_swecc.

Maybe this is explains why things seem to be working???

No, that's OK -- it stops before that on the
"if (mtd->writesize >= chip->ecc.size) break;" line (or if that condition is not true, it prints a warning that it is falling back on soft ecc).

-Scott