[PATCH] mtd: onenand: report OOB write progress after programming
From: James Hilliard
Date: Sat Dec 05 2026 - 02:16:48 EST
When a page program fails, a combined data and OOB write can report
spare bytes as written even though they were only staged in BufferRAM.
With pipelined writes the count can include the next page, for which
no program command was issued.
Advance the OOB count at the same point as the data count. In the
pipelined path, use the count saved before staging the next page.
Fixes: 9ce969082e49 ("[MTD] [OneNAND] Add write-while-program support")
Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
---
drivers/mtd/nand/onenand/onenand_base.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c
index bca5a3bebd41..c79e2351bdfc 100644
--- a/drivers/mtd/nand/onenand/onenand_base.c
+++ b/drivers/mtd/nand/onenand/onenand_base.c
@@ -1832,6 +1832,9 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
/* Loop until all data write */
while (1) {
+ /* Staging the next page advances oobwritten before we wait. */
+ size_t prev_oobwritten = oobwritten;
+
if (written < len) {
u_char *wbuf = (u_char *) buf;
@@ -1890,6 +1893,7 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
__func__, ret);
break;
}
+ ops->oobretlen = prev_oobwritten;
if (written == len) {
/* Only check verify write turn on */
@@ -1940,6 +1944,7 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
}
written += thislen;
+ ops->oobretlen = oobwritten;
if (written == len)
break;
@@ -1961,7 +1966,6 @@ static int onenand_write_ops_nolock(struct mtd_info *mtd, loff_t to,
onenand_invalidate_bufferram(mtd, 0, -1);
ops->retlen = written;
- ops->oobretlen = oobwritten;
return ret;
}
---
base-commit: 4e5457fcbc14d21e7c004c3159e78fc63838029e
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
change-id: 20261204-submit-onenand-oob-write-progress-v1-29061fc01525
Best regards,
--
James Hilliard <james.hilliard1@xxxxxxxxx>