mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mtd: onenand: report OOB write progress after programming
@ 2026-12-05  7:16 James Hilliard
  0 siblings, 0 replies; only message in thread
From: James Hilliard @ 2026-12-05  7:16 UTC (permalink / raw)
  To: Kyungmin Park, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
  Cc: linux-mtd, linux-kernel, James Hilliard

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@gmail.com>
---
 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@gmail.com>


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-05  7:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-05  7:16 [PATCH] mtd: onenand: report OOB write progress after programming James Hilliard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®