Re: [PATCH] spi: cadence-quadspi: Fix clock enable underflows due to runtime PM

From: Dutta, Anurag

Date: Fri Dec 05 2025 - 07:58:14 EST


Please ignore the previous mail.

Hi Mark and Nishanth The below seems to work for me on j721e. Let me know your thoughts.

Apply over 6987d58a9cbc5bd57c983baa514474a86c945d56.
Also, the error actually comes from :

if (cqspi->use_direct_mode) {
    ret = cqspi_request_mmap_dma(cqspi);
    if (ret == -EPROBE_DEFER)
    goto probe_setup_failed;
}

And not from flash_setup().

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index af6d050da1c8..492b44976e52 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -2024,7 +2024,7 @@ static int cqspi_probe(struct platform_device *pdev)
 probe_reset_failed:
        if (cqspi->is_jh7110)
                cqspi_jh7110_disable_clk(pdev, cqspi);
-       clk_disable_unprepare(cqspi->clk);
+       pm_runtime_force_suspend(dev);
 probe_clk_failed:
        return ret;
 }

Regards
Anurag

On 04-12-2025 22:35, Mark Brown wrote:
On Thu, Dec 04, 2025 at 03:11:26PM +0000, Mark Brown wrote:
On Thu, Dec 04, 2025 at 08:05:30AM -0600, Nishanth Menon wrote:
The clock is already turned off by the runtime-PM suspend callback, so an
extra clk_disable*_unprepare() is only correct when runtime-PM support is
not in use.
Right, I'm pretty sure that's where the extra disable is coming from.
The pm_runtime_set_active() further up the function is looking rather
suspect here.
qspi_setup_flash() is just reading DT data, it's not actually
interacting with the hardware at all, so I think we can sidestep the
immediate issue by just moving it to where we parse the DT for the
controller. It's not fixing the actual issue with the missing/extra
clock reference but it does get us back to where we were:

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index af6d050da1c8..bdbeef05cd72 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1845,6 +1845,12 @@ static int cqspi_probe(struct platform_device *pdev)
return -ENODEV;
}
+ ret = cqspi_setup_flash(cqspi);
+ if (ret) {
+ dev_err(dev, "failed to setup flash parameters %d\n", ret);
+ return ret;
+ }
+
/* Obtain QSPI clock. */
cqspi->clk = devm_clk_get(dev, NULL);
if (IS_ERR(cqspi->clk)) {
@@ -1988,12 +1994,6 @@ static int cqspi_probe(struct platform_device *pdev)
pm_runtime_get_noresume(dev);
}
- ret = cqspi_setup_flash(cqspi);
- if (ret) {
- dev_err(dev, "failed to setup flash parameters %d\n", ret);
- goto probe_setup_failed;
- }
-
host->num_chipselect = cqspi->num_chipselect;
if (ddata && (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET))

I'll send this out later assuming nothing blows up in my CI and nobody
else notices an issue.