[PATCH v2 0/5] mtd: docg3: fix spare-area transfers and ECC reporting

From: James Hilliard

Date: Sun Dec 06 2026 - 02:10:53 EST


DiskOnChip G3 exposes eight free bytes in its 16-byte spare area. An
AUTO read can return ECC bytes instead of those free bytes; an OOB-only
write of all eight free bytes is rejected. A later page write can also
pick up stale spare bytes instead of the bytes supplied by its caller.

Use the selected OOB layout for reads and writes. Retire staged bytes
after programming their page or when issuing an erase for their block
pair. On full-page reads, correct BCH errors in the buffer containing
the affected byte. Report the highest bitflip count across all pages read.

Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>

---
Changes in v2:
- Keep the requested ECC mode and default spare bytes on data pages past
the end of a combined write's OOB, including across MEMWRITE chunks.
- Invalidate staged OOB when the matching erase command is issued, even
if the subsequent status check fails.
- Link to v1: https://patch.msgid.link/20261204-submit-docg3-oob-fixes-v1-v1-0-ea0bf6c535ca@xxxxxxxxx

---
James Hilliard (5):
mtd: docg3: check whole-page OOB writes in the selected mode
mtd: docg3: invalidate staged OOB on page write and block erase
mtd: docg3: correct BCH errors in the buffer holding the affected byte
mtd: docg3: return the requested spare bytes in the selected OOB mode
mtd: docg3: report the maximum bitflip count across read pages

drivers/mtd/devices/docg3.c | 276 ++++++++++++++++++++++----------------------
1 file changed, 135 insertions(+), 141 deletions(-)
---
base-commit: 4e5457fcbc14d21e7c004c3159e78fc63838029e
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
change-id: 20261204-submit-docg3-oob-fixes-v1-3ac1e192f872

Best regards,
--
James Hilliard <james.hilliard1@xxxxxxxxx>