summaryrefslogtreecommitdiff
path: root/drivers/spi
AgeCommit message (Collapse)Author
2026-01-06spi: stm32-qspi: avoid __maybe_unused and use pm_ptrAlain Volmat
Switch to usage of pm_ptr / SYSTEM_SLEEP_PM_OPS / RUNTIME_PM_OPS in order to avoid having to mark the pm related functions as __maybe_unused. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://patch.msgid.link/20260106-spi_st_maybe_unused_removal-v1-3-8f5ca7136e96@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2026-01-06spi: stm32-ospi: avoid __maybe_unused and use pm_ptrAlain Volmat
Switch to usage of pm_ptr / SYSTEM_SLEEP_PM_OPS / RUNTIME_PM_OPS in order to avoid having to mark the pm related functions as __maybe_unused. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://patch.msgid.link/20260106-spi_st_maybe_unused_removal-v1-2-8f5ca7136e96@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2026-01-06spi: st: remove __maybe_unused for suspend/resumeAlain Volmat
Remove useless __maybe_unused statements for suspend and resume functions since this is now used via pm_ptr. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://patch.msgid.link/20260106-spi_st_maybe_unused_removal-v1-1-8f5ca7136e96@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2026-01-05spi: change of_find_spi_controller_by_node() gating to CONFIG_OFOder Chiou
Currently, the helper of_find_spi_controller_by_node() is gated under CONFIG_OF_DYNAMIC. This prevents drivers from using it in all CONFIG_OF configurations. This patch moves the gating to CONFIG_OF, keeping the inline fallback returning NULL when Device Tree support is disabled. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Link: https://patch.msgid.link/6d8ae977d9f4726ea23ad5382638750593f9a2e4.1767148150.git.oder_chiou@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2026-01-05spi: export of_find_spi_controller_by_node()Oder Chiou
Some devices are primarily described on another bus (e.g. I2C) but also have an additional SPI connection that serves as a transport for firmware loading. Export of_find_spi_controller_by_node() so drivers can obtain the SPI controller referenced by a DT phandle. Signed-off-by: Oder Chiou <oder_chiou@realtek.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/0e572a00aa305e588357162d400ba9472ce56dd3.1767148150.git.oder_chiou@realtek.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-23spi: cadence-quadspi: Prevent indirect readMark Brown
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-23spi: cadence-quadspi: Improve CQSPI_SLOW_SRAM quirk if flash is slowMateusz Litwin
CQSPI_SLOW_SRAM quirk on the Stratix10 platform causes fewer interrupts, but also causes timeouts if a small block is used or if flash devices are slower than or equal in speed to SRAM's read operations. Adding the CQSPI_REG_IRQ_IND_COMP interrupt would resolve the problem for small reads, and removing the disabling of interrupts would resolve the issue with lost interrupts. This marginally increases IRQ count. Tests show that this will cause only a few percent more interrupts. 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 commit: 224 528 Signed-off-by: Mateusz Litwin <mateusz.litwin@nokia.com> Link: https://patch.msgid.link/20251218-cqspi_indirect_read_improve-v2-2-396079972f2a@nokia.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-23spi: cadence-quadspi: Prevent lost complete() call during indirect readMateusz Litwin
A race condition exists between the read loop and IRQ `complete()` call. An interrupt could call the complete() between the inner loop and reinit_completion(), potentially losing the completion event and causing an unnecessary timeout. Moving reinit_completion() before the loop prevents this. A premature signal will only result in a spurious wakeup and another wait cycle, which is preferable to waiting for a timeout. Signed-off-by: Mateusz Litwin <mateusz.litwin@nokia.com> Link: https://patch.msgid.link/20251218-cqspi_indirect_read_improve-v2-1-396079972f2a@nokia.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-23spi: bcm63xx-hsspi: add support for 1-2-2 read opsJonas Gorski
Add support for 1-2-2 read ops by separately calculating the switch from single-bit to multi-bit, and then switching within the prepend data. This allows us to support single-bit write followed by multi-bit write followed by multi-bit read, and we do not need to reject 1-2-2 read operations anymore. Tested on BCM963268BU_P300 with custom fixup to allow 1-2-2 on the non-SDFP capable s25fl129p1 attached (which it actually supports): root@OpenWrt:~# cat /sys/kernel/debug/spi-nor/spi1.0/params name s25fl129p1 id 01 20 18 4d 01 01 size 16.0 MiB write size 1 page size 256 address nbytes 3 flags HAS_16BIT_SR | NO_READ_CR opcodes read 0xbb dummy cycles 4 erase 0xd8 program 0x02 8D extension none protocols read 1S-2S-2S write 1S-1S-1S register 1S-1S-1S Reading from flash is still working as expected: [ 1.070000] parser_imagetag: rootfs: CFE image tag found at 0x0 with version 6, board type 963168VX [ 1.080000] parser_imagetag: Partition 0 is rootfs offset 100 and length 665000 [ 1.090000] parser_imagetag: Partition 1 is kernel offset 665100 and length 136fa1 [ 1.100000] parser_imagetag: Spare partition is offset 7b0000 and length 30000 Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Acked-by: William Zhang <william.zhang@broadcom.com> Tested-by: David Regan <dregan@broadcom.com> Link: https://patch.msgid.link/20251217211026.173946-1-jonas.gorski@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-22spi: sun6i: Support A523's SPI controllersChen-Yu Tsai
The A523 has four SPI controllers. One of them supports MIPI DBI mode in addition to standard SPI. Compared to older generations, this newer controller now has a combined counter for the RX FIFO ad buffer levels. In older generations, the RX buffer level was a separate bitfield in the FIFO status register. In practice this difference is negligible. The buffer is mostly invisible to the implementation. If programmed I/O transfers are limited to the FIFO size, then the contents of the buffer seem to always be flushed over to the FIFO. For DMA, the DRQ trigger levels are only tied to the FIFO levels. In all other aspects, the controller is the same as the one in the R329. Support the standard SPI mode controllers using the settings for R329. DBI is left out as there currently is no infrastructure for enabling a DBI host controller, as was the case for the R329. Also fold the entry for the R329 to make the style consistent. Signed-off-by: Chen-Yu Tsai <wens@kernel.org> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://patch.msgid.link/20251221110513.1850535-3-wens@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-19spi: stm32: stability & performance enhancementsMark Brown
Merge series from Alain Volmat <alain.volmat@foss.st.com>: The series fixes a stability issue when dealing with <8bpw transfers, as well as enforce an error if the DMA information provided within the DT are incorrect. Performance enhancement is also provided by allowing a polling mode which is triggered when the transfer is so short that polling mode transfer would lead to faster transfer than if it was done in a interrupt driven manner.
2025-12-18spi: stm32: perform small transfer in polling modeAlain Volmat
In case of interrupt based transfer, when the transfer is very small, relying on interrupts leads to lower performances than if the transfer were done using polling on the registers. Add a module parameter "polling_limit_us" to indicate the threshold in us from which a transfer would be done polling the registers rather than relying on interrupts. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://patch.msgid.link/20251218-stm32-spi-enhancements-v2-3-3b69901ca9fe@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-18spi: stm32: fix Overrun issue at < 8bpwDeepak Kumar
When SPI communication is suspended by hardware automatically, it could happen that few bits of next frame are already clocked out due to internal synchronization delay. To achieve a safe suspension, we need to ensure that each word must be at least 8 SPI clock cycles long. That's why, if bpw is less than 8 bits, we need to use midi to reach 8 SPI clock cycles at least. This will ensure that each word achieve safe suspension and prevent overrun condition. Signed-off-by: Deepak Kumar <deepak.kumar01@st.com> Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://patch.msgid.link/20251218-stm32-spi-enhancements-v2-2-3b69901ca9fe@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-18spi: stm32: properly fail on dma_request_chan errorAlain Volmat
Correct handling of the dma_request_chan call in order to avoid misleading warn message if no DMA is provided within the device-tree and moreover fail if dma_request_chan has returned a valid error. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Link: https://patch.msgid.link/20251218-stm32-spi-enhancements-v2-1-3b69901ca9fe@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-18spi: atcspi200: Add support for Andes ATCSPI200 SPIMark Brown
Merge series from CL Wang <cl634@andestech.com>: This series adds support for the Andes ATCSPI200 SPI controller.
2025-12-18spi: cadence-quadspi: Fix probe error path and loggingMark Brown
Merge series from Anurag Dutta <a-dutta@ti.com>: 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
2025-12-18Add support for NXP XSPIMark Brown
Merge series from Haibo Chen <haibo.chen@nxp.com>: XSPI is a flexible SPI host controller which supports up to 2 external devices (2 CS). It support Single/Dual/Quad/Octal mode data transfer. The difference between XSPI and Flexspi is XSPI support multiple independent execution environments (EENVs) for HW virtualization with some limitations. Each EENV has its own interrupt and its own set of programming registers that exists in a specific offset range in the XSPI memory map. The main environment (EENV0) address space contains all of the registers for controlling EENV0 plus all of the general XSPI control and programming registers. The register mnemonics for the user environments (EENV1 to EENV4) have "_SUB_n" appended to the mnemonic for the corresponding main-environment register. Current driver based on EENV0, which means system already give EENV0 right to linux. This driver use SPI memory interface of the SPI framework to issue flash memory operations. Tested this driver with mtd_debug and UBIFS on NXP i.MX943 EVK board which has one MT35XU512ABA spi nor flash. NOw this driver has the following key features: - Support up to OCT DDR mode - Support AHB read - Support IP read and IP write - Support two CS
2025-12-17spi: stm32-qspi: Remove unneeded semicolonChen Ni
Remove unnecessary semicolons reported by Coccinelle/coccicheck and the semantic patch at scripts/coccinelle/misc/semicolon.cocci. Signed-off-by: Chen Ni <nichen@iscas.ac.cn> Link: https://patch.msgid.link/20251217023721.1684244-1-nichen@iscas.ac.cn Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-17spi: stm32-ospi: Remove unneeded semicolonChen Ni
Remove unnecessary semicolons reported by Coccinelle/coccicheck and the semantic patch at scripts/coccinelle/misc/semicolon.cocci. Signed-off-by: Chen Ni <nichen@iscas.ac.cn> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251216043210.1521722-1-nichen@iscas.ac.cn Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-17spi: atcspi200: Add ATCSPI200 SPI controller driverCL Wang
Add driver for the Andes ATCSPI200 SPI controller. Signed-off-by: CL Wang <cl634@andestech.com> Link: https://patch.msgid.link/20251215132349.513843-3-cl634@andestech.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-17spi: add driver for NXP XSPI controllerHaibo Chen
Add driver support for NXP XSPI controller. XSPI is a flexible SPI host controller which supports up to 2 external devices (2 CS). It support Single/Dual/Quad/Octal mode data transfer. The difference between XSPI and Flexspi: 1.the register layout is total different. 2.XSPI support multiple independent execution environments (EENVs) for HW virtualization with some limitations. Each EENV has its own interrupt and its own set of programming registers that exists in a specific offset range in the XSPI memory map. The main environment (EENV0) address space contains all of the registers for controlling EENV0 plus all of the general XSPI control and programming registers. The register mnemonics for the user environments (EENV1 to EENV4) have "_SUB_n" appended to the mnemonic for the corresponding main-environment register. Current driver based on EENV0, which means system already give EENV0 right to linux. This driver use SPI memory interface of the SPI framework to issue flash memory operations. Tested this driver with UBIFS and mtd_debug on NXP i.MX943 EVK board which has one spi nor MT35XU512ABA flash. Now this driver has the following key features: - Support up to OCT DDR mode - Support AHB read - Support IP read and IP write - Support two CS Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Link: https://patch.msgid.link/20251216-xspi-v7-2-282525220979@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-17spi: mt65xx: Use IRQF_ONESHOT with threaded IRQFei Shao
This driver is migrated to use threaded IRQ since commit 5972eb05ca32 ("spi: spi-mt65xx: Use threaded interrupt for non-SPIMEM transfer"), and we almost always want to disable the interrupt line to avoid excess interrupts while the threaded handler is processing SPI transfer. Use IRQF_ONESHOT for that purpose. In practice, we see MediaTek devices show SPI transfer timeout errors when communicating with ChromeOS EC in certain scenarios, and with IRQF_ONESHOT, the issue goes away. Signed-off-by: Fei Shao <fshao@chromium.org> Link: https://patch.msgid.link/20251217101131.1975131-1-fshao@chromium.org Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-17spi: cadence-quadspi: Fix clock disable on probe failure pathAnurag 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> Tested-by: Nishanth Menon <nm@ti.com> Link: https://patch.msgid.link/20251212072312.2711806-3-a-dutta@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-17spi: cadence-quadspi: Add error logging for DMA request failureAnurag 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> Link: https://patch.msgid.link/20251212072312.2711806-2-a-dutta@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-15Add DMA support for RZ/T2H RSPIMark Brown
Merge series from Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>: The DMA controller can be used to transfer data to and from the SPI controller without involving the CPU for each word of a SPI transfer. Add support for DMA mode, and do some other cleanups while touching the same code.
2025-12-15Support ECSPI dynamic burst feature for DMA modeMark Brown
Merge series from Carlos Song <carlos.song@nxp.com>: ECSPI has a low throughput because of no dynamic burst support, it transfers only one word per frame in DMA mode, causing SCLK stalls between words due to BURST_LENGTH updates. This patch set is to support ECSPI dynamic burst feature to help improve the ECSPI DMA mode performance. Performance test (spidev_test @10MHz, 4KB): Before: tx/rx ~6651.9 kbps After: tx/rx ~9922.2 kbps (~50% improvement) For compatibility with slow SPI devices, add configurable word delay in DMA mode. When word delay is set, dynamic burst is disabled and BURST_LENGTH equals word length. Also support target DMA mode with enabled dynamic burst. --- Changes since v2: * Patch1~4: no change * Patch5: remove __counted_by from *dma_data, because spi_imx struct is allocated with a fixed memory in probe, flexible array is not suitable, so just remove it to avoid the build error. Also add review-by tag * Patch6: add review-by tag Changes since v1: * Patch1~3: * Add review-by tag * Patch4: * Add review-by tag * Improve patch commit log * Patch5: * Clean up tab instead of space for dma_tx_addr and dma_rx_addr * Add __counted_by(dma_package_num) for dma_data_package *dma_data * Move temp and bytes_per_word to if() * Add comment for spi_imx_dma_rx_data_handle() and spi_imx_dma_tx_data_handle() * Use kzalloc instead of kmalloc(x, x | __GFP_ZERO) * Use sizeof(*temp) instead of BYTES_PER_32BITS_WORD in suitable place * Add comments and fix comments according to discussion * Propagate the error value of dma_mapping_error() * Use round_down() to replace DIV_ROUND_DOWN_ULL() * Improve transfer->error |= SPI_TRANS_FAIL_NO_START judgment for better readability * Patch6: * Improve patch commit log * Add READ_ONCE for spi_imx->target_aborted * Add comments for data length limit * Move data length limit to spi_imx_can_dma() Carlos Song (6): spi: imx: group spi_imx_dma_configure() with spi_imx_dma_transfer() spi: imx: introduce helper to clear DMA mode logic spi: imx: avoid dmaengine_terminate_all() on TX prep failure spi: imx: handle DMA submission errors with dma_submit_error() spi: imx: support dynamic burst length for ECSPI DMA mode spi: imx: enable DMA mode for target operation drivers/spi/spi-imx.c | 625 +++++++++++++++++++++++++++++++++++------- 1 file changed, 519 insertions(+), 106 deletions(-) -- 2.34.1
2025-12-15spi: stm32: Update for OSPI and QSPI driversMark Brown
Merge series from Patrice Chotard <patrice.chotard@foss.st.com>: This serie applies the following updates on the spi-stm32-ospi and spi-stm32-qspi dirvers : _ Update FIFO accesses using u16 and u32 when possible instead of u8 only to optimize throughput. _ Replace Transmit Complete and Transmit Error interrupt management by usage of read_poll_timeout_atomic() to optimize throughtput. _ Simplify Status Match interrupt check. _ Set DMA burst configuration dynamically. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> --- Changes in v2: - Fix compilation error in stm32_ospi_wait_cmd() - Link to v1: https://lore.kernel.org/r/20251205-upstream_qspi_ospi_updates-v1-0-7e6c8b9f5141@foss.st.com --- Patrice Chotard (8): spi: stm32-ospi: Set DMA maxburst dynamically spi: stm32-ospi: Optimize FIFO accesses using u16 or u32 spi: stm32-ospi: Remove CR_TCIE and CR_TEIE irq usage spi: stm32-ospi: Simplify SMIE interrupt test spi: stm32-qspi: Set DMA maxburst dynamically spi: stm32-qspi: Optimize FIFO accesses using u16 or u32 spi: stm32-qspi: Remove CR_TCIE and CR_TEIE irq usage spi: stm32-qspi: Simplify SMIE interrupt test drivers/spi/spi-stm32-ospi.c | 107 +++++++++++++++++++++++++---------------- drivers/spi/spi-stm32-qspi.c | 111 +++++++++++++++++++++++++------------------ 2 files changed, 132 insertions(+), 86 deletions(-) --- base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 change-id: 20251205-upstream_qspi_ospi_updates-4faf7a3b098c Best regards, -- Patrice Chotard <patrice.chotard@foss.st.com>
2025-12-14spi: spi-fsl-lpspi: convert min_t() to simple min()Carlos Song
Current min() has supported comparison by normal integer promotion rules, so explicit type casts or min_t() are not needed. Signed-off-by: Carlos Song <carlos.song@nxp.com> Reviewed-by: David Laight <david.laight.linux@gmail.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251210105001.3891776-1-carlos.song@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: virtio: Fix confusing cleanup.h syntaxKrzysztof Kozlowski
Initializing automatic __free variables to NULL without need (e.g. branches with different allocations), followed by actual allocation is in contrary to explicit coding rules guiding cleanup.h: "Given that the "__free(...) = NULL" pattern for variables defined at the top of the function poses this potential interdependency problem the recommendation is to always define and assign variables in one statement and not group variable definitions at the top of the function when __free() is used." Code does not have a bug, but is less readable and uses discouraged coding practice, so fix that by moving declaration to the place of assignment. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20251208020830.5225-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: cadence-quadspi: Parse DT for flashes with the rest of the DT parsingMark Brown
The recent refactoring of where runtime PM is enabled done in commit f1eb4e792bb1 ("spi: spi-cadence-quadspi: Enable pm runtime earlier to avoid imbalance") made the fact that when we do a pm_runtime_disable() in the error paths of probe() we can trigger a runtime disable which in turn results in duplicate clock disables. This is particularly likely to happen when there is missing or broken DT description for the flashes attached to the controller. Early on in the probe function we do a pm_runtime_get_noresume() since the probe function leaves the device in a powered up state but in the error path we can't assume that PM is enabled so we also manually disable everything, including clocks. This means that when runtime PM is active both it and the probe function release the same reference to the main clock for the IP, triggering warnings from the clock subsystem: [ 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/0xb ... [ 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 Dealing with this issue properly is complicated by the fact that we don't know if runtime PM is active so can't tell if it will disable the clocks or not. We can, however, sidestep the issue for the flash descriptions by moving their parsing to when we parse the controller properties which also save us doing a bunch of setup which can never be used so let's do that. Reported-by: Francesco Dolcini <francesco@dolcini.it> Closes: https://lore.kernel.org/r/20251201072844.GA6785@francesco-nb Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://patch.msgid.link/20251204-spi-cadence-qspi-runtime-pm-imbalance-v2-1-10af9115d531@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: spi-qpic-snand: remove superfluous qcom_spi_set_read_loc() callsGabor Juhos
Before configuring the registers related to page read, both the qcom_spi_read_page_ecc() and the qcom_spi_read_page_oob() functions are calling qcom_spi_set_read_loc() to set the read location for the first codeword. However the qcom_spi_set_read_loc() function puts the passed value into the register write cache only, from where those gets written to the corresponding register later via DMA. Yet, the qcom_spi_set_read_loc() is also gets called within the internal loops, and during the first iteration the read location register values written by the initial call gets overwritten in the register cache. This means that the values written by the first calls are never getting used in practice, so remove the calls as those are superfluous. Signed-off-by: Gabor Juhos <j4g8y7@gmail.com> Link: https://patch.msgid.link/20251129-qpic-snand-superfluous-readloc-v1-1-b84ca17095d9@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi-geni-qcom: rework setup_fifo_paramsJonathan Marek
Update each register only if it changes. This also fixes the chipselect related registers not being changed when chipselect changes but not the mode. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Link: https://patch.msgid.link/20251120211204.24078-5-jonathan@marek.ca Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi-geni-qcom: initialize mode related registers to 0Jonathan Marek
setup_fifo_params assumes these will be zero, it won't write these registers if the initial mode is zero. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Link: https://patch.msgid.link/20251120211204.24078-4-jonathan@marek.ca Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi-geni-qcom: use xfer->bits_per_word for can_dma()Jonathan Marek
mas->cur_bits_per_word may not reflect the value of xfer->bits_per_word when can_dma() is called. Use the right value instead. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Link: https://patch.msgid.link/20251120211204.24078-3-jonathan@marek.ca Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi-geni-qcom: don't set max clock in setup_fifo_paramsJonathan Marek
setup_se_xfer() already sets the correct clock (xfer->speed_hz). Setting the clock to max_speed_hz here makes the driver change the clock rate between speed_hz and max_speed_hz for every message (if not equal), slowing it down significantly. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Link: https://patch.msgid.link/20251120211204.24078-2-jonathan@marek.ca Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi-geni-qcom: remove manual CS controlJonathan Marek
The GPI_DMA mode already uses automatic CS control, to use automatic CS control for non-GPI case all that's needed is to set the FRAGMENTATION flag using the same logic as setup_gsi_xfer(). (note clearing SPI_TRANS_CFG's CS_TOGGLE bit enables automatic CS control, the comment was wrong) spi_geni_set_cs() is slow, so this is a big performance improvement. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Link: https://patch.msgid.link/20251120211204.24078-1-jonathan@marek.ca Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: cadence-qspi: Remove redundant pm_runtime_mark_last_busy callAkif Ejaz
The pm_runtime_mark_last_busy() call is redundant in probe function as pm_runtime_put_autosuspend() already calls pm_runtime_mark_last_busy() internally to update the last access time of the device before queuing autosuspend. Remove the pm_runtime_mark_last_busy() call from the probe function. Tested on StarFive VisionFive 2 v1.2A board. Fixes: e1f2e77624db ("spi: cadence-qspi: Fix runtime PM imbalance in probe") Signed-off-by: Akif Ejaz <akifejaz40@gmail.com> Link: https://patch.msgid.link/20251203181921.97171-1-akifejaz40@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: cadence-xspi: Replace OF/ACPI specifics by agnostic APIsAndy Shevchenko
Replace OF/ACPI specific call to get matched driver data with the agnostic one. This doesn't change functionality. While at it, add missing property.h include, and drop now unneeded of.h. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20251129150704.3998301-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: cadence-xspi: Replace ACPI specifics by agnostic APIsAndy Shevchenko
Replace ACPI specific calls to get device property with the agnostic one. The code looses the direct dependency to the ACPI APIs and get cleaner. This doesn't change functionality. While at it, drop now unneeded acpi.h. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20251129151739.3998668-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-qspi: Simplify SMIE interrupt testPatrice Chotard
SR_SMF status bit can only be set if CR_SMIE was previously set, keep status bit check only. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-8-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-qspi: Remove CR_TCIE and CR_TEIE irq usagePatrice Chotard
Replace CR_TCIE and CR_TEIE irq usage by a read_poll_timeout_atomic() in stm32_qspi_wait_cmd(). It will reduce the time waiting for TCF or TEF flags to optimize throughput. before after average time spent in stm32_qspi_wait_cmd: 2615 ns 712 ns Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-7-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-qspi: Optimize FIFO accesses using u16 or u32Patrice Chotard
FIFO accesses uses u8 only for read/write. In order to optimize throughput, add u16 or u32 read/write accesses when possible. Running mtd_speedtest on a 4MB sNOR partition using a stm32mp257f-ev1 board gives the following results: before after gain Read : 5773 KiB/s 22170 KiB/s 384% Write: 796 KiB/s 890 KiB/s 12% Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-6-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-qspi: Set DMA maxburst dynamicallyPatrice Chotard
Set src_maxburst and dst_maxburst dynamically from DMA capabilities. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-5-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-ospi: Simplify SMIE interrupt testPatrice Chotard
SR_SMF status bit can only be set if CR_SMIE was previously set, keep status bit check only. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-4-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-ospi: Remove CR_TCIE and CR_TEIE irq usagePatrice Chotard
Replace CR_TCIE and CR_TEIE irq usage by a read_poll_timeout_atomic() in stm32_ospi_wait_cmd(). It will reduce the time waiting for TCF or TEF flags to optimize throughput. before after average time spent in stm32_omi_wait_cmd: 5685 ns 923 ns Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-3-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-ospi: Optimize FIFO accesses using u16 or u32Patrice Chotard
FIFO accesses uses u8 only for read/write. In order to optimize throughput, add u16 or u32 read/write accesses when possible. Running mtd_speedtest on a 4MB sNOR partition using a stm32mp257f-ev1 board gives the following results: before after gain Read : 5693 KiB/s 21139 KiB/s 371% Write: 765 KiB/s 910 KiB/s 19% Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-2-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: stm32-ospi: Set DMA maxburst dynamicallyPatrice Chotard
Set src_maxburst and dst_maxburst dynamically from DMA capabilities. Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com> Link: https://patch.msgid.link/20251208-upstream_qspi_ospi_updates-v2-1-62526c9467dc@foss.st.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: imx: enable DMA mode for target operationCarlos Song
Enable DMA mode for SPI IMX in target mode. Disable the word delay feature for target mode, because target mode should always keep high performance to make sure it can follow the master. Target mode continues to operate in dynamic burst mode. Signed-off-by: Carlos Song <carlos.song@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251203085949.2922166-7-carlos.song@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: imx: support dynamic burst length for ECSPI DMA modeCarlos Song
ECSPI transfers only one word per frame in DMA mode, causing SCLK stalls between words due to BURST_LENGTH updates, which significantly impacts performance. To improve throughput, configure BURST_LENGTH as large as possible (up to 512 bytes per frame) instead of word length. This avoids delays between words. When transfer length is not 4-byte aligned, use bounce buffers to align data for DMA. TX uses aligned words for TXFIFO, while RX trims DMA buffer data after transfer completion. Introduce a new dma_package structure to store: 1. BURST_LENGTH values for each DMA request 2. Variables for DMA submission 3. DMA transmission length and actual data length Handle three cases: - len <= 512 bytes: one package, BURST_LENGTH = len * 8 - 1 - len > 512 and aligned: one package, BURST_LENGTH = max (512 bytes) - len > 512 and unaligned: two packages, second for tail data Performance test (spidev_test @10MHz, 4KB): Before: tx/rx ~6651.9 kbps After: tx/rx ~9922.2 kbps (~50% improvement) For compatibility with slow SPI devices, add configurable word delay in DMA mode. When word delay is set, dynamic burst is disabled and BURST_LENGTH equals word length. Signed-off-by: Carlos Song <carlos.song@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251203085949.2922166-6-carlos.song@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-12-14spi: imx: handle DMA submission errors with dma_submit_error()Carlos Song
Add error handling for DMA request submission by checking the return cookie with dma_submit_error(). This prevents propagating submission failures through the DMA transfer process, which could lead to unexpected behavior. Signed-off-by: Carlos Song <carlos.song@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251203085949.2922166-5-carlos.song@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>