From: James Hilliard <james.hilliard1@gmail.com>
To: Robert Jarzmik <robert.jarzmik@free.fr>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Ivan Djelic <ivan.djelic@parrot.com>,
David Woodhouse <David.Woodhouse@intel.com>,
Mike Dunn <mikedunn@newsguy.com>,
Brian Norris <computersforpeace@gmail.com>,
Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
James Hilliard <james.hilliard1@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH 5/5] mtd: docg3: report the maximum bitflip count across read pages
Date: Fri, 04 Dec 2026 22:49:31 -0700 [thread overview]
Message-ID: <20261204-submit-docg3-oob-fixes-v1-v1-5-ea0bf6c535ca@gmail.com> (raw)
In-Reply-To: <20261204-submit-docg3-oob-fixes-v1-v1-0-ea0bf6c535ca@gmail.com>
A clean last page can hide earlier bitflips in a multi-page read.
doc_read_oob() tracks the maximum number of bitflips in any page, but
sets its return value to zero each time it starts checking another page.
An MTD caller can therefore miss the indication that the read crossed
the device's bitflip threshold.
Return the maximum after the last successful page. Also record it in
the request statistics so a later failing page does not erase it.
Fixes: edbc4540e02c ("mtd: driver _read() returns max_bitflips; mtd_read() returns -EUCLEAN")
Cc: stable@vger.kernel.org
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/mtd/devices/docg3.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
index c00693aba84a..051c6f56d59a 100644
--- a/drivers/mtd/devices/docg3.c
+++ b/drivers/mtd/devices/docg3.c
@@ -861,13 +861,13 @@ static bool doc_oob_mode_valid(unsigned int mode)
/**
* doc_read_oob - Read out of band bytes from flash
* @mtd: the device
- * @from: the offset from first block and first page, in bytes, aligned on page
- * size
+ * @from: byte offset in the device
* @ops: the mtd oob structure
*
* Reads flash memory OOB area of pages.
*
- * Returns 0 if read successful, of -EIO, -EINVAL if an error occurred
+ * Return: The maximum number of bitflips in any page read, or a negative
+ * error code.
*/
static int doc_read_oob(struct mtd_info *mtd, loff_t from,
struct mtd_oob_ops *ops)
@@ -960,7 +960,6 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
if (ret > 0) {
mtd->ecc_stats.corrected += ret;
max_bitflips = max(max_bitflips, ret);
- ret = max_bitflips;
}
}
@@ -989,6 +988,8 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
from += DOC_LAYOUT_PAGE_SIZE;
skip = 0;
}
+ if (ret >= 0)
+ ret = max_bitflips;
out:
if (ops->stats) {
@@ -996,6 +997,7 @@ static int doc_read_oob(struct mtd_info *mtd, loff_t from,
mtd->ecc_stats.failed - old_stats.failed;
ops->stats->corrected_bitflips +=
mtd->ecc_stats.corrected - old_stats.corrected;
+ ops->stats->max_bitflips = max_bitflips;
}
mutex_unlock(&docg3->cascade->lock);
return ret;
--
2.53.0
prev parent reply other threads:[~2026-12-05 5:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 5:49 [PATCH 0/5] mtd: docg3: fix spare-area transfers and ECC reporting James Hilliard
2026-12-05 5:49 ` [PATCH 1/5] mtd: docg3: check whole-page OOB writes in the selected mode James Hilliard
2026-12-05 5:49 ` [PATCH 2/5] mtd: docg3: invalidate staged OOB on page write and block erase James Hilliard
2026-12-05 5:49 ` [PATCH 3/5] mtd: docg3: correct BCH errors in the buffer holding the affected byte James Hilliard
2026-12-05 5:49 ` [PATCH 4/5] mtd: docg3: return the requested spare bytes in the selected OOB mode James Hilliard
2026-12-05 5:49 ` James Hilliard [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204-submit-docg3-oob-fixes-v1-v1-5-ea0bf6c535ca@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=David.Woodhouse@intel.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=computersforpeace@gmail.com \
--cc=ivan.djelic@parrot.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mikedunn@newsguy.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robert.jarzmik@free.fr \
--cc=stable@vger.kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®