Repository navigation
arch/rp23xx: add bounded timeout to SPI DMA completion wait - #20587
Open
Sarthak-Pandey wants to merge 1 commit into
Open
Sarthak-Pandey wants to merge 1 commit into
Sarthak-Pandey wants to merge 1 commit into
Conversation
xiaoxiang781216
previously approved these changes
Oct 11, 2026
Sarthak-Pandey
force-pushed
the
fix/rp23xx-spi-dma-timeout
branch
from
October 11, 2026 17:42
92aa8e9 to
bd07013
Compare
xiaoxiang781216
approved these changes
Oct 11, 2026
The SPI DMA exchange path previously waited for completion with two untimed, uninterruptible semaphore waits (nxsem_wait_uninterruptible). If a DMA transfer never completes (e.g. stalled slave or bus glitch), the calling thread sleeps indefinitely. In network drivers like W5500 on SPI0 running from the LP work queue while holding net_lock, this causes the worker to hang permanently, wedging the whole network stack and blocking recovery handlers. This patch updates both ARM and RISC-V ports of rp23xx: - Switches to nxsem_tickwait_uninterruptible() with a transfer-size-derived timeout plus a safety margin. - On timeout, forcibly stops both DMA channels with rp23xx_dmastop(), disables SPI DMA in the control register, resets the semaphore count, drains leftover RX FIFO bytes, and logs an error to degrade gracefully instead of deadlocking. Fixes apache#19305 Signed-off-by: Sarthak Pandey <sarthak@email.com>
Sarthak-Pandey
force-pushed
the
fix/rp23xx-spi-dma-timeout
branch
from
October 12, 2026 04:32
bd07013 to
631c1ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #19305
The SPI DMA exchange path in
rp23xx_spi.cpreviously waited for DMA completion using two back-to-back untimed, uninterruptible semaphore waits (nxsem_wait_uninterruptible()). If a DMA transfer never completes (e.g. stalled slave device or bus glitch), the calling thread sleeps indefinitely without timeout.In network drivers such as W5500 Ethernet on SPI0 running from the LP work queue while holding
net_lock, this stalled wait causes the LP worker to sleep forever while holding the network lock, wedging the whole network stack (pinghangs, network shell commands block, and driver TX-timeout recovery cannot run).This patch addresses the issue for both ARM and RISC-V ports of rp23xx:
nxsem_tickwait_uninterruptible()and a dynamic timeout calculated from transfer size, SPI clock frequency, and a safety margin (100 ms).rp23xx_dmastop().SSPDMACR).nxsem_reset(&priv->dmasem, 0)) to avoid residual posts corrupting subsequent transfers.spierr()and returns instead of hanging forever.Impact
arch/arm/src/rp23xx/rp23xx_spi.c,arch/risc-v/src/rp23xx-rv/rp23xx_spi.c).net_lock, and run its TX timeout recovery handlers.Testing
nxstyle.