[RFC, v3 5/5] mtd: spinand: skip set/get oob data bytes when interleaved case

Xiangsheng Hou
2021-10-22T02:51:32Z

For syndrome layout, ECC/free byte in oob layout and main
data are interleaved. For this case, it is better to set/get
oob data bytes in ECC engine.

For MTK ECC engine, although it can auto place data as sector +
oob free + oob ecc for one page in pipelined. However, the bad
mark will be not fit with nand spec. Therefore, there have bad
mark swap operation in ecc engine.

But, the swap opeation(between bbm 0xff with 1byte main data) will
lead to more one byte than oobavailable. Set oob databytes after
bad mark swap will lead to lost one oob free byte.

Therefore, just try to modify the spi nand framework for review.
And this may be common for the interleaved case.

Signed-off-by: Xiangsheng Hou <xiangsheng.hou@mediatek.com>
---
drivers/mtd/nand/spi/core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index 2c8685f1f2fa..32a4707982c5 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -401,7 +401,8 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
req->datalen);

if (req->ooblen) {
- if (req->mode == MTD_OPS_AUTO_OOB)
+ if (req->mode == MTD_OPS_AUTO_OOB &&
+ nand->ecc.user_conf.placement != NAND_ECC_PLACEMENT_INTERLEAVED)
mtd_ooblayout_get_databytes(mtd, req->oobbuf.in,
spinand->oobbuf,
req->ooboffs,
@@ -442,7 +443,8 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand,
req->datalen);

if (req->ooblen) {
- if (req->mode == MTD_OPS_AUTO_OOB)
+ if (req->mode == MTD_OPS_AUTO_OOB &&
+ nand->ecc.user_conf.placement != NAND_ECC_PLACEMENT_INTERLEAVED)
mtd_ooblayout_set_databytes(mtd, req->oobbuf.out,
spinand->oobbuf,
req->ooboffs,
--
2.25.1