Skip to contentSkip to conversation

spi: cadence-quadspi: Fix cqspi_probe() error handling for runtime pm

PATCH In review Siddharth Vadapalli 3 participants 7 messages Nov 19, 2025 – Dec 2, 2025 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: cadence-quadspi: Fix cqspi_probe() error handling for runtime pm

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")

---

Hello,

This patch is based on linux-next tagged next-20251118.
Please note that the commit being fixed is not in Mainline Linux yet, due to which the patch is based on linux-next and '[email protected]' hasn't been copied.

Regards,
Siddharth.

 drivers/spi/spi-cadence-quadspi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-cadence-quadspi.c +1 -2
index 8e0df08609c0..af6d050da1c8 100644
@@ -2002,7 +2002,7 @@ static int cqspi_probe(struct platform_device *pdev)
 	if (cqspi->use_direct_mode) {
 		ret = cqspi_request_mmap_dma(cqspi);
 		if (ret == -EPROBE_DEFER)
-			goto probe_dma_failed;
+			goto probe_setup_failed;
 	}
 
 	ret = spi_register_controller(host);
@@ -2020,7 +2020,6 @@ static int cqspi_probe(struct platform_device *pdev)
 probe_setup_failed:
 	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM)))
 		pm_runtime_disable(dev);
-probe_dma_failed:
 	cqspi_controller_enable(cqspi, 0);
 probe_reset_failed:
 	if (cqspi->is_jh7110)
Signature · 1 line
2.51.1
maintainer
#1 lore raw
Quoted 9 lines · Siddharth Vadapalli

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()'.

[...]

Applied to

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

Thanks!

[1/1] spi: cadence-quadspi: Fix cqspi_probe() error handling for runtime pm

      commit: 295fe8406a357bc0abb901a21d1a554fd4dd1d05

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

#2 lore raw
In reply to Siddharth Vadapalli

Hello Siddharth, Mark,

Quoted 28 lines · Siddharth Vadapalli

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]
Quoted 8 lines

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")

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)
[    8.694083] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    8.694091] pc : clk_core_disable+0xa0/0xb4
[    8.694100] lr : clk_core_disable+0xa0/0xb4
[    8.694108] sp : ffff800081023800
[    8.694112] x29: ffff800081023800 x28: ffffd3298dc06158 x27: ffff00000189d410
[    8.694127] x26: ffff00000189d410 x25: ffffd3298dc2e428 x24: ffff00000189d400
[    8.694141] x23: 0000000000000000 x22: ffff000006202000 x21: 0000000000000000
[    8.694156] x20: 0000000000000000 x19: ffff000001ad2200 x18: fffffffffffe7988
[    8.694169] x17: 0000000000000000 x16: 0000000000000006 x15: ffffd329953fe4b0
[    8.694183] x14: 0000000000000000 x13: 64656c6261736964 x12: 2079646165726c61
[    8.694197] x11: 0000000000000058 x10: 0000000000000018 x9 : ffffd329953fe538
[    8.694211] x8 : 0000000000057fa8 x7 : 00000000000001ad x6 : 0000000000000001
[    8.694225] x5 : ffff00003fda46c8 x4 : 0000000000000000 x3 : 0000000000000027
[    8.694239] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000003670000
[    8.694255] Call trace:
[    8.694261]  clk_core_disable+0xa0/0xb4 (P)
[    8.694272]  clk_disable+0x38/0x60
[    8.694283]  cqspi_probe+0x7c8/0xc5c [spi_cadence_quadspi]
[    8.694309]  platform_probe+0x5c/0xa4
[    8.694324]  really_probe+0xc0/0x38c
[    8.694334]  __driver_probe_device+0x7c/0x150
[    8.694344]  driver_probe_device+0x40/0x120
[    8.694353]  __driver_attach+0xc8/0x1e0
[    8.694362]  bus_for_each_dev+0x7c/0xdc
[    8.694371]  driver_attach+0x24/0x30
[    8.694380]  bus_add_driver+0x110/0x230
[    8.694389]  driver_register+0x68/0x130
[    8.694400]  __platform_driver_register+0x20/0x2c
[    8.694410]  cqspi_platform_driver_init+0x20/0x1000 [spi_cadence_quadspi]
[    8.694424]  do_one_initcall+0x60/0x1e0
[    8.694439]  do_init_module+0x54/0x240
[    8.694455]  load_module+0x17c0/0x1e60
[    8.694465]  init_module_from_file+0x88/0xc8
[    8.694477]  __arm64_sys_finit_module+0x268/0x360
[    8.694488]  invoke_syscall.constprop.0+0x48/0xc8
[    8.694501]  do_el0_svc+0x9c/0xd8
[    8.694510]  el0_svc+0x3c/0x140
[    8.694524]  el0t_64_sync_handler+0xa0/0xe4
[    8.694533]  el0t_64_sync+0x198/0x19c
[    8.694545] ---[ end trace 0000000000000000 ]---
[    8.694555] ------------[ cut here ]------------

Francesco

#3 lore raw
Quoted 45 lines · Francesco Dolcini

Hello Siddharth, Mark,

Quoted 28 lines · Siddharth Vadapalli

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]
Quoted 8 lines

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")

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.

Quoted 8 lines
[    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

[    4.554803] cadence-qspi fc40000.spi: No flash device declared
[    4.565690] optee: dynamic shared memory is enabled
[    4.566240] optee: initialized driver
[    4.566620] cadence-qspi fc40000.spi: failed to setup flash parameters -19
[    4.573982] ------------[ cut here ]------------
[    4.573999] clk:75:7 already disabled
[    4.574045] WARNING: CPU: 2 PID: 187 at /usr/src/kernel/drivers/clk/clk.c:1188 clk_core_disable+0xa0/0xb4
[    4.574068] Modules linked in: gf128mul(+) optee spi_cadence_quadspi(+) tee gpio_keys usb_conn_gpio roles dwc3_am62 ti_ads1015 tps65219_pwrbutton industrialio_triggered_buffer kfifo_buf btnxpuart hci_uart bluetooth k3_j72xx_bandgap sa2ul ti_k3_r5_remoteproc rtc_ti_k3 ecdh_generic ti_k3_common ecc sha512 libsha512 rfkill sha256 wave5 sha1 authenc libaes snd_soc_davinci_mcasp snd_soc_ti_udma snd_soc_ti_edma omap_hwspinlock snd_soc_ti_sdma lm75 i3c ina2xx snd_soc_wm8904 omap_mailbox m_can_platform m_can can_dev spi_omap2_mcspi pwm_tiehrpwm loop fuse ipv6 libsha1 autofs4
[    4.574248] CPU: 2 UID: 0 PID: 187 Comm: (udev-worker) Not tainted 6.18.0-0.0.0-devel #1 PREEMPT
[    4.574261] Hardware name: Toradex Verdin AM62P WB on Dahlia Board (DT)
[    4.574268] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    4.574276] pc : clk_core_disable+0xa0/0xb4
[    4.574287] lr : clk_core_disable+0xa0/0xb4
[    4.574294] sp : ffff8000810b3800
[    4.574298] x29: ffff8000810b3800 x28: ffffb19e583d3158 x27: ffff000001922c10
[    4.574313] x26: ffff000001922c10 x25: ffffb19e583d6428 x24: ffff000001922c00
[    4.574327] x23: 0000000000000000 x22: ffff000005c7f800 x21: 0000000000000000
[    4.574342] x20: 0000000000000000 x19: ffff00000296de00 x18: fffffffffffe77a0
[    4.574356] x17: 000000000004b000 x16: 0000000000001000 x15: ffffb19e581fe4b0
[    4.574369] x14: 0000000000000000 x13: 64656c6261736964 x12: 2079646165726c61
[    4.574383] x11: 0000000000000058 x10: 0000000000000018 x9 : ffffb19e581fe538
[    4.574397] x8 : 0000000000057fa8 x7 : 00000000000001b0 x6 : 0000000000000001
[    4.574410] x5 : ffff00007fb976c8 x4 : 0000000000000000 x3 : 0000000000000027
[    4.574424] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000048b90c0
[    4.574439] Call trace:
[    4.574445]  clk_core_disable+0xa0/0xb4 (P)
[    4.574459]  clk_disable+0x38/0x60
[    4.574471]  cqspi_probe+0x7c8/0xc5c [spi_cadence_quadspi]
[    4.574493]  platform_probe+0x5c/0xa4
[    4.574507]  really_probe+0xc0/0x38c
[    4.574517]  __driver_probe_device+0x7c/0x150
[    4.574526]  driver_probe_device+0x40/0x120
[    4.574536]  __driver_attach+0xc8/0x1e0
[    4.574545]  bus_for_each_dev+0x7c/0xdc
[    4.574554]  driver_attach+0x24/0x30
[    4.574566]  bus_add_driver+0x110/0x230
[    4.574575]  driver_register+0x68/0x130
[    4.574585]  __platform_driver_register+0x20/0x2c
[    4.574596]  cqspi_platform_driver_init+0x20/0x1000 [spi_cadence_quadspi]
[    4.574612]  do_one_initcall+0x60/0x1e0
[    4.574626]  do_init_module+0x54/0x240
[    4.574640]  load_module+0x17c0/0x1e60
[    4.574652]  init_module_from_file+0x88/0xc8
[    4.574664]  __arm64_sys_finit_module+0x268/0x360
[    4.574675]  invoke_syscall.constprop.0+0x48/0xc8
[    4.574687]  do_el0_svc+0x9c/0xd8
[    4.574696]  el0_svc+0x3c/0x140
[    4.574708]  el0t_64_sync_handler+0xa0/0xe4
[    4.574718]  el0t_64_sync+0x198/0x19c
[    4.574731] ---[ end trace 0000000000000000 ]---
[    4.576566] ------------[ cut here ]------------
#4 lore raw
Quoted 55 lines · Francesco Dolcini
Quoted 45 lines · Francesco Dolcini

Hello Siddharth, Mark,

Quoted 28 lines · Siddharth Vadapalli

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]
Quoted 8 lines

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")

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.

Quoted 8 lines
[    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)
Quoted 1 line

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.

maintainer
#5 lore raw
Quoted 10 lines · Siddharth Vadapalli
Quoted 8 lines · Francesco Dolcini
Quoted 6 lines · Francesco Dolcini
Quoted 3 lines

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()'.

[    8.648915] cadence-qspi fc40000.spi: No flash device declared
[    8.675671] cadence-qspi fc40000.spi: failed to setup flash parameters -19
Quoted 7 lines

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.

Given the above log we've failed at cqspi_setup_flash() so we shouldn't have got as far as the code you changed for handling direct mode - I think the actual issue is likely Anurag's earlier change f1eb4e792bb1 (spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance) that you mention, it means we've done a pm_runtime_get_noresume() previously. That shouldn't have done a clock enable due to the noresume, but the get() being there will confuse pm_runtime_disable() and cause it to invoke the suspend callback as Francesco identified. This will have been failing previously if controller registration failed, but it's now happening in more situations.

This is all very annoying since runtime PM can be configured off so we can't rely on it's callbacks actually happening. I *think* something like the below ought to DTRT (I'd expect it should avoid the reported error at least):

drivers/spi/spi-cadence-quadspi.c +1 -1
index af6d050da1c8..0833b6f666d0 100644
@@ -1985,7 +1985,6 @@ static int cqspi_probe(struct platform_device *pdev)
 		pm_runtime_enable(dev);
 		pm_runtime_set_autosuspend_delay(dev, CQSPI_AUTOSUSPEND_TIMEOUT);
 		pm_runtime_use_autosuspend(dev);
-		pm_runtime_get_noresume(dev);
 	}
 
 	ret = cqspi_setup_flash(cqspi);
@@ -2012,6 +2011,7 @@ static int cqspi_probe(struct platform_device *pdev)
 	}
 
 	if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) {
+		pm_runtime_get_noresume(dev);
 		pm_runtime_mark_last_busy(dev);
 		pm_runtime_put_autosuspend(dev);
 	}

Unfortunately none of my testing appears to show the issue.

maintainer
#6 lore raw
In reply to Francesco Dolcini
Quoted 9 lines · Francesco Dolcini
Quoted 3 lines · Siddharth Vadapalli

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.

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.

Does this fix the issues you're seeing:

    https://lore.kernel.org/r/[email protected]