[PATCH 09/20] spi: cavium-thunderx: fix controller deregistration
From: Johan Hovold
Date: Thu Apr 09 2026 - 08:12:24 EST
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@xxxxxxxxxxxxxxx # 4.9
Cc: Jan Glauber <jan.glauber@xxxxxxxxx>
Signed-off-by: Johan Hovold <johan@xxxxxxxxxx>
---
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