Linux SPI subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging
@ 2025-12-12  7:23 Anurag Dutta
  2025-12-12  7:23 ` [PATCH 1/2] spi: cadence-quadspi: Add error logging for DMA request failure Anurag Dutta
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Anurag Dutta @ 2025-12-12  7:23 UTC (permalink / raw)
  To: broonie
  Cc: grmoore, nm, francesco, s-vadapalli, linux-spi, linux-kernel,
	gehariprasath, u-kumar1, a-dutta

This series addresses issues in the cadence-quadspi driver's probe
error path:

Patch 1 fixes a clock disable imbalance that occurs when probe fails
after runtime PM is enabled, particularly when DMA request returns
-EPROBE_DEFER.

Patch 2 adds proper error logging for DMA request failures using
dev_err_probe() to improve diagnostics and handle probe deferral
appropriately.

logs : https://gist.github.com/anuragdutta731/59925cd11a50913b7128c88cd5394db7

Anurag Dutta (2):
  spi: cadence-quadspi: Add error logging for DMA request failure
  spi: cadence-quadspi: Fix clock disable on probe failure path

 drivers/spi/spi-cadence-quadspi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] spi: cadence-quadspi: Add error logging for DMA request failure
  2025-12-12  7:23 [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Anurag Dutta
@ 2025-12-12  7:23 ` Anurag Dutta
  2025-12-12  7:23 ` [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path Anurag Dutta
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Anurag Dutta @ 2025-12-12  7:23 UTC (permalink / raw)
  To: broonie
  Cc: grmoore, nm, francesco, s-vadapalli, linux-spi, linux-kernel,
	gehariprasath, u-kumar1, a-dutta

Add dev_err_probe() to log DMA request failures. This properly handles
-EPROBE_DEFER at debug level, reducing log spam during deferred probing.

Signed-off-by: Anurag Dutta <a-dutta@ti.com>
---
 drivers/spi/spi-cadence-quadspi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index af6d050da1c8..7c1f742d95a6 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -2001,8 +2001,10 @@ static int cqspi_probe(struct platform_device *pdev)
 
 	if (cqspi->use_direct_mode) {
 		ret = cqspi_request_mmap_dma(cqspi);
-		if (ret == -EPROBE_DEFER)
+		if (ret == -EPROBE_DEFER) {
+			dev_err_probe(&pdev->dev, ret, "Failed to request mmap DMA\n");
 			goto probe_setup_failed;
+		}
 	}
 
 	ret = spi_register_controller(host);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path
  2025-12-12  7:23 [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Anurag Dutta
  2025-12-12  7:23 ` [PATCH 1/2] spi: cadence-quadspi: Add error logging for DMA request failure Anurag Dutta
@ 2025-12-12  7:23 ` Anurag Dutta
  2025-12-12  8:44   ` Mark Brown
  2025-12-18  9:32 ` [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Mark Brown
  2025-12-23 17:06 ` Mark Brown
  3 siblings, 1 reply; 7+ messages in thread
From: Anurag Dutta @ 2025-12-12  7:23 UTC (permalink / raw)
  To: broonie
  Cc: grmoore, nm, francesco, s-vadapalli, linux-spi, linux-kernel,
	gehariprasath, u-kumar1, a-dutta

When cqspi_request_mmap_dma() returns -EPROBE_DEFER after runtime PM
is enabled, the error path calls clk_disable_unprepare() on an already
disabled clock, causing an imbalance.

Use pm_runtime_get_sync() to increment the usage counter and resume the
device. This prevents runtime_suspend() from being invoked and causing
a double clock disable.

Fixes: 140623410536 ("mtd: spi-nor: Add driver for Cadence Quad SPI Flash Controller")
Signed-off-by: Anurag Dutta <a-dutta@ti.com>
---
 drivers/spi/spi-cadence-quadspi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 7c1f742d95a6..f8823e83a622 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -2026,7 +2026,9 @@ 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);
+
+	if (pm_runtime_get_sync(&pdev->dev) >= 0)
+		clk_disable_unprepare(cqspi->clk);
 probe_clk_failed:
 	return ret;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path
  2025-12-12  7:23 ` [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path Anurag Dutta
@ 2025-12-12  8:44   ` Mark Brown
  2025-12-15 18:13     ` Nishanth Menon
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2025-12-12  8:44 UTC (permalink / raw)
  To: Anurag Dutta
  Cc: grmoore, nm, francesco, s-vadapalli, linux-spi, linux-kernel,
	gehariprasath, u-kumar1

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

On Fri, Dec 12, 2025 at 12:53:12PM +0530, Anurag Dutta wrote:
> When cqspi_request_mmap_dma() returns -EPROBE_DEFER after runtime PM
> is enabled, the error path calls clk_disable_unprepare() on an already
> disabled clock, causing an imbalance.
> 
> Use pm_runtime_get_sync() to increment the usage counter and resume the
> device. This prevents runtime_suspend() from being invoked and causing
> a double clock disable.

Thanks - this is working for me with a hack to trigger the issue,
hopefully others seeing the issue in real scenarios can confirm.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path
  2025-12-12  8:44   ` Mark Brown
@ 2025-12-15 18:13     ` Nishanth Menon
  0 siblings, 0 replies; 7+ messages in thread
From: Nishanth Menon @ 2025-12-15 18:13 UTC (permalink / raw)
  To: Mark Brown
  Cc: Anurag Dutta, grmoore, francesco, s-vadapalli, linux-spi,
	linux-kernel, gehariprasath, u-kumar1

On 17:44-20251212, Mark Brown wrote:
> On Fri, Dec 12, 2025 at 12:53:12PM +0530, Anurag Dutta wrote:
> > When cqspi_request_mmap_dma() returns -EPROBE_DEFER after runtime PM
> > is enabled, the error path calls clk_disable_unprepare() on an already
> > disabled clock, causing an imbalance.
> > 
> > Use pm_runtime_get_sync() to increment the usage counter and resume the
> > device. This prevents runtime_suspend() from being invoked and causing
> > a double clock disable.
> 
> Thanks - this is working for me with a hack to trigger the issue,
> hopefully others seeing the issue in real scenarios can confirm.

This seems to fix the warnings I had reported at least.

gist: https://gist.github.com/nmenon/f062ebcb51f97859e97c9716a27fa494

Tested-by: Nishanth Menon <nm@ti.com>


-- 
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
https://ti.com/opensource

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging
  2025-12-12  7:23 [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Anurag Dutta
  2025-12-12  7:23 ` [PATCH 1/2] spi: cadence-quadspi: Add error logging for DMA request failure Anurag Dutta
  2025-12-12  7:23 ` [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path Anurag Dutta
@ 2025-12-18  9:32 ` Mark Brown
  2025-12-23 17:06 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-12-18  9:32 UTC (permalink / raw)
  To: Anurag Dutta
  Cc: grmoore, nm, francesco, s-vadapalli, linux-spi, linux-kernel,
	gehariprasath, u-kumar1

On Fri, 12 Dec 2025 12:53:10 +0530, Anurag Dutta wrote:
> This series addresses issues in the cadence-quadspi driver's probe
> error path:
> 
> Patch 1 fixes a clock disable imbalance that occurs when probe fails
> after runtime PM is enabled, particularly when DMA request returns
> -EPROBE_DEFER.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] spi: cadence-quadspi: Add error logging for DMA request failure
      commit: b1f54d7143e0f527cca1091857a786e278d72184
[2/2] spi: cadence-quadspi: Fix clock disable on probe failure path
      commit: 1889dd2081975ce1f6275b06cdebaa8d154847a9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging
  2025-12-12  7:23 [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Anurag Dutta
                   ` (2 preceding siblings ...)
  2025-12-18  9:32 ` [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Mark Brown
@ 2025-12-23 17:06 ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-12-23 17:06 UTC (permalink / raw)
  To: Anurag Dutta
  Cc: grmoore, nm, francesco, s-vadapalli, linux-spi, linux-kernel,
	gehariprasath, u-kumar1

On Fri, 12 Dec 2025 12:53:10 +0530, Anurag Dutta wrote:
> This series addresses issues in the cadence-quadspi driver's probe
> error path:
> 
> Patch 1 fixes a clock disable imbalance that occurs when probe fails
> after runtime PM is enabled, particularly when DMA request returns
> -EPROBE_DEFER.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] spi: cadence-quadspi: Add error logging for DMA request failure
      commit: b1f54d7143e0f527cca1091857a786e278d72184
[2/2] spi: cadence-quadspi: Fix clock disable on probe failure path
      commit: 1889dd2081975ce1f6275b06cdebaa8d154847a9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-12-23 17:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12  7:23 [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Anurag Dutta
2025-12-12  7:23 ` [PATCH 1/2] spi: cadence-quadspi: Add error logging for DMA request failure Anurag Dutta
2025-12-12  7:23 ` [PATCH 2/2] spi: cadence-quadspi: Fix clock disable on probe failure path Anurag Dutta
2025-12-12  8:44   ` Mark Brown
2025-12-15 18:13     ` Nishanth Menon
2025-12-18  9:32 ` [PATCH 0/2] spi: cadence-quadspi: Fix probe error path and logging Mark Brown
2025-12-23 17:06 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox