[RFC PATCH 0/3] pstore: add an NVMEM backend with panic writes
From: ChunYuZhiQiang
Date: Mon Nov 16 2026 - 05:29:16 EST
This series builds on the SPI panic atomic transfer series sent
separately. It is not standalone: patch 2 uses spi_sync_atomic() and the
pstore panic path depends on the controller implementing transfer_atomic().
The target system has no retained RAM. A SPI FRAM is the only persistent
store, and the crash log must reach it before the next reset. Existing
pstore backends do not fit: pstore/blk needs a block device, mtdpstore
needs an MTD device, and the new spi-mem panic write path requires
exec_op() plus a native chip select. The FRAM here is an NVMEM device on
a GPIO chip select.
Patch 1 adds a panic write callback to nvmem_config and a matching
nvmem_device_write_panic() consumer API. The callback must not sleep,
allocate, use DMA, wait for interrupts or touch a GPIO that may sleep.
Patch 2 implements the callback for FRAM in the at25 driver. FRAM has no
write cycle, so the WREN and WRITE commands are issued directly with
spi_sync_atomic(). EEPROMs still need status polling and are rejected.
Patch 3 adds a pstore/zone backend for NVMEM devices. The device is
selected by name, the pstore area is described by offset and total_size,
and the zone sizes are module parameters with Kconfig defaults matching
pstore/blk. Normal writes use the regular NVMEM path; panic writes use
nvmem_device_write_panic(). This avoids a private pstore-fram driver and
a new devicetree binding, and reuses the existing at25 FRAM support.
Testing:
- the changes compile on x86 with COMPILE_TEST and on arm64;
- qemu boots with the backend built in and the SPI mock test still
passes;
- a runtime test with a mock NVMEM provider and the full panic path on
i.MX8QXP are still pending.
Questions:
1. Is the panic write operation at the NVMEM level the right layer, or
should pstore talk to the SPI device directly?
2. Is reg_write_panic in nvmem_config acceptable, or should it be a
separate provider operation?
3. Is selecting the NVMEM device by module parameter acceptable, or is
an NVMEM cell/devicetree nomination preferred?
4. Should the backend live in fs/pstore or drivers/nvmem?
This cover letter and the patches were prepared with AI assistance; the
submitter must review them before submission.
Thanks,
ChunYuZhiQiang
Signed-off-by: ChunYuZhiQiang <chunyuzhiqiang@xxxxxxxx>
ChunYuZhiQiang (3):
nvmem: add panic write support
nvmem: at25: support panic writes for FRAM
pstore: add nvmem backend
drivers/nvmem/at25.c | 59 +++++++++
drivers/nvmem/core.c | 44 +++++++
drivers/nvmem/internals.h | 1 +
fs/pstore/Kconfig | 64 +++++++++
fs/pstore/Makefile | 3 +
fs/pstore/nvmem.c | 230 +++++++++++++++++++++++++++++++++
include/linux/nvmem-consumer.h | 9 ++
include/linux/nvmem-provider.h | 3 +
8 files changed, 413 insertions(+)
create mode 100644 fs/pstore/nvmem.c
--
2.47.3