[PATCH 09/20] spi: cavium-thunderx: fix controller deregistration

Johan Hovold
2026-04-09T12:05:26Z

Make sure to deregister the controller before disabling it to avoid
hanging or leaking resources associated with the queue when the queue
non-empty.

Fixes: 7347a6c7af8d ("spi: octeon: Add ThunderX driver")
Cc: stable@vger.kernel.org # 4.9
Cc: Jan Glauber <jan.glauber@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/spi/spi-cavium-thunderx.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cavium-thunderx.c b/drivers/spi/spi-cavium-thunderx.c
index 99aac40a1bba..f1a9aa696c87 100644
--- a/drivers/spi/spi-cavium-thunderx.c
+++ b/drivers/spi/spi-cavium-thunderx.c
@@ -70,7 +70,7 @@ static int thunderx_spi_probe(struct pci_dev *pdev,

pci_set_drvdata(pdev, host);

- ret = devm_spi_register_controller(dev, host);
+ ret = spi_register_controller(host);
if (ret)
goto error;

@@ -90,8 +90,14 @@ static void thunderx_spi_remove(struct pci_dev *pdev)
if (!p)
return;

+ spi_controller_get(host);
+
+ spi_unregister_controller(host);
+
/* Put everything in a known state. */
writeq(0, p->register_base + OCTEON_SPI_CFG(p));
+
+ spi_controller_put(host);
}

static const struct pci_device_id thunderx_spi_pci_id_table[] = {
--
2.52.0