[PATCH 3/5] spi: spi-zynqmp-gqspi: Stop the controller fully on remove

From: Srikanth Boyapally

Date: Sun Nov 15 2026 - 11:57:09 EST


From: Mohammad Zeeshan <zeeshan.mohammad2@xxxxxxx>

zynqmp_qspi_remove() used to stop the hardware with one write,
GQSPI_EN = 0. That disables the controller and leaves pending GQSPI
and DMA status set, and leaves the interrupt sources enabled.

zynqmp_qspi_disable_hw() is that write plus the rest of the stop
sequence: acknowledge pending status, mask every interrupt source,
then clear GQSPI_EN. Call it here so remove() performs the whole
sequence.

pm_runtime_get_sync() can fail and leave the clocks off. Skip the
helper in that case and warn. get_sync() still increments the usage
counter on error, so pm_runtime_put_noidle() below still balances it.

Signed-off-by: Mohammad Zeeshan <zeeshan.mohammad2@xxxxxxx>
Signed-off-by: Srikanth Boyapally <srikanth.boyapally@xxxxxxx>
---
drivers/spi/spi-zynqmp-gqspi.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index cf22ae8d2163..39f90fc3f453 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -1372,19 +1372,25 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
static void zynqmp_qspi_remove(struct platform_device *pdev)
{
struct zynqmp_qspi *xqspi = platform_get_drvdata(pdev);
+ int ret;

- pm_runtime_get_sync(&pdev->dev);
+ ret = pm_runtime_get_sync(&pdev->dev);

spi_unregister_controller(xqspi->ctlr);

/*
* Mask at the interrupt controller, same reasoning as
- * zynqmp_qspi_shutdown(): the write below cannot recall a handler
- * the GIC already dispatched.
+ * zynqmp_qspi_shutdown(). Placed before the ret >= 0 check so it
+ * also covers the branch where disable_hw() is skipped.
*/
disable_irq(xqspi->irq);

- zynqmp_gqspi_write(xqspi, GQSPI_EN_OFST, 0x0);
+ if (ret >= 0)
+ zynqmp_qspi_disable_hw(xqspi);
+ else
+ dev_warn(&pdev->dev,
+ "failed to resume device, skip hw disable (%d)\n",
+ ret);

pm_runtime_disable(&pdev->dev);
pm_runtime_dont_use_autosuspend(&pdev->dev);

--
2.43.0