lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251204140530.xax5didvuc7auzcd@problem>
Date: Thu, 4 Dec 2025 08:05:30 -0600
From: Nishanth Menon <nm@...com>
To: Mark Brown <broonie@...nel.org>
CC: Francesco Dolcini <francesco@...cini.it>, Siddharth Vadapalli
	<s-vadapalli@...com>, Anurag Dutta <a-dutta@...com>,
	<linux-spi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<stable@...r.kernel.org>
Subject: Re: [PATCH] spi: cadence-quadspi: Fix clock enable underflows due to
 runtime PM

On 13:28-20251204, Mark Brown wrote:
> On Thu, Dec 04, 2025 at 10:13:35AM +0100, Francesco Dolcini wrote:
> 
> > Unless I did some stupid mistake testing the patch, it does not fix the issue.
> > Here the log with v6.18 + this patch
> 
> Yeah, I'm pretty sure it didn't work.  I've managed to find a system
> which instantiates the IP so hopefully I can modify it to trigger the
> issue and test directly rather than working blind, I've also noticed
> that we're getting
> 
> [   15.430306] cadence-qspi 13010000.spi: Runtime PM usage count underflow!
> 
> even in normal operation (on that system anyway) so the runtime PM
> handling is definitely unhappy.

Hit the same issue on J721E platform [1], the following seems to help in
my local testing [2]. I am no expert.. but do see if this makes sense

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.

[1] https://dashboard.kernelci.org/log-viewer?itemId=ti%3A4db11a5806594ef99c7c2828&org=ti&type=test&url=http%3A%2F%2Ffiles.kernelci.org%2F%2Fti%2Fmainline%2Fmaster%2Fv6.18-763-g4a26e7032d7d5%2Farm64%2Fdefconfig%2Blab-setup%2Bkselftest%2Fgcc-14%2Fbaseline-nfs-boot.nfs-j721e-idk-gw.txt.gz

[2] https://gist.github.com/nmenon/1ebaa7cf18e7df49ab59aaa7eb798a68

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index af6d050da1c8..3678e971d6d9 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -2024,7 +2024,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);
+	/* Runtime-PM suspend already disables the core clock. */
+	if (ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))
+		clk_disable_unprepare(cqspi->clk);
 probe_clk_failed:
 	return ret;
 }
@@ -2048,9 +2050,11 @@ static void cqspi_remove(struct platform_device *pdev)
 	if (cqspi->rx_chan)
 		dma_release_channel(cqspi->rx_chan);
 
-	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
-		if (pm_runtime_get_sync(&pdev->dev) >= 0)
-			clk_disable(cqspi->clk);
+	if (ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))
+		clk_disable_unprepare(cqspi->clk);
+	else
+		/* Balance the later pm_runtime_put_sync() */
+		pm_runtime_get_sync(&pdev->dev);
 
 	if (cqspi->is_jh7110)
 		cqspi_jh7110_disable_clk(pdev, cqspi);
-- 
2.47.0

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ