]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
nand: fix wrong default oob layout for small pages using soft ecc
authorMiquel Raynal <miquel.raynal@free-electrons.com>
Wed, 5 Jul 2017 06:51:09 +0000 (08:51 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 2 Aug 2017 08:26:26 +0000 (10:26 +0200)
commitf7f8c1756e9a5f1258a7cc6b663f8451b724900f
tree4802e38baef1ba390daee395e2ea821f9d44427c
parent3aa0907675a38498d8f2d343e94207ad28a117cf
nand: fix wrong default oob layout for small pages using soft ecc

When using soft ecc, if no ooblayout is given, the core automatically
uses one of the nand_ooblayout_{sp,lp}*() functions to determine the
layout inside the out of band data.

Until kernel version 4.6, struct nand_ecclayout was used for that
purpose. During the migration from 4.6 to 4.7, an error shown up in the
small page layout, in the case oob section is only 8 bytes long.

The layout was using three bytes (0, 1, 2) for ecc, two bytes (3, 4)
as free bytes, one byte (5) for bad block marker and finally
two bytes (6, 7) as free bytes, as shown there:

[linux-4.6] drivers/mtd/nand/nand_base.c:52
static struct nand_ecclayout nand_oob_8 = {
.eccbytes = 3,
.eccpos = {0, 1, 2},
.oobfree = {
{.offset = 3,
 .length = 2},
{.offset = 6,
 .length = 2} }
};

This fixes the current implementation which is incoherent. It
references bit 3 at the same time as an ecc byte and a free byte.

Furthermore, it is clear with the previous implementation that there
is only one ecc section with 8 bytes oob sections. We shall return
-ERANGE in the nand_ooblayout_ecc_sp() function when asked for the
second section.

Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Fixes: 41b207a70d3a ("mtd: nand: implement the default mtd_ooblayout_ops")
Cc: <stable@vger.kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
drivers/mtd/nand/nand_base.c