Pi 5 RP1: pio transer stuck when using channel dma2chan2
Describe the bug
Since 6.18.50, i am experiencing a problem when i run a slightly modified version of piotest on a Raspberry Pi 5: every 2nd run, the program hangs indefinitely inside rp1_pio_sm_xfer_data32_user() .
If i add print statements to piotest, the output shows that the for loop hangs on the second call to pio_sm_xfer_data from piolib:
timeout --signal=TERM --kill-after=5s 10s ./pio-reproducer/pio-build-piotest/examples/piotest 2
Loaded program at -1, using sm 1, gpio 2
transfer 0 BEGIN
transfer 0 END rc=0
transfer 1 BEGINIf i configure multiple buffers, for example 3 instead of 1: pio_sm_config_xfer(pio, sm, PIO_DIR_TO_SM, 2 * 1024 * 1024, 3);,
the program will get stuck at the 4th call to pio_sm_xfer_data.
Stacktrace shows that the program is stuck inside rp1_pio_sm_xfer_data32_user:
[<0>] rp1_pio_sm_xfer_data32_user+0x2c8/0x6a0 [rp1_pio]
[<0>] rp1_pio_sm_xfer_data_user+0x48/0x80 [rp1_pio]
[<0>] rp1_pio_ioctl+0x1a4/0x248 [rp1_pio]
[<0>] __arm64_sys_ioctl+0xb4/0x120
[<0>] invoke_syscall+0x4c/0x100
[<0>] el0_svc_common.constprop.0+0x48/0xf0
[<0>] do_el0_svc+0x24/0x38
[<0>] el0_svc+0x38/0x120
[<0>] el0t_64_sync_handler+0xa0/0xe8
[<0>] el0t_64_sync+0x198/0x1a0
=== /proc/2468/task/2469 ===
[<0>] rp1_pio_irq_wait+0x40/0xa8 [rp1_pio]
[<0>] rp1_pio_ioctl+0x1a4/0x248 [rp1_pio]
[<0>] __arm64_sys_ioctl+0xb4/0x120
[<0>] invoke_syscall+0x4c/0x100
[<0>] el0_svc_common.constprop.0+0x48/0xf0
[<0>] do_el0_svc+0x24/0x38
[<0>] el0_svc+0x38/0x120
[<0>] el0t_64_sync_handler+0xa0/0xe8
[<0>] el0t_64_sync+0x198/0x1a0Whenever the problem occurs, running cat /sys/kernel/debug/dmaengine/summary always shows that channel dma2chan2 is being used:
dma2 (1f00188000.dma): number of channels: 8
dma2chan2 | 1f00178000.pio:tx0Conversely, if the program runs without problems, it always uses dma2chan0.
After the successful run, the following logs appear (journalctl -kf -o short-monotonic):
[ 3346.002998] cpdis-2505-117 kernel: dma dma2chan0: dma2chan0 failed to stop
[ 3346.003394] cpdis-2505-117 kernel: dma dma2chan0: dma2chan0 is non-idle!Then during the second run, the program hangs and the logs show:
[ 3357.420030] cpdis-2505-117 kernel: dma dma2chan0: dma2chan0 is non-idle!
[ 3362.420028] cpdis-2505-117 kernel: rp1-pio 1f00178000.pio: DMA bounce interruptedIt seems that dma2chan0 cannot be stopped during the 1st run, after which dma2chan2 is selected during the 2nd run, but this channel never finishes. However dma2chan0 is stopped somehow during the 2nd run because on the 3rd run, the programs runs OK again.
I ran into this because i am controlling a led panel, using the hzeller lib. But the most basic way to reproduce the issue is to use a modified piotest without anything attached to the raspberrpy pi.
Steps to reproduce the behaviour
sudo apt update
sudo apt install git build-essential cmake
mkdir /tmp/pio-reproducer && cd pio-reproducer
git clone https://github.com/raspberrypi/utils.git rpi-utilsIn rpi-utils/piolib/examples/piotest.c, replace:
pio_sm_xfer_data(pio, sm, PIO_DIR_TO_SM, sizeof(databuf), databuf);with:
fprintf(stderr, "transfer %d BEGIN\n", pass + 1);
fflush(stderr);
pio_sm_xfer_data(pio, sm, PIO_DIR_TO_SM,
sizeof(databuf), databuf);
fprintf(stderr, "transfer %d END\n", pass + 1);
fflush(stderr);and replace:
const uint pixels = 60;
.
.
pio_sm_config_xfer(pio, sm, PIO_DIR_TO_SM, 256, 1);with:
const uint pixels = 6144;
.
.
pio_sm_config_xfer(pio, sm, PIO_DIR_TO_SM,
2 * 1024 * 1024, 1);Build and run:
cmake -S rpi-utils/piolib -B pio-build-piotest \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_SHARED_LIBS=OFF
cmake --build pio-build-piotest --target piotest -j2
sudo timeout --signal=TERM --kill-after=5s 10s \
./pio-build-piotest/examples/piotest 2With this program i can reproduce the issue every second time i run it. Even taking longer pauses between runs (30 seconds) does not resolve the issue.
After the successful run, the following logs appear (journalctl -kf -o short-monotonic):
[ 3346.002998] cpdis-2505-117 kernel: dma dma2chan0: dma2chan0 failed to stop
[ 3346.003394] cpdis-2505-117 kernel: dma dma2chan0: dma2chan0 is non-idle!Then during the second run, the program hangs and the logs show:
[ 3357.420030] cpdis-2505-117 kernel: dma dma2chan0: dma2chan0 is non-idle!
[ 3362.420028] cpdis-2505-117 kernel: rp1-pio 1f00178000.pio: DMA bounce interruptedThe third run will be ok, with logs as in the first run. During the fourth run the problem occurs again. And so on and so forth.
The issue can be reproduced with the original piotest, but it occurs far less often, usually every 50th time or so. I tried two different raspberry's, same issue.
Device (s)
Raspberry Pi 5
System
Raspberry Pi 5 Model B Rev 1.1 PRETTY_NAME="Debian GNU/Linux 13 (trixie)" NAME="Debian GNU/Linux" VERSION_ID="13" VERSION="13 (trixie)"
Raspberry Pi reference 2026-04-21 Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 4ad56cc850fa60adcc7f07dc15879bc95cc1d281, stage2
Linux cpdis-2505-122 6.18.50+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.18.50-1+rpt1 (2026-09-11) aarch64 GNU/Linux Revision : d04171 Serial : 935509188ec7e445 Model : Raspberry Pi 5 Model B Rev 1.1 Throttled flag : throttled=0x0 . . [ 0.000000] Linux version 6.18.50+rpt-rpi-2712 ([email protected]) (aarch64-linux-gnu-gcc-14 (Debian 14.2.0-19) 14.2.0, GNU ld (GNU Binutils for Debian) 2.44) #1 SMP PREEMPT Debian 1:6.18.50-1+rpt1 (2026-09-11)
Logs
No response
Additional context
No response
Source: raspberrypi/linux