Linux SPI subsystem development
 help / color / mirror / Atom feed
From: Siddharth Vadapalli <s-vadapalli@ti.com>
To: Francesco Dolcini <francesco@dolcini.it>
Cc: <broonie@kernel.org>, <a-dutta@ti.com>,
	<linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <srk@ti.com>,
	<s-vadapalli@ti.com>
Subject: Re: [PATCH] spi: cadence-quadspi: Fix cqspi_probe() error handling for runtime pm
Date: Mon, 1 Dec 2025 18:08:07 +0530	[thread overview]
Message-ID: <dfbbd5ce209fac9a556c200748d8c521d0d4f450.camel@ti.com> (raw)
In-Reply-To: <20251201074320.GA8737@francesco-nb>

On Mon, 2025-12-01 at 08:43 +0100, Francesco Dolcini wrote:
> On Mon, Dec 01, 2025 at 08:28:44AM +0100, Francesco Dolcini wrote:
> > Hello Siddharth, Mark,
> > 
> > On Wed, Nov 19, 2025 at 08:53:53PM +0530, Siddharth Vadapalli wrote:
> > > Commit f1eb4e792bb1 ("spi: spi-cadence-quadspi: Enable pm runtime earlier
> > > to avoid imbalance") relocated code but missed updating the error handling
> > > path associated with it.
> > > 
> > > Prior to the relocation, runtime pm was enabled after the code-block
> > > associated with 'cqspi_request_mmap_dma()', due to which, the error
> > > handling for the same didn't require invoking 'pm_runtime_disable()'.
> > > 
> > > Post refactoring, runtime pm has been enabled before the code-block and
> > > when an error is encountered, jumping to 'probe_dma_failed' doesn't
> > > invoke 'pm_runtime_disable()'. This leads to a race condition wherein
> > > 'cqspi_runtime_suspend()' is invoked while the error handling path executes
> > > in parallel. The resulting error is the following:
> > > 
> > >   clk:103:0 already disabled
> > >   WARNING: drivers/clk/clk.c:1188 at clk_core_disable+0x80/0xa0, CPU#1: kworker/u8:0/12
> > >   [TRIMMED]
> > >   pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> > >   pc : clk_core_disable+0x80/0xa0
> > >   lr : clk_core_disable+0x80/0xa0
> > >   [TRIMMED]
> > >   Call trace:
> > >    clk_core_disable+0x80/0xa0 (P)
> > >    clk_core_disable_lock+0x88/0x10c
> > >    clk_disable+0x24/0x30
> > >    cqspi_probe+0xa3c/0xae8
> > >   [TRIMMED]
> > > 
> > > The error is due to the second invocation of 'clk_disable_unprepare()' on
> > > 'cqspi->clk' in the error handling within 'cqspi_probe()', with the first
> > > invocation being within 'cqspi_runtime_suspend()'.
> > > 
> > > Fix this by correcting the error handling.
> > > 
> > > Fixes: f1eb4e792bb1 ("spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance")
> > > Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> > 
> > Our CI just hit this WARNING with 6.18 kernel, on verdin-am62. To me it's a
> > regression from v6.18, specifically from spi-fix-v6.18-rc7, we did not
> > had any such WARNING with the master build we did run last Friday.
> > 
> > 
> > [    8.648915] cadence-qspi fc40000.spi: No flash device declared
> > [    8.675671] cadence-qspi fc40000.spi: failed to setup flash parameters -19
> > [    8.693691] ------------[ cut here ]------------
> > [    8.693719] clk:75:7 already disabled
> > [    8.693791] WARNING: CPU: 1 PID: 185 at /usr/src/kernel/drivers/clk/clk.c:1188 clk_core_disable+0xa0/0xb4
> > [    8.693822] Modules linked in: gf128mul(+) snd_soc_simple_card(+) snd_soc_simple_card_utils spi_cadence_quadspi(+) optee tee usb_conn_gpio gpio_keys display_connector roles dwc3_am62 rtc_ti_k3 ti_k3_r5_remoteproc k3_j72xx_bandgap ti_k3_m4_remoteproc ti_k3_common tidss sa2ul sha512 snd_soc_davinci_mcasp drm_display_helper libsha512 snd_soc_ti_udma sha256 sha1 cec snd_soc_ti_edma pruss omap_mailbox snd_soc_ti_sdma omap_hwspinlock authenc bluetooth ecdh_generic ecc ina2xx tpm_tis_i2c rfkill snd_soc_wm8904 libaes lm75 lontium_lt8912b crc_ccitt i3c ti_ads1015 tpm_tis_core industrialio_triggered_buffer kfifo_buf tps65219_pwrbutton tpm rng_core m_can_platform m_can tc358768 can_dev spi_omap2_mcspi pwm_tiehrpwm loop fuse ipv6 libsha1 autofs4
> > [    8.694064] CPU: 1 UID: 0 PID: 185 Comm: (udev-worker) Not tainted 6.18.0-0.0.0-devel #1 PREEMPT
> > [    8.694076] Hardware name: Toradex Verdin AM62 on Dahlia Board (DT)
> 
> Same on verdin-am62p

Could you please check if the driver's suspend callback has executed before
the above? The patch intended to fix the very issue being reported.
Therefore, the commit corresponding to the current patch might still
trigger the issue. Ideally, reverting the commit for the current patch and
the commit under Fixes (f1eb4e792bb1 ("spi: spi-cadence-quadspi: Enable pm
runtime earlier to avoid imbalance"))
should prevent the issue.

Please let me know.

Regards,
Siddharth.

  reply	other threads:[~2025-12-01 12:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19 15:23 [PATCH] spi: cadence-quadspi: Fix cqspi_probe() error handling for runtime pm Siddharth Vadapalli
2025-11-20  9:40 ` Mark Brown
2025-12-01  7:28 ` Francesco Dolcini
2025-12-01  7:43   ` Francesco Dolcini
2025-12-01 12:38     ` Siddharth Vadapalli [this message]
2025-12-02 16:28       ` Mark Brown
2025-12-01 13:06   ` Mark Brown

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=dfbbd5ce209fac9a556c200748d8c521d0d4f450.camel@ti.com \
    --to=s-vadapalli@ti.com \
    --cc=a-dutta@ti.com \
    --cc=broonie@kernel.org \
    --cc=francesco@dolcini.it \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=srk@ti.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