mirror-linux/drivers/spi
Mark Brown b005d618c8
spi: cadence-quadspi: Prevent indirect read
Merge series from Mateusz Litwin <mateusz.litwin@nokia.com>:

On the Stratix10 platform, indirect reads can become very slow due to lost
interrupts and/or missed `complete()` calls, causing
`wait_for_completion_timeout()` to expire.

Three issues were identified:
1) A race condition exists between the read loop and IRQ `complete()`
   call:
   An IRQ can call `complete()` after the inner loop ends, but before
   `reinit_completion()`, losing the completion event and leading to
   `wait_for_completion_timeout()` expire. This function will not return
   an error because `bytes_to_read` > 0 (indicating data is already in the
   FIFO) and the final `ret` value is overwritten by
   `cqspi_wait_for_bit()` return value (indicating request completion),
   masking the timeout.

   For test purpose, logging was added to print the count of timeouts and
   the outer loop count.
   $ dd if=/dev/mtd0 of=/dev/null bs=64M count=1
   [ 2232.925219] cadence-qspi ff8d2000.spi: Indirect read error timeout
    (1) loop (12472)
   [ 2236.200391] cadence-qspi ff8d2000.spi: Indirect read error timeout
    (1) loop (12460)
   [ 2239.482836] cadence-qspi ff8d2000.spi: Indirect read error timeout
    (5) loop (12450)
   This indicates that such an event is rare, but possible.
   Tested on the Stratix10 platform.

2) The quirk assumes the indirect read path never leaves the inner loop on
   SoCFPGA. This assumption is incorrect when using slow flash. Disabling
   IRQs in the inner loop can cause lost interrupts.

3) The `CQSPI_SLOW_SRAM` quirk disables `CQSPI_REG_IRQ_IND_COMP` (indirect
   completion) interrupt, relying solely on the `CQSPI_REG_IRQ_WATERMARK`
   (FIFO watermark) interrupt. For small transfers sizes, the final data
   read might not fill the FIFO sufficiently to trigger the watermark,
   preventing completion and leading to wait_for_completion_timeout()
   expiration.

Two patches have been prepared to resolve these issues.
-  [1/2] spi: cadence-quadspi: Prevent lost complete() call during
   indirect read
   Moving `reinit_completion()` before the inner loop prevents a race
   condition. This might cause a premature IRQ complete() call to occur;
   however, in the worst case, this will result in a spurious wakeup and
   another wait cycle, which is preferable to waiting for a timeout.

-  [2/2] spi: cadence-quadspi: Improve CQSPI_SLOW_SRAM quirk if flash is
   slow
   Re-enabling `CQSPI_REG_IRQ_IND_COMP` interrupt resolves the problem for
   small reads and removes the disabling of interrupts, addressing the
   issue with lost interrupts. This marginally increases the IRQ count.

   Test:
   $ dd if=/dev/mtd0 of=/dev/null bs=1M count=64
   Results from the Stratix10 platform with mt25qu02g flash.
   FIFO size in all tests: 128

   Serviced interrupt call counts:
   Without `CQSPI_SLOW_SRAM` quirk: 16 668 850
   With `CQSPI_SLOW_SRAM` quirk: 204 176
   With `CQSPI_SLOW_SRAM` and this patch: 224 528

Patch 2/2: Delivers a substantial read‑performance improvement for the
Cadence QSPI controller on the Stratix10 platform. Patch 1/2: Applies to
all platforms and should yield a modest performance gain, most noticeable
with large `CQSPI_READ_TIMEOUT_MS` values and workloads dominated by many
small reads.
2025-12-23 15:18:22 +00:00
..
Kconfig spi: Updates for v6.19 2025-12-04 11:24:24 -08:00
Makefile spi: add support for microchip "soft" spi controller 2025-11-14 13:54:43 +00:00
atmel-quadspi.c spi: atmel-quadspi: Add support for sama7d65 QSPI 2025-09-18 22:26:42 +01:00
internals.h spi: Rework per message DMA mapped flag to be per transfer 2024-06-10 12:49:03 +01:00
spi-airoha-snfi.c spi: airoha-snfi: en7523: workaround flash damaging if UART_TXD was short to GND 2025-11-27 11:42:15 +00:00
spi-altera-core.c spi: add missing MODULE_DESCRIPTION() macros 2024-06-10 12:49:05 +01:00
spi-altera-dfl.c
spi-altera-platform.c spi: remove unneeded 'fast_io' parameter in regmap_config 2025-08-13 22:31:06 +01:00
spi-amd-pci.c spi: spi_amd: Remove the use of dev_err_probe() 2025-08-19 13:05:58 +01:00
spi-amd.c spi: spi_amd: Remove the use of dev_err_probe() 2025-08-19 13:05:58 +01:00
spi-amd.h spi: spi_amd: Add PCI-based driver for AMD HID2 SPI controller 2025-04-06 23:26:10 +01:00
spi-amlogic-spifc-a1.c spi: amlogic-spifc-a1: Handle devm_pm_runtime_enable() errors 2025-11-24 11:31:27 +00:00
spi-amlogic-spifc-a4.c spi: amlogic: fix spifc build error 2025-10-15 14:09:57 +01:00
spi-amlogic-spisg.c spi: Remove the use of dev_err_probe() 2025-08-19 18:45:38 +01:00
spi-apple.c spi: apple: Add "apple,t8103-spi" compatible 2025-09-14 21:51:35 +02:00
spi-ar934x.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-armada-3700.c spi: armada-3700: use 'time_left' variable with wait_for_completion_timeout() 2024-04-30 23:57:26 +09:00
spi-aspeed-smc.c spi: aspeed: Add support for the AST2700 SPI controller 2025-11-17 00:49:57 +00:00
spi-at91-usart.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-ath79.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-atmel.c spi: atmel: Add support for handling GCLK as a clock source 2025-08-10 21:11:42 +01:00
spi-au1550.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-axi-spi-engine.c spi: axi-spi-engine: use adi_axi_pcore_ver_gteq() 2025-09-11 17:52:15 +01:00
spi-bcm-qspi.c
spi-bcm-qspi.h
spi-bcm63xx-hsspi.c spi: bcm63xx-hsspi: fix shared reset 2025-05-30 11:42:38 +01:00
spi-bcm63xx.c spi: Updates for v6.19 2025-12-04 11:24:24 -08:00
spi-bcm2835.c spi: bcm2835: Remove redundant semicolons 2025-08-12 12:06:11 +01:00
spi-bcm2835aux.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-bcmbca-hsspi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-bitbang-txrx.h
spi-bitbang.c spi: bitbang: Implement support for MOSI idle state configuration 2024-07-29 01:19:52 +01:00
spi-brcmstb-qspi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-butterfly.c parport: Remove parport_driver.devmodel 2024-07-03 16:44:22 +02:00
spi-cadence-quadspi.c spi: cadence-quadspi: Improve CQSPI_SLOW_SRAM quirk if flash is slow 2025-12-23 10:58:57 +00:00
spi-cadence-xspi.c spi: cadence: Fix out-of-bounds array access in cdns_mrvl_xspi_setup_clock() 2025-03-31 16:38:32 +01:00
spi-cadence.c spi: spi-cadence: supports transmission with bits_per_word of 16 and 32 2025-11-13 18:56:49 +00:00
spi-cavium-octeon.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-cavium-thunderx.c spi: spi-cavium-thunderx: Use non-hybrid PCI devres API 2025-04-17 12:25:42 +01:00
spi-cavium.c
spi-cavium.h
spi-ch341.c spi: ch341: fix out-of-bounds memory access in ch341_transfer_one 2025-11-28 11:48:08 +00:00
spi-clps711x.c
spi-coldfire-qspi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-cs42l43.c spi: cs42l43: Use actual ACPI firmware node for chip selects 2025-11-20 16:51:48 +01:00
spi-davinci.c spi: davinci: remove platform data header 2025-11-17 17:27:38 +00:00
spi-dln2.c Linux 6.12-rc2 2024-10-07 14:53:15 +01:00
spi-dw-bt1.c spi: dw: rename the spi controller to ctlr 2025-10-13 11:27:35 +01:00
spi-dw-core.c spi: dw: add target mode support 2025-10-13 11:27:36 +01:00
spi-dw-dma.c spi: dw: rename the spi controller to ctlr 2025-10-13 11:27:35 +01:00
spi-dw-mmio.c spi: dw: add target mode support 2025-10-13 11:27:36 +01:00
spi-dw-pci.c spi: dw: rename the spi controller to ctlr 2025-10-13 11:27:35 +01:00
spi-dw.h spi: dw: rename the spi controller to ctlr 2025-10-13 11:27:35 +01:00
spi-ep93xx.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-falcon.c spi: falcon: mark falcon_sflash_xfer() as static 2025-06-18 17:23:10 +01:00
spi-fsi.c spi: fsi: Batch TX operations 2025-02-03 19:24:44 +00:00
spi-fsl-cpm.c spi: add missing MODULE_DESCRIPTION() macros 2024-06-10 12:49:05 +01:00
spi-fsl-cpm.h spi: fsl: remove is_dma_mapped checks 2024-03-28 21:09:46 +00:00
spi-fsl-dspi.c spi: spi-fsl-dspi: Report FIFO overflows as errors 2025-09-03 14:30:34 +01:00
spi-fsl-espi.c spi: Remove redundant pm_runtime_mark_last_busy() calls 2025-07-05 00:50:32 +01:00
spi-fsl-lib.c spi: add missing MODULE_DESCRIPTION() macros 2024-06-10 12:49:05 +01:00
spi-fsl-lib.h
spi-fsl-lpspi.c spi: spi-fsl-lpspi: fix watermark truncation caused by type cast 2025-11-21 14:23:45 +00:00
spi-fsl-qspi.c spi: fsl-qspi: support the SpacemiT K1 SoC 2025-11-06 16:57:36 +00:00
spi-fsl-spi.c spi: fsl-cpm: Check length parity before switching to 16 bit mode 2025-12-14 19:32:49 +09:00
spi-fsl-spi.h
spi-geni-qcom.c spi: geni-qcom: Load spi qup Firmware from linux side 2025-09-17 13:50:23 -05:00
spi-gpio.c spi: gpio: Use explicit 'unsigned int' for parameter types 2025-07-16 11:15:31 +01:00
spi-gxp.c
spi-hisi-kunpeng.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-hisi-sfc-v3xx.c spi: fix typo in the comment 2024-09-30 01:12:21 +02:00
spi-img-spfi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-imx.c Add RSPI support for RZ/T2H and RZ/N2H 2025-11-24 19:25:58 +00:00
spi-ingenic.c spi: ingenic: Use new spi_xfer_is_dma_mapped() helper 2024-06-10 12:48:59 +01:00
spi-intel-pci.c spi: intel: Add support for Oak Stream SPI serial flash 2025-10-29 12:53:45 +00:00
spi-intel-platform.c spi: intel: Improve resource mapping 2025-04-24 12:56:59 +01:00
spi-intel.c spi: intel: Add support for 128M component density 2025-10-20 16:15:29 +01:00
spi-intel.h spi: intel: Improve resource mapping 2025-04-24 12:56:59 +01:00
spi-iproc-qspi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-jcore.c
spi-kspi2.c spi: spi-kspi2: Add KEBA SPI controller support 2024-12-04 16:25:22 +00:00
spi-lantiq-ssc.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-ljca.c spi: ljca: Remove Wentong's e-mail address 2025-09-22 14:23:41 +02:00
spi-lm70llp.c parport: Remove parport_driver.devmodel 2024-07-03 16:44:22 +02:00
spi-loongson-core.c spi: loongson: Fix build warnings about export.h 2025-06-08 23:30:04 +01:00
spi-loongson-pci.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
spi-loongson-plat.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
spi-loongson.h
spi-loopback-test.c spi: loopback-test: Don't use %pK through printk 2025-08-12 12:06:13 +01:00
spi-lp8841-rtc.c
spi-mem.c spi: spi-mem: Trace exec_op 2025-10-27 11:10:50 +00:00
spi-meson-spicc.c spi: meson-spicc: add DMA support 2025-04-24 19:11:49 +01:00
spi-meson-spifc.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-microchip-core-qspi.c support for Amlogic SPI Flash Controller IP 2025-09-12 00:54:56 +01:00
spi-microchip-core-spi.c spi: microchip-core: Fix an error handling path in mchp_corespi_probe() 2025-12-09 10:01:32 +09:00
spi-mpc52xx-psc.c spi: fix typo in the comment 2024-09-30 01:12:21 +02:00
spi-mpc52xx.c spi: mpc52xx: Add cancel_work_sync before module remove 2024-12-02 00:29:46 +00:00
spi-mpc512x-psc.c
spi-mpfs.c spi: mpfs: Fix an error handling path in mpfs_spi_probe() 2025-12-14 19:32:48 +09:00
spi-mt65xx.c spi: mt65xx: Use IRQF_ONESHOT with threaded IRQ 2025-12-17 12:01:17 +00:00
spi-mt7621.c spi: mt7621: allow GPIO chip select lines 2024-03-25 15:03:02 +00:00
spi-mtk-nor.c spi: Remove redundant pm_runtime_mark_last_busy() calls 2025-07-05 00:50:32 +01:00
spi-mtk-snfi.c spi: mtk-snfi: Remove redundant semicolons 2025-08-12 12:06:12 +01:00
spi-mux.c spi: spi-mux: Fix coverity issue, unchecked return value 2025-03-16 23:34:25 +00:00
spi-mxic.c spi: mxic: Support per spi-mem operation frequency switches 2025-01-09 20:16:32 +00:00
spi-mxs.c spi: mxs: fix "transfered"->"transferred" 2025-09-03 13:43:58 +01:00
spi-npcm-fiu.c spi: npcm-fiu: use min_t() to improve code 2025-08-18 13:14:03 +01:00
spi-npcm-pspi.c Linux 6.12-rc2 2024-10-07 14:53:15 +01:00
spi-nxp-fspi.c spi: nxp-fspi: Propagate fwnode in ACPI case as well 2025-11-27 11:41:06 +00:00
spi-oc-tiny.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-offload-trigger-adi-util-sigma-delta.c spi: offload trigger: adi-util-sigma-delta: clean up imports 2025-08-18 13:13:57 +01:00
spi-offload-trigger-pwm.c spi: offload: Add offset parameter 2025-10-13 11:27:52 +01:00
spi-offload.c spi: offload: check offload ops existence before disabling the trigger 2025-06-09 13:31:50 +01:00
spi-omap-uwire.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-omap2-mcspi.c spi: omap2-mcspi: drive SPI_CLK on transfer_setup() 2025-09-22 09:28:50 +01:00
spi-orion.c Linux 6.12-rc2 2024-10-07 14:53:15 +01:00
spi-pci1xxxx.c spi: spi-pci1xxxx: enable concurrent DMA read/write across SPI transfers 2025-06-30 12:15:45 +01:00
spi-pic32-sqi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-pic32.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-pl022.c spi: spl022: use min_t() to improve code 2025-08-18 13:14:04 +01:00
spi-ppc4xx.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-pxa2xx-dma.c spi: pxa2xx: Remove DMA parameters from struct chip_data 2024-05-03 11:11:36 +09:00
spi-pxa2xx-pci.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
spi-pxa2xx-platform.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
spi-pxa2xx.c spi: pxa2xx: Remove the use of dev_err_probe() 2025-08-19 13:06:02 +01:00
spi-pxa2xx.h spi: pxa2xx: Do not override dev->platform_data on probe 2024-08-22 13:34:05 +01:00
spi-qcom-qspi.c spi: Use of_property_present() for non-boolean properties 2024-11-04 19:18:19 +00:00
spi-qpic-snand.c spi: spi-qpic-snand: make qcom_spi_ecc_engine_ops_pipelined const 2025-10-23 14:10:53 +01:00
spi-qup.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-rb4xx.c spi: rb4xx: use devm for clk_prepare_enable 2025-08-28 11:08:47 +02:00
spi-realtek-rtl-snand.c spi: realtek-rtl-snand: Drop unneeded assignment for cache_type 2025-02-03 00:41:38 +00:00
spi-realtek-rtl.c
spi-rockchip-sfc.c spi: rockchip-sfc: Fix DMA-API usage 2025-10-06 13:37:12 +01:00
spi-rockchip.c spi-rockchip: Fix register out of bounds access 2025-03-26 13:31:00 +00:00
spi-rpc-if.c spi: rpc-if: Add resume support for RZ/G3E 2025-09-22 09:21:18 +01:00
spi-rspi.c spi: rspi: Convert to DEFINE_SIMPLE_DEV_PM_OPS() 2025-07-10 09:16:15 +01:00
spi-rzv2h-rspi.c spi: rzv2h-rspi: add support for RZ/T2H and RZ/N2H 2025-11-24 14:10:48 +00:00
spi-rzv2m-csi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-s3c64xx.c spi: s3c64xx: Drop S3C2443 2025-09-08 16:22:15 +01:00
spi-sc18is602.c spi: sc18is602: Switch to generic firmware properties and drop of_match_ptr() 2024-12-02 00:32:30 +00:00
spi-sg2044-nor.c spi: sophgo: Fix incorrect use of bus width value macros 2025-11-18 23:15:11 +00:00
spi-sh-hspi.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-sh-msiof.c spi: sh-msiof: Convert to DEFINE_SIMPLE_DEV_PM_OPS() 2025-07-10 09:16:14 +01:00
spi-sh-sci.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-sh.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-sifive.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-slave-mt27xx.c spi: replace and remove 2024-09-30 22:43:40 +01:00
spi-slave-system-control.c spi: slave-system-control: switch to use spi_target_abort() 2024-09-10 12:41:38 +01:00
spi-slave-time.c spi: slave-time: switch to use spi_target_abort() 2024-09-10 12:41:37 +01:00
spi-sn-f-ospi.c spi: sn-f-ospi: Fix division by zero 2025-02-06 11:33:51 +00:00
spi-sprd-adi.c
spi-sprd.c spi: Remove redundant pm_runtime_mark_last_busy() calls 2025-07-05 00:50:32 +01:00
spi-st-ssc4.c spi: st: fix PM macros to use CONFIG_PM instead of CONFIG_PM_SLEEP 2025-08-21 13:14:10 +01:00
spi-stm32-ospi.c spi: stm32-ospi: Fix NULL vs IS_ERR() bug in stm32_ospi_get_resources() 2025-07-16 16:35:18 +01:00
spi-stm32-qspi.c spi: Remove redundant pm_runtime_mark_last_busy() calls 2025-07-05 00:50:32 +01:00
spi-stm32.c treewide: Remove redundant 2025-07-07 16:12:21 +01:00
spi-sun4i.c spi: spi-sun4i: fix early activation 2025-05-14 10:56:43 +02:00
spi-sun6i.c spi: sun6i: Support A523's SPI controllers 2025-12-22 09:00:50 +00:00
spi-sunplus-sp7021.c spi: sunplus: sp7021: Clean up coding style 2025-08-10 21:11:39 +01:00
spi-synquacer.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-tegra20-sflash.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-tegra20-slink.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-tegra114.c spi: tegra114: Use value to check for invalid delays 2025-05-08 10:32:40 +09:00
spi-tegra210-quad.c spi: tegra210-quad: Check hardware status on timeout 2025-11-04 16:48:55 +00:00
spi-test.h
spi-ti-qspi.c spi: Remove redundant pm_runtime_mark_last_busy() calls 2025-07-05 00:50:32 +01:00
spi-tle62x0.c spi: tle62x0: Add newline to sysfs attribute output 2025-10-30 13:08:11 +00:00
spi-topcliff-pch.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-uniphier.c Linux 6.12-rc2 2024-10-07 14:53:15 +01:00
spi-virtio.c SPI: Add virtio SPI driver 2025-09-22 09:29:30 +01:00
spi-wpcm-fiu.c spi: wpcm-fiu: Simplify with dev_err_probe() 2024-08-28 22:22:24 +01:00
spi-xcomm.c treewide: rename GPIO set callbacks back to their original names 2025-08-07 10:07:06 +02:00
spi-xilinx.c spi: xilinx: increase number of retries before declaring stall 2025-11-07 09:37:46 +00:00
spi-xlp.c spi: xlp: use 'time_left' variable with wait_for_completion_timeout() 2024-04-30 23:57:32 +09:00
spi-xtensa-xtfpga.c spi: Switch back to struct platform_driver::remove() 2024-09-30 01:12:23 +02:00
spi-zynq-qspi.c spi: spi-mem: Introduce a default ->exec_op() debug log 2025-03-20 12:37:11 +00:00
spi-zynqmp-gqspi.c spi: Remove redundant pm_runtime_mark_last_busy() calls 2025-07-05 00:50:32 +01:00
spi.c spi: Add TODO comment about ACPI GPIO setup 2025-11-10 14:03:53 +00:00
spidev.c spi: spidev: add compatible for arduino spi mcu interface 2025-11-20 17:22:39 +00:00