[PATCH v3 0/2] mtd: rawnand: serialize OTP and BBT recovery operations

From: James Hilliard

Date: Thu Nov 26 2026 - 15:05:13 EST


Route raw NAND OTP callbacks through core wrappers that hold the chip
and controller locks, and protect marker writes performed by BBT
failure recovery. Both paths issue NAND commands outside the ordinary
MTD read/write wrappers, so they need the same serialization and
suspend handling as normal operations.

The first patch registers manufacturer OTP operations with the raw NAND
core, which invokes them under the normal locks. The second uses those
locks around BBT recovery marker writes.

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

---
Changes in v3:
- Run raw NAND OTP callbacks under core-managed chip/controller locking
and resume handling; keep target selection in the device-specific
callbacks.
- Keep helper visibility changes with the BBT recovery patch that uses
them.
- Link to v2: https://patch.msgid.link/20261122-submit-rawnand-operation-locking-v1-v2-0-030bc867f0c7@xxxxxxxxx

Changes in v2:
- Rebase on nand/next after the BBT logging change.
- Apply the Macronix locking change on top of the posted OTP error
propagation fix; both touch the OTP cleanup path.
- Link to v1: https://patch.msgid.link/20261108-submit-rawnand-operation-locking-v1-v1-0-565010fc5f8b@xxxxxxxxx

---
James Hilliard (2):
mtd: rawnand: serialize OTP operations in the core
mtd: rawnand: serialize bad-block marker writes during BBT recovery

drivers/mtd/nand/raw/internals.h | 2 +
drivers/mtd/nand/raw/nand_base.c | 110 ++++++++++++++++++++++++++++++++++-
drivers/mtd/nand/raw/nand_bbt.c | 2 +
drivers/mtd/nand/raw/nand_macronix.c | 32 +++++-----
include/linux/mtd/rawnand.h | 24 ++++++++
5 files changed, 151 insertions(+), 19 deletions(-)
---
base-commit: ec1e844b9486302a488abc03ea918db60709766e
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next
change-id: 20261108-submit-rawnand-operation-locking-v1-1a0b8fe786d4
prerequisite-message-id: <20261108-submit-macronix-otp-errors-v1-v1-1-8f64a2ad5a10@xxxxxxxxx>
prerequisite-patch-id: a542c9cd698d2d4c090932b8d74dc6f520a71166

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