Commit c907464a0ad5f1327a3873e9d0ffd617a0182a44

Authored by Miquel Raynal
Committed by Jagan Teki
1 parent af61ea27f5

mtd: rawnand: pxa3xx: fix 2kiB pages with 8b strength chips layout

The initial layout for such NAND chips was the following:

+----------------------------------------------------------------------------+
| 1024 (data) | 30 (ECC) | 1024 (data) | 30 (ECC) | 32 (free OOB) | 30 (ECC) |
+----------------------------------------------------------------------------+

This layout has a weakness: reading empty pages trigger ECC errors
(this is expected), but the hardware ECC engine tries to correct the
data anyway and creates itself bitflips, hence bitflips are detected
in erased pages while actually there are none in the NAND chip.

Two solutions have been found at the same time. One was to enlarge the
free OOB area to 64 bytes, changing the layout to be:

+----------------------------------------------------------------------------+
| 1024 (data) | 30 (ECC) | 1024 (data) | 30 (ECC) | 64 (free OOB) | 30 (ECC) |
+----------------------------------------------------------------------------+
                                                    ^^

The very big drawbacks of this solution are:
1/ It prevents booting from NAND.
2/ The current Linux driver (marvell_nand) does not have such problem
because it already re-reads possible empty pages in raw mode before
checking for bitflips. Using different layouts in U-Boot and Linux
would simply not work.

As this driver does support raw reads now and uses it to check for
empty pages, let's forget about this broken hack and return to the
initial layout with only 32 free OOB bytes.

Fixes: ac56a3b30c ("mtd: nand: pxa3xx: add support for 2KB 8-bit flash")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>

Showing 1 changed file with 9 additions and 9 deletions Side-by-side Diff

drivers/mtd/nand/raw/pxa3xx_nand.c
... ... @@ -327,14 +327,14 @@
327 327 static struct nand_ecclayout ecc_layout_2KB_bch8bit = {
328 328 .eccbytes = 64,
329 329 .eccpos = {
330   - 64, 65, 66, 67, 68, 69, 70, 71,
331   - 72, 73, 74, 75, 76, 77, 78, 79,
332   - 80, 81, 82, 83, 84, 85, 86, 87,
333   - 88, 89, 90, 91, 92, 93, 94, 95,
334   - 96, 97, 98, 99, 100, 101, 102, 103,
335   - 104, 105, 106, 107, 108, 109, 110, 111,
336   - 112, 113, 114, 115, 116, 117, 118, 119,
337   - 120, 121, 122, 123, 124, 125, 126, 127},
  330 + 32, 33, 34, 35, 36, 37, 38, 39,
  331 + 40, 41, 42, 43, 44, 45, 46, 47,
  332 + 48, 49, 50, 51, 52, 53, 54, 55,
  333 + 56, 57, 58, 59, 60, 61, 62, 63,
  334 + 64, 65, 66, 67, 68, 69, 70, 71,
  335 + 72, 73, 74, 75, 76, 77, 78, 79,
  336 + 80, 81, 82, 83, 84, 85, 86, 87,
  337 + 88, 89, 90, 91, 92, 93, 94, 95},
338 338 .oobfree = { {1, 4}, {6, 26} }
339 339 };
340 340  
... ... @@ -1591,7 +1591,7 @@
1591 1591 info->chunk_size = 1024;
1592 1592 info->spare_size = 0;
1593 1593 info->last_chunk_size = 1024;
1594   - info->last_spare_size = 64;
  1594 + info->last_spare_size = 32;
1595 1595 info->ecc_size = 32;
1596 1596 ecc->mode = NAND_ECC_HW;
1597 1597 ecc->size = info->chunk_size;