[PATCH 00/26] spi: fix controller deregistration (part 2/2)

Johan Hovold
2026-04-10T08:18:56Z

Device managed registration generally only works if all involved
resources are managed as otherwise resources may be disabled or freed
while they are still in use.

This series fixes the SPI controller drivers that get this wrong by
disabling resources such as clocks, DMA and interrupts while the
controller (and its devices) are still registered, which can lead to
issues like system errors due to unclocked accesses, NULL-pointer
dereferences, hangs or just prevent SPI device drivers from doing I/O
during during deregistration (e.g. to power down devices).

I decided to split these fixes in two parts consisting of 20 and 26
patches respectively in order not to spam the lists too much.

I've also prepared a follow-on series to convert the drivers here that
do not yet use device managed controller allocation (which avoids taking
extra references during deregistration).

After that it should be possible to change the SPI API so that it no
longer drops a reference during deregistration without too much effort
(cf. [1]).

Note that this series is based on spi/for-next which specifically has
commit 1f8fd9490e31 ("spi: zynq-qspi: Simplify clock handling with
devm_clk_get_enabled()") (which is not in the for-7.1 branch).

Johan

[1]
https://lore.kernel.org/lkml/20260325145319.1132072-1-johan@kernel.org/

Johan Hovold (26):
spi: mt65xx: fix controller deregistration
spi: mtk-nor: fix controller deregistration
spi: mxs: fix controller deregistration
spi: npcm-pspi: fix controller deregistration
spi: omap2-mcspi: fix controller deregistration
spi: pic32: fix controller deregistration
spi: pic32-sqi: fix controller deregistration
spi: pl022: fix controller deregistration
spi: qup: fix controller deregistration
spi: rspi: fix controller deregistration
spi: s3c64xx: fix controller deregistration
spi: sh-hspi: fix controller deregistration
spi: sh-msiof: fix controller deregistration
spi: sifive: fix controller deregistration
spi: slave-mt27xx: fix controller deregistration
spi: sprd: fix controller deregistration
spi: st-ssc4: fix controller deregistration
spi: sun4i: fix controller deregistration
spi: sun6i: fix controller deregistration
spi: syncuacer: fix controller deregistration
spi: tegra114: fix controller deregistration
spi: tegra20-sflash: fix controller deregistration
spi: ti-qspi: fix controller deregistration
spi: uniphier: fix controller deregistration
spi: zynqmp-gqspi: fix controller deregistration
spi: zynq-qspi: fix controller deregistration

drivers/spi/spi-mt65xx.c | 4 +++-
drivers/spi/spi-mtk-nor.c | 4 +++-
drivers/spi/spi-mxs.c | 8 +++++++-
drivers/spi/spi-npcm-pspi.c | 8 +++++++-
drivers/spi/spi-omap2-mcspi.c | 8 +++++++-
drivers/spi/spi-pic32-sqi.c | 8 +++++++-
drivers/spi/spi-pic32.c | 11 ++++++++---
drivers/spi/spi-pl022.c | 8 +++++++-
drivers/spi/spi-qup.c | 8 +++++++-
drivers/spi/spi-rspi.c | 10 ++++++++--
drivers/spi/spi-s3c64xx.c | 4 +++-
drivers/spi/spi-sh-hspi.c | 10 ++++++++--
drivers/spi/spi-sh-msiof.c | 10 ++++++++--
drivers/spi/spi-sifive.c | 8 +++++++-
drivers/spi/spi-slave-mt27xx.c | 10 +++++++++-
drivers/spi/spi-sprd.c | 8 ++++++--
drivers/spi/spi-st-ssc4.c | 8 +++++++-
drivers/spi/spi-sun4i.c | 10 +++++++++-
drivers/spi/spi-sun6i.c | 8 +++++++-
drivers/spi/spi-synquacer.c | 8 +++++++-
drivers/spi/spi-tegra114.c | 8 +++++++-
drivers/spi/spi-tegra20-sflash.c | 8 +++++++-
drivers/spi/spi-ti-qspi.c | 14 ++++++--------
drivers/spi/spi-uniphier.c | 8 +++++++-
drivers/spi/spi-zynq-qspi.c | 15 +++++++++++----
drivers/spi/spi-zynqmp-gqspi.c | 4 +++-
26 files changed, 176 insertions(+), 42 deletions(-)

--
2.52.0