[RFC PATCH v2 0/4] pstore: NVMEM backend with panic writes
From: ChunYuZhiQiang
Date: Fri Nov 27 2026 - 02:45:20 EST
This series adds the panic-time SPI entry point and its first user: a
pstore backend over an SPI FRAM. v1 was based on an earlier revision of
Heiko Stuebner's atomic-transfer series and is superseded; this version is
based on current broonie/spi for-next with Heiko's v4 applied
(63083539d2bf).
Patch 1 adds spi_sync_atomic() for panic and oops. Heiko's shutdown path
is gated on system_state being past SYSTEM_RUNNING, but panic and oops run
while the system is still running, so they cannot use it. The entry point
reuses transfer_atomic(), takes the bus locks with trylock so a normal
transfer in progress on another CPU returns -EBUSY instead of deadlocking,
and validates without allocating or optimizing.
Patch 2 adds a panic write callback to nvmem_config and
nvmem_device_write_panic(). Patch 3 implements it for FRAM in at25:
FRAM has no write cycle, so WREN and WRITE are issued with
spi_sync_atomic(); EEPROMs still need status polling and are rejected.
Patch 4 adds the pstore/zone backend over NVMEM, selected by device name,
with normal writes through the regular NVMEM path and panic writes
through nvmem_device_write_panic().
This avoids a private pstore-fram driver and a new devicetree binding,
and reuses the existing at25 FRAM support. The fsl_lpspi controller
implementation is sent separately; this series only needs the
transfer_atomic() callback.
Testing:
- the series compiles on x86 with COMPILE_TEST and on arm64, including
against the for-next versions of the touched files;
- a mock SPI controller test in qemu passes (spi_sync_atomic and its
error paths);
- qemu boots with the pstore/nvmem backend built in and no regression;
- a mock NVMEM provider runtime test and the i.MX8QXP panic path are
still pending.
Changes in v2:
- rebased onto current for-next with Heiko's v4 applied;
- include spi_sync_atomic() here so the panic API and its pstore user are
reviewed together;
- the fsl_lpspi controller implementation is now a separate series.
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 has reviewed and signed them.
Thanks,
ChunYuZhiQiang
Signed-off-by: ChunYuZhiQiang <chunyuzhiqiang@xxxxxxxx>
ChunYuZhiQiang (4):
spi: add spi_sync_atomic() for panic and oops
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 +
drivers/spi/spi.c | 69 +++++++++-
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 +
include/linux/spi/spi.h | 1 +
10 files changed, 479 insertions(+), 4 deletions(-)
create mode 100644 fs/pstore/nvmem.c
base-commit: 63083539d2bf955ccf84042d4b044d1133752bed
--
2.47.3