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

Johan Hovold posted 20 patches 2 months ago
drivers/spi/spi-amlogic-spisg.c       |  4 +++-
drivers/spi/spi-aspeed-smc.c          |  9 ++++++---
drivers/spi/spi-at91-usart.c          |  8 +++++++-
drivers/spi/spi-atmel.c               |  8 +++++++-
drivers/spi/spi-bcm63xx-hsspi.c       |  8 +++++++-
drivers/spi/spi-bcm63xx.c             |  8 +++++++-
drivers/spi/spi-bcmbca-hsspi.c        |  4 +++-
drivers/spi/spi-cavium-octeon.c       |  8 +++++++-
drivers/spi/spi-cavium-thunderx.c     |  8 +++++++-
drivers/spi/spi-coldfire-qspi.c       | 10 ++++++++--
drivers/spi/spi-dln2.c                |  8 +++++++-
drivers/spi/spi-ep93xx.c              |  8 +++++++-
drivers/spi/spi-fsl-espi.c            | 10 +++++++++-
drivers/spi/spi-fsl-spi.c             |  8 +++++++-
drivers/spi/spi-img-spfi.c            |  8 +++++++-
drivers/spi/spi-lantiq-ssc.c          |  8 +++++++-
drivers/spi/spi-meson-spicc.c         |  8 +++++++-
drivers/spi/spi-microchip-core-qspi.c | 12 ++++++++----
drivers/spi/spi-microchip-core-spi.c  |  4 +++-
drivers/spi/spi-mpfs.c                |  4 +++-
20 files changed, 127 insertions(+), 26 deletions(-)
[PATCH 00/20] spi: fix controller deregistration (part 1/2)
Posted by Johan Hovold 2 months ago
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.

Johan


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


Johan Hovold (20):
  spi: amlogic-spisg: fix controller deregistration
  spi: aspeed-smc: fix controller deregistration
  spi: at91-usart: fix controller deregistration
  spi: atmel: fix controller deregistration
  spi: bcm63xx: fix controller deregistration
  spi: bcm63xx-hsspi: fix controller deregistration
  spi: bcmbca-hsspi: fix controller deregistration
  spi: octeon: fix controller deregistration
  spi: cavium-thunderx: fix controller deregistration
  spi: coldfire-qspi: fix controller deregistration
  spi: dln2: fix controller deregistration
  spi: ep93xx: fix controller deregistration
  spi: fsl-espi: fix controller deregistration
  spi: fsl: fix controller deregistration
  spi: img-spfi: fix controller deregistration
  spi: lantiq-ssc: fix controller deregistration
  spi: meson-spicc: fix controller deregistration
  spi: microchip-core-qspi: fix controller deregistration
  spi: microchip-core-spi: fix controller deregistration
  spi: mpfs: fix controller deregistration

 drivers/spi/spi-amlogic-spisg.c       |  4 +++-
 drivers/spi/spi-aspeed-smc.c          |  9 ++++++---
 drivers/spi/spi-at91-usart.c          |  8 +++++++-
 drivers/spi/spi-atmel.c               |  8 +++++++-
 drivers/spi/spi-bcm63xx-hsspi.c       |  8 +++++++-
 drivers/spi/spi-bcm63xx.c             |  8 +++++++-
 drivers/spi/spi-bcmbca-hsspi.c        |  4 +++-
 drivers/spi/spi-cavium-octeon.c       |  8 +++++++-
 drivers/spi/spi-cavium-thunderx.c     |  8 +++++++-
 drivers/spi/spi-coldfire-qspi.c       | 10 ++++++++--
 drivers/spi/spi-dln2.c                |  8 +++++++-
 drivers/spi/spi-ep93xx.c              |  8 +++++++-
 drivers/spi/spi-fsl-espi.c            | 10 +++++++++-
 drivers/spi/spi-fsl-spi.c             |  8 +++++++-
 drivers/spi/spi-img-spfi.c            |  8 +++++++-
 drivers/spi/spi-lantiq-ssc.c          |  8 +++++++-
 drivers/spi/spi-meson-spicc.c         |  8 +++++++-
 drivers/spi/spi-microchip-core-qspi.c | 12 ++++++++----
 drivers/spi/spi-microchip-core-spi.c  |  4 +++-
 drivers/spi/spi-mpfs.c                |  4 +++-
 20 files changed, 127 insertions(+), 26 deletions(-)

-- 
2.52.0
Re: (subset) [PATCH 00/20] spi: fix controller deregistration (part 1/2)
Posted by Mark Brown 2 months ago
On Thu, 09 Apr 2026 14:03:59 +0200, Johan Hovold wrote:
> spi: fix controller deregistration (part 1/2)
> 
> 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).
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.1

Thanks!

[01/20] spi: amlogic-spisg: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/84d31bb1f625
[02/20] spi: aspeed-smc: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/1044e5a4ccd5
[03/20] spi: at91-usart: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/9acecc9bcff0
[04/20] spi: atmel: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/8d4de97e8352
[05/20] spi: bcm63xx: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/c39e65a4e3b8
[06/20] spi: bcm63xx-hsspi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/ab837c51899d
[07/20] spi: bcmbca-hsspi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/c3d97c3320b9
[08/20] spi: octeon: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/3c49a4d8799b
[09/20] spi: cavium-thunderx: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/dbb6b01267c0
[10/20] spi: coldfire-qspi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/e7c510e192ff
[11/20] spi: dln2: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/c353020fbfa8
[12/20] spi: ep93xx: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/f4838934b695
[13/20] spi: fsl-espi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/e506a700a7ad
[15/20] spi: img-spfi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/fc3a83b0d9c1
[16/20] spi: lantiq-ssc: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/b99206710d03
[17/20] spi: meson-spicc: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/77953c76bec9
[18/20] spi: microchip-core-qspi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/e6464140d439
[19/20] spi: microchip-core-spi: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/d00d722ebad4
[20/20] spi: mpfs: fix controller deregistration
        https://git.kernel.org/broonie/spi/c/573c7db8fce9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark