mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Diogo Ivo (Schneider Electric)" <diogo.ivo@bootlin.com>
To: Mark Brown <broonie@kernel.org>,
	 Matthew Gerlach <matthew.gerlach@altera.com>,
	 Khairul Anuar Romli <khairul.anuar.romli@altera.com>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Dan Carpenter <dan.carpenter@linaro.org>
Cc: miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com,
	 Pascal EBERHARD <pascal.eberhard@se.com>,
	linux-spi@vger.kernel.org,  linux-kernel@vger.kernel.org,
	 "Diogo Ivo (Schneider Electric)" <diogo.ivo@bootlin.com>,
	 stable@vger.kernel.org
Subject: [PATCH 1/2] spi: cadence-quadspi: fix runtime pm cleanup on probe failure/unbind
Date: Fri, 31 Jul 2026 12:53:46 +0200	[thread overview]
Message-ID: <20260731-cqspi-pm_runtime-v1-1-ff0bfc9e8e56@bootlin.com> (raw)
In-Reply-To: <20260731-cqspi-pm_runtime-v1-0-ff0bfc9e8e56@bootlin.com>

Currently the probe cleanup path is imbalanced regarding
pm_runtime_enable() and pm_runtime_disable(). For example, if the probe
defers after calling cqspi_request_mmap_dma() pm_runtime_disable() will
be called without a prior call to pm_runtime_enable(), causing an
imbalance. Furthermore, the cleanup path does not undo all the runtime
calls made while probing.

Fix this by enforcing the correct correspondence between
pm_runtime_enable() and pm_runtime_resume() and add the missing PM
cleanup calls.

As the history of this driver in mainline is convoluted with several
rounds of fixes it includes the fixes from two commits, namely
commit 5ff4d5d1af0c ("spi: cadence-quadspi: fix runtime pm disable
imbalance on probe failure") and commit 5e8bb0cc72f1 ("spi:
cadence-quadspi: fix runtime pm and clock imbalance on unbind").

Fixes: 74b0b4cf13fc ("spi: spi-cadence-quadspi: Fix pm runtime unbalance")
Cc: stable@vger.kernel.org
Signed-off-by: Diogo Ivo (Schneider Electric) <diogo.ivo@bootlin.com>
---
 drivers/spi/spi-cadence-quadspi.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index da8401261bbc..d749dee54015 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1862,7 +1862,6 @@ static int cqspi_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-
 	ret = clk_prepare_enable(cqspi->clk);
 	if (ret) {
 		dev_err(dev, "Cannot enable QSPI clock.\n");
@@ -1983,16 +1982,19 @@ static int cqspi_probe(struct platform_device *pdev)
 	ret = spi_register_controller(host);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register SPI ctlr %d\n", ret);
-		goto probe_setup_failed;
+		goto disable_rpm;
 	}
 
 	pm_runtime_mark_last_busy(dev);
 	pm_runtime_put_autosuspend(dev);
 
 	return 0;
+disable_rpm:
+	pm_runtime_put_noidle(dev);
+	pm_runtime_dont_use_autosuspend(dev);
+	pm_runtime_disable(dev);
 probe_setup_failed:
 	cqspi_controller_enable(cqspi, 0);
-	pm_runtime_disable(dev);
 probe_reset_failed:
 	if (cqspi->is_jh7110)
 		cqspi_jh7110_disable_clk(pdev, cqspi);
@@ -2026,6 +2028,7 @@ static void cqspi_remove(struct platform_device *pdev)
 		cqspi_jh7110_disable_clk(pdev, cqspi);
 
 	pm_runtime_put_sync(&pdev->dev);
+	pm_runtime_dont_use_autosuspend(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 }
 

-- 
2.55.0


  reply	other threads:[~2026-07-31 10:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 10:53 [PATCH 0/2] spi: cadence-quadspi: fix probe error path and remove Diogo Ivo (Schneider Electric)
2026-07-31 10:53 ` Diogo Ivo (Schneider Electric) [this message]
2026-07-31 10:53 ` [PATCH 2/2] spi: cadence-quadspi: release DMA channel on probe failure Diogo Ivo (Schneider Electric)
2026-07-31 23:48 ` [PATCH 0/2] spi: cadence-quadspi: fix probe error path and remove Mark Brown
2026-08-01 11:27   ` Diogo Ivo
2026-08-01 15:54     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260731-cqspi-pm_runtime-v1-1-ff0bfc9e8e56@bootlin.com \
    --to=diogo.ivo@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=khairul.anuar.romli@altera.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=matthew.gerlach@altera.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=pascal.eberhard@se.com \
    --cc=stable@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®