[PATCH 0/2] spi: Implement a atomic transfer as a last resort
Heiko Stuebner
heiko at sntech.de
Fri Nov 6 10:18:21 PST 2026
SPI devices at times are used as PMICs including a power-controller
functionality that should turn off a system.
This happens in an atomic context very late during the shutdown, where
no interrupts are available anymore and conflicts with the asynchronous
nature of the SPI subsystem.
====== History ======
For the RK806 spi-connected PMIC this has already caused interesting
artifacts.
A first change, tried to "fix" the issue by using the
SYS_OFF_MODE_POWER_OFF_PREPARE step of poweroff. While this hides the
issue, on some devices this now turns the pmic off too early before
other important steps are done.
To mitigate that issue for "some" devices, a change [0] tried to use
different poweroff phases for i2c and spi devices, where Lee rightfully
said, that with this no proper solution would be done - and Lee was right,
as that issue now is open since 2024.
The newest change is a simple revert back the old way [1] because of
those issues caused on other devices, but that now breaks the SPI side
again and also did not take into account that long history.
====== Now =======
The I2C framework has an atomic transfer callback for exactly this late
stage transfers since
commit 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers")
and during the discussion it was suggested implementing something like
this for SPI too.
As this did not seem to have happened yet, I thought I'd try my luck.
Similar to I2C this is meant only for that latest stage so I stole the
gating from there too.
I assume I did not take some SPI specifics into account, but I guess
having some code to discuss is a starting point at least :-)
[0] https://lore.kernel.org/lkml/20240730180903.81688-1-sebastian.reichel@collabora.com/
[1] https://lore.kernel.org/all/20260908-veyron-shutdown-v1-1-066ecb80f5f2@gmail.com/
Cc: Heiko Stuebner <heiko at sntech.de>
Cc: linux-spi at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org
Cc: linux-rockchip at lists.infradead.org
Cc: quentin.schulz at cherry.de
Cc: Lee Jones <lee at kernel.org>
Cc: Sebastian Reichel <sebastian.reichel at collabora.com>
Heiko Stuebner (2):
spi: Add infrastructure for atomic sync transfers
spi: rockchip: add an atomic transfer function
drivers/spi/spi-rockchip.c | 88 ++++++++++++++++++++++++++++++++++++++
drivers/spi/spi.c | 66 ++++++++++++++++++++++++++--
include/linux/spi/spi.h | 11 +++++
3 files changed, 161 insertions(+), 4 deletions(-)
--
2.47.3
More information about the Linux-rockchip
mailing list