sdhci: fix SDMA boundary bug
cover sdhci: fix SDMA boundary bug
Hi all,
Booting Linux from SD card on Xilinx Zynq with SDMA (MMC_SDHCI_SDMA=y) currently hangs during image load.
This patch fixes the hang and enables successful image loading.
Thanks!
Tao Ding (1):
fixed sdma boundary bug
hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)
base-commit: 608ad9307d5b4797d2254ee3a4bad2bc8c8bcbae
Signature · 1 line
2.43.0
PATCH 1/1 fixed sdma boundary bug
During SDMA transfers, the controller raises an interrupt at buffer boundaries to request a system address update. But the emulation fails to clear the SDHC_DOING_READ/WRITE flags after DMA completion, so writes to SDHC_SYSAD are ignored. Clear these flags when the transfer ends.
(according to PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf section 2.2.1)
This is a QTest in npcm7xx_sdhci-test that exercises this boundary condition and validates the fix.
QTest steps:
1. Replace npcm7xx_sdhci-test.c with the updated version (full code available at: https://pastebin.com/AWVp2wFi).
2. Build with:
../configure --target-list="arm-softmmu,aarch64-softmmu" \
--disable-slirp --enable-debug --disable-werror
ninja qemu-system-arm tests/qtest/npcm7xx_sdhci-test
3. Run the specific test case:
QTEST_QEMU_BINARY=./qemu-system-arm \
./tests/qtest/npcm7xx_sdhci-test \
-p /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueBefore the fix, the test fails with a BLKCNT assertion:
ERROR:...wait_for_block_count: assertion failed (qtest_readw(...) == expected): (1 == 0)
After applying the fix, the test passes:
ok 1 /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continue
The new test case ensures the SDMA boundary handling works correctly and prevents future regressions.
Uboot test:
1. Prepare zImage, uboot and rootfs.cpio.gz, make sure uboot config (MMC_SDHCI_SDMA=y).
2. ./qemu-system-aarch64 -M xilinx-zynq-a9 -machine boot-mode=sd -m 1024 -display none -serial null -serial stdio -monitor none \
-device loader,file=u-boot-dtb.bin,addr=0x04000000,cpu-num=0 \
-drive file=zynq-sd.img,format=raw,if=sd -D qemu.log
After applying the fix, success load sd card:
U-Boot 2026.07-rc4-g1e80ee41441c (Jun 15 2026 - 19:05:05 +0800)
Model: Xilinx ZC702 board DRAM: ECC disabled 1 GiB Core: 33 devices, 21 uclasses, devicetree: board Flash: 0 Bytes NAND: 0 MiB MMC: mmc@e0100000: 0
Loading Environment from FAT... *** Error - No Valid Environment Area found *** Warning - bad env area, using default environment
In: serial@e0001000 Out: serial@e0001000 Err: serial@e0001000
Net:
ZYNQ GEM: e000b000, mdio bus e000b000, phyaddr 7, interface rgmii-id
Warning: ethernet@e000b000 (eth0) using random MAC address - 4a:63:5a:a4:d3:6b
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Zynq> fatload mmc 0 ${kernel_addr_r} zImage
10838528 bytes read in 4316 ms (2.4 MiB/s)
Zynq> fatload mmc 0 ${ramdisk_addr_r} rootfs-arm32.cpio.gz
406531 bytes read in 199 ms (1.9 MiB/s)
Zynq> setenv ramdisk_size ${filesize}
Zynq> fatload mmc 0 ${fdt_addr_r} zynq-zc702.dtb
15754 bytes read in 21 ms (732.4 KiB/s)
Zynq> setenv bootargs console=ttyPS0,115200 earlycon ignore_loglevel rdinit=/init Zynq> bootz ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} Kernel image @ 0x2000000 [ 0x000000 - 0xa56200 ]
## Flattened Device Tree blob at 01f00000
Booting using the fdt blob at 0x1f00000
Working FDT set to 1f00000
Loading Ramdisk to 2ff9c000, end 2ffff403 ... OK
Loading Device Tree to 2ff95000, end 2ff9bd89 ... OK
Working FDT set to 2ff95000
Starting kernel ...
--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)
hw/sd/sdhci.c +2 -0
@@ -644,6 +644,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->data_count =0 ; }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_READ ;break ; } }
@@ -669,6 +670,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) } }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_WRITE ;break ; } }
Signature · 1 line
2.43.0
Re: [PATCH 1/1] fixed sdma boundary bug
Quoted 25 lines · Tao Ding
During SDMA transfers, the controller raises an interrupt at buffer boundaries to request a system address update. But the emulation fails to clear the SDHC_DOING_READ/WRITE flags after DMA completion, so writes to
SDHC_SYSADare ignored. Clear these flags when the transfer ends.
(according to PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf section 2.2.1)This is a QTest in npcm7xx_sdhci-test that exercises this boundary condition and validates the fix.
QTest steps:
1. Replacenpcm7xx_sdhci-test.cwith the updated version (full code available at: https://pastebin.com/AWVp2wFi).
2. Build with:../configure --target-list="arm-softmmu,aarch64-softmmu" \ --disable-slirp --enable-debug --disable-werror ninja qemu-system-arm tests/qtest/npcm7xx_sdhci-test 3. Run the specific test case: QTEST_QEMU_BINARY=./qemu-system-arm \ ./tests/qtest/npcm7xx_sdhci-test \ -p /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueBefore the fix, the test fails with a BLKCNT assertion:
ERROR:...wait_for_block_count: assertion failed (qtest_readw(...)== expected): (1 == 0)
Quoted 8 lines
After applying the fix, the test passes:
ok 1 /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueThe new test case ensures the SDMA boundary handling works correctly and prevents future regressions.
Uboot test:
U-Boot
Quoted 1 line
1. Prepare zImage, uboot and rootfs.cpio.gz, make sure uboot config (MMC_SDHCI_SDMA=y).
Please specify which U-Boot defconfig you used for testing and how zynq-sd.img was generated.
Quoted 66 lines
2. ./qemu-system-aarch64 -M xilinx-zynq-a9 -machine boot-mode=sd -m 1024 -display none -serial null -serial stdio -monitor none \
-device loader,file=u-boot-dtb.bin,addr=0x04000000,cpu-num=0 \
-drive file=zynq-sd.img,format=raw,if=sd -D qemu.logAfter applying the fix, success load sd card:
U-Boot 2026.07-rc4-g1e80ee41441c (Jun 15 2026 - 19:05:05 +0800)
Model: Xilinx ZC702 board DRAM: ECC disabled 1 GiB Core: 33 devices, 21 uclasses, devicetree: board Flash: 0 Bytes NAND: 0 MiB MMC: mmc@e0100000: 0Loading Environment from FAT... *** Error - No Valid Environment Area found *** Warning - bad env area, using default environment
In: serial@e0001000 Out: serial@e0001000 Err: serial@e0001000Net:
ZYNQ GEM:e000b000, mdio buse000b000, phyaddr 7, interface rgmii-idWarning: ethernet@e000b000 (eth0) using random MAC address - 4a:63:5a:a4:d3:6b
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Zynq> fatload mmc 0 ${kernel_addr_r} zImage
10838528 bytes read in 4316 ms (2.4 MiB/s)
Zynq> fatload mmc 0 ${ramdisk_addr_r} rootfs-arm32.cpio.gz
406531 bytes read in 199 ms (1.9 MiB/s)
Zynq> setenvramdisk_size${filesize}
Zynq> fatload mmc 0 ${fdt_addr_r} zynq-zc702.dtb
15754 bytes read in 21 ms (732.4 KiB/s)
Zynq> setenv bootargs console=ttyPS0,115200 earlyconignore_loglevelrdinit=/init Zynq> bootz ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} Kernel image @0x2000000[0x000000-0xa56200]
## Flattened Device Tree blob at01f00000
Booting using the fdt blob at0x1f00000
Working FDT set to 1f00000
Loading Ramdisk to2ff9c000, end2ffff403... OK
Loading Device Tree to2ff95000, end2ff9bd89... OK
Working FDT set to2ff95000Starting kernel ...
Signed-off-by Tao Ding <[email protected]>--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)hw/sd/sdhci.c +1
-0@@ -644,6 +644,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->data_count =0 ; }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_READ ;break ; } }
hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
Quoted 8 lines
hw/sd/sdhci.c +1
-1@@ -669,6 +670,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) } }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_WRITE ;break ; } } --
Regards,
Bin
Re: [PATCH 1/1] fixed sdma boundary bug
1. u-boot
I used the u-boot obtained fromhttps://github.com/u-boot/u-boot, specifically the commit 1e80ee41441c612f05787a93bbef4e6e422e29d1.
When compiling uboot, I used xilinx_zynq_virt_defconfig and enabled the SDHCI_SDMA function. This can be set through scripts or in manuconfig.
Below is the command I used for local compilation:
$ export ARCH=arm $ export CROSS_COMPILE=/home/taoding/arm/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf- $ make O=/home/taoding/arm/u-boot-build-zynq xilinx_zynq_virt_defconfig
$ /home/taoding/arm/u-boot/scripts/config \
--file /home/taoding/arm/u-boot-build-zynq/.config \
--enable MMC_SDHCI_SDMA$ make O=/home/taoding/arm/u-boot-build-zynq olddefconfig $ make O=/home/taoding/arm/u-boot-build-zynq DEVICE_TREE=zynq-zc702 -j$(nproc)
The U-Boot binary used by QEMU was:/home/taoding/arm/u-boot-build-zynq/u-boot-dtb.bin
2. linux image
I used Linux 6.6.
Below is the command I used:
$ export ARCH=arm $ export CROSS_COMPILE=/home/taoding/arm/gcc-arm-11.2-2022.02-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf- $ make multi_v7_defconfig $ make -j$(nproc) zImage dtbs
The resulting files were:/home/taoding/arm/linux-6.6/arch/arm/boot/zImage /home/taoding/arm/linux-6.6/arch/arm/boot/dts/xilinx/zynq-zc702.dtb
3. rootfs
I utilized the defconfig and enable static binary to compile and generate rootfs-arm32.cpio.gz
4. zynq-sd.img
The SD image used for testing was a FAT16 image containing:
- zImage
- zynq-zc702.dtb
- rootfs-arm32.cpio.gz
Below is the command I used:
$ truncate -s 128M /home/taoding/arm/zynq-sd.img $ mkfs.vfat -F 16 /home/taoding/arm/zynq-sd.img
$ mcopy -i /home/taoding/arm/zynq-sd.img \ /home/taoding/arm/linux-6.6/arch/arm/boot/zImage ::zImage
$ mcopy -i /home/taoding/arm/zynq-sd.img \ /home/taoding/arm/linux-6.6/arch/arm/boot/dts/xilinx/zynq-zc702.dtb ::zynq-zc702.dtb
$ mcopy -i /home/taoding/arm/zynq-sd.img \ /home/taoding/arm/rootfs-arm32.cpio.gz ::rootfs-arm32.cpio.gz
If only want to verify the issues fixed in this patch, step 3 can be ignored. After starting qemu and entering uboot, we can manually load a file.
Please note that the driver will only actually use SDMA when the file size is greater than 0.5MB. It is recommended to load zImage from sd instead of dtb.
Thanks,
Tao
Quoted 115 lines · Bin Meng
Quoted 24 lines · Tao Ding
During SDMA transfers, the controller raises an interrupt at buffer boundaries to request a system address update. But the emulation fails to clear the SDHC_DOING_READ/WRITE flags after DMA completion, so writes to
SDHC_SYSADare ignored. Clear these flags when the transfer ends.
(according to PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf section 2.2.1)This is a QTest in npcm7xx_sdhci-test that exercises this boundary condition and validates the fix.
QTest steps:
1. Replacenpcm7xx_sdhci-test.cwith the updated version (full code available at:https://pastebin.com/AWVp2wFi).
2. Build with:../configure --target-list="arm-softmmu,aarch64-softmmu" \ --disable-slirp --enable-debug --disable-werror ninja qemu-system-arm tests/qtest/npcm7xx_sdhci-test 3. Run the specific test case: QTEST_QEMU_BINARY=./qemu-system-arm \ ./tests/qtest/npcm7xx_sdhci-test \ -p /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueBefore the fix, the test fails with a BLKCNT assertion:
ERROR:...wait_for_block_count: assertion failed (qtest_readw(...) == expected): (1 == 0)Quoted 8 lines
After applying the fix, the test passes:
ok 1 /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueThe new test case ensures the SDMA boundary handling works correctly and prevents future regressions.
Uboot test:
U-Boot
Quoted 1 line
1. Prepare zImage, uboot and rootfs.cpio.gz, make sure uboot config (MMC_SDHCI_SDMA=y).
Please specify which U-Boot defconfig you used for testing and how zynq-sd.img was generated.
Quoted 66 lines
2. ./qemu-system-aarch64 -M xilinx-zynq-a9 -machine boot-mode=sd -m 1024 -display none -serial null -serial stdio -monitor none \
-device loader,file=u-boot-dtb.bin,addr=0x04000000,cpu-num=0 \
-drive file=zynq-sd.img,format=raw,if=sd -D qemu.logAfter applying the fix, success load sd card:
U-Boot 2026.07-rc4-g1e80ee41441c (Jun 15 2026 - 19:05:05 +0800)
Model: Xilinx ZC702 board DRAM: ECC disabled 1 GiB Core: 33 devices, 21 uclasses, devicetree: board Flash: 0 Bytes NAND: 0 MiB MMC: mmc@e0100000: 0Loading Environment from FAT... *** Error - No Valid Environment Area found *** Warning - bad env area, using default environment
In: serial@e0001000 Out: serial@e0001000 Err: serial@e0001000Net:
ZYNQ GEM:e000b000, mdio buse000b000, phyaddr 7, interface rgmii-idWarning: ethernet@e000b000 (eth0) using random MAC address - 4a:63:5a:a4:d3:6b
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Zynq> fatload mmc 0 ${kernel_addr_r} zImage
10838528 bytes read in 4316 ms (2.4 MiB/s)
Zynq> fatload mmc 0 ${ramdisk_addr_r} rootfs-arm32.cpio.gz
406531 bytes read in 199 ms (1.9 MiB/s)
Zynq> setenvramdisk_size${filesize}
Zynq> fatload mmc 0 ${fdt_addr_r} zynq-zc702.dtb
15754 bytes read in 21 ms (732.4 KiB/s)
Zynq> setenv bootargs console=ttyPS0,115200 earlyconignore_loglevelrdinit=/init Zynq> bootz ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} Kernel image @0x2000000[0x000000-0xa56200]
## Flattened Device Tree blob at01f00000Booting using the fdt blob at 0x1f00000 Working FDT set to 1f00000 Loading Ramdisk to 2ff9c000, end 2ffff403 ... OK Loading Device Tree to 2ff95000, end 2ff9bd89 ... OKWorking FDT set to
2ff95000Starting kernel ...
Signed-off-by Tao Ding<[email protected]>--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)hw/sd/sdhci.c +1
-0@@ -644,6 +644,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->data_count =0 ; }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_READ ;break ; } }hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
Quoted 8 lines
hw/sd/sdhci.c +1
-1@@ -669,6 +670,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) } }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_WRITE ;break ; } } --Regards,
Bin
Re: [PATCH 1/1] fixed sdma boundary bug
In reply to Tao DingQuoted 7 lines · Tao Ding
During SDMA transfers, the controller raises an interrupt at buffer boundaries to request a system address update. But the emulation fails to clear the SDHC_DOING_READ/WRITE flags after DMA completion, so writes to
SDHC_SYSADare ignored. Clear these flags when the transfer ends.
(according to PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf section 2.2.1)
The commit message could end here, and the following can be put below --- so that they don't go into the commit message while it could still provide useful information for people to understand the issue.
Quoted 6 lines
This is a QTest in npcm7xx_sdhci-test that exercises this boundary condition and validates the fix.
QTest steps:
1. Replacenpcm7xx_sdhci-test.cwith the updated version (full code available at: https://pastebin.com/AWVp2wFi).
Please post a qtest patch instead.
Quoted 87 lines
2. Build with: ../configure --target-list="arm-softmmu,aarch64-softmmu" \ --disable-slirp --enable-debug --disable-werror ninja qemu-system-arm tests/qtest/npcm7xx_sdhci-test 3. Run the specific test case: QTEST_QEMU_BINARY=./qemu-system-arm \ ./tests/qtest/npcm7xx_sdhci-test \ -p /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueBefore the fix, the test fails with a BLKCNT assertion:
ERROR:...wait_for_block_count: assertion failed (qtest_readw(...)== expected): (1 == 0)After applying the fix, the test passes:
ok 1 /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueThe new test case ensures the SDMA boundary handling works correctly and prevents future regressions.
Uboot test:
1. Prepare zImage, uboot and rootfs.cpio.gz, make sure uboot config (MMC_SDHCI_SDMA=y).
2. ./qemu-system-aarch64 -M xilinx-zynq-a9 -machine boot-mode=sd -m 1024 -display none -serial null -serial stdio -monitor none \
-device loader,file=u-boot-dtb.bin,addr=0x04000000,cpu-num=0 \
-drive file=zynq-sd.img,format=raw,if=sd -D qemu.logAfter applying the fix, success load sd card:
U-Boot 2026.07-rc4-g1e80ee41441c (Jun 15 2026 - 19:05:05 +0800)
Model: Xilinx ZC702 board DRAM: ECC disabled 1 GiB Core: 33 devices, 21 uclasses, devicetree: board Flash: 0 Bytes NAND: 0 MiB MMC: mmc@e0100000: 0Loading Environment from FAT... *** Error - No Valid Environment Area found *** Warning - bad env area, using default environment
In: serial@e0001000 Out: serial@e0001000 Err: serial@e0001000Net:
ZYNQ GEM:e000b000, mdio buse000b000, phyaddr 7, interface rgmii-idWarning: ethernet@e000b000 (eth0) using random MAC address - 4a:63:5a:a4:d3:6b
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Zynq> fatload mmc 0 ${kernel_addr_r} zImage
10838528 bytes read in 4316 ms (2.4 MiB/s)
Zynq> fatload mmc 0 ${ramdisk_addr_r} rootfs-arm32.cpio.gz
406531 bytes read in 199 ms (1.9 MiB/s)
Zynq> setenvramdisk_size${filesize}
Zynq> fatload mmc 0 ${fdt_addr_r} zynq-zc702.dtb
15754 bytes read in 21 ms (732.4 KiB/s)
Zynq> setenv bootargs console=ttyPS0,115200 earlyconignore_loglevelrdinit=/init Zynq> bootz ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} Kernel image @0x2000000[0x000000-0xa56200]
## Flattened Device Tree blob at01f00000
Booting using the fdt blob at0x1f00000
Working FDT set to 1f00000
Loading Ramdisk to2ff9c000, end2ffff403... OK
Loading Device Tree to2ff95000, end2ff9bd89... OK
Working FDT set to2ff95000Starting kernel ...
Signed-off-by Tao Ding <[email protected]>--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)hw/sd/sdhci.c +1
-0@@ -644,6 +644,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->data_count =0 ; }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_READ ;break ; } }
hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
Quoted 8 lines
hw/sd/sdhci.c +1
-1@@ -669,6 +670,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) } }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_WRITE ;break ; } } --
Overall this patch LGTM.
Regards,
Bin
Re: [PATCH 1/1] fixed sdma boundary bug
Thank you for suggestion.
If post a patch in qtest, I have some doubts about where to place the code.
The bug fixed by this patch is related to generic sdhci. Currently,
qos-test includes a file named sdhci-test.c, which seems to be more appropriately placed here. qos-test conducts tests on many machines, but the way some machines load SD cards varies greatly. Is it possible to target only a specific board, such as xilinx-zynq-a9, and skip the other machines. Another way is to create a new file named xilinx_zynq_sdhci-test.c (similar to npcm7xx_sdhci-test.c).
Thanks,
Tao
Quoted 118 lines · Bin Meng
Quoted 6 lines · Tao Ding
During SDMA transfers, the controller raises an interrupt at buffer boundaries to request a system address update. But the emulation fails to clear the SDHC_DOING_READ/WRITE flags after DMA completion, so writes to
SDHC_SYSADare ignored. Clear these flags when the transfer ends.
(according to PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf section 2.2.1)The commit message could end here, and the following can be put below --- so that they don't go into the commit message while it could still provide useful information for people to understand the issue.
Quoted 6 lines
This is a QTest in npcm7xx_sdhci-test that exercises this boundary condition and validates the fix.
QTest steps:
1. Replacenpcm7xx_sdhci-test.cwith the updated version (full code available at:https://pastebin.com/AWVp2wFi).Please post a qtest patch instead.
Quoted 87 lines
2. Build with: ../configure --target-list="arm-softmmu,aarch64-softmmu" \ --disable-slirp --enable-debug --disable-werror ninja qemu-system-arm tests/qtest/npcm7xx_sdhci-test 3. Run the specific test case: QTEST_QEMU_BINARY=./qemu-system-arm \ ./tests/qtest/npcm7xx_sdhci-test \ -p /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueBefore the fix, the test fails with a BLKCNT assertion:
ERROR:...wait_for_block_count: assertion failed (qtest_readw(...) == expected): (1 == 0)After applying the fix, the test passes:
ok 1 /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continueThe new test case ensures the SDMA boundary handling works correctly and prevents future regressions.
Uboot test:
1. Prepare zImage, uboot and rootfs.cpio.gz, make sure uboot config (MMC_SDHCI_SDMA=y).
2. ./qemu-system-aarch64 -M xilinx-zynq-a9 -machine boot-mode=sd -m 1024 -display none -serial null -serial stdio -monitor none \
-device loader,file=u-boot-dtb.bin,addr=0x04000000,cpu-num=0 \
-drive file=zynq-sd.img,format=raw,if=sd -D qemu.logAfter applying the fix, success load sd card:
U-Boot 2026.07-rc4-g1e80ee41441c (Jun 15 2026 - 19:05:05 +0800)
Model: Xilinx ZC702 board DRAM: ECC disabled 1 GiB Core: 33 devices, 21 uclasses, devicetree: board Flash: 0 Bytes NAND: 0 MiB MMC: mmc@e0100000: 0Loading Environment from FAT... *** Error - No Valid Environment Area found *** Warning - bad env area, using default environment
In: serial@e0001000 Out: serial@e0001000 Err: serial@e0001000Net:
ZYNQ GEM:e000b000, mdio buse000b000, phyaddr 7, interface rgmii-idWarning: ethernet@e000b000 (eth0) using random MAC address - 4a:63:5a:a4:d3:6b
eth0: ethernet@e000b000
Hit any key to stop autoboot: 0
Zynq> fatload mmc 0 ${kernel_addr_r} zImage
10838528 bytes read in 4316 ms (2.4 MiB/s)
Zynq> fatload mmc 0 ${ramdisk_addr_r} rootfs-arm32.cpio.gz
406531 bytes read in 199 ms (1.9 MiB/s)
Zynq> setenvramdisk_size${filesize}
Zynq> fatload mmc 0 ${fdt_addr_r} zynq-zc702.dtb
15754 bytes read in 21 ms (732.4 KiB/s)
Zynq> setenv bootargs console=ttyPS0,115200 earlyconignore_loglevelrdinit=/init Zynq> bootz ${kernel_addr_r} ${ramdisk_addr_r}:${ramdisk_size} ${fdt_addr_r} Kernel image @0x2000000[0x000000-0xa56200]
## Flattened Device Tree blob at01f00000Booting using the fdt blob at 0x1f00000 Working FDT set to 1f00000 Loading Ramdisk to 2ff9c000, end 2ffff403 ... OK Loading Device Tree to 2ff95000, end 2ff9bd89 ... OKWorking FDT set to
2ff95000Starting kernel ...
Signed-off-by Tao Ding<[email protected]>--- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)hw/sd/sdhci.c +1
-0@@ -644,6 +644,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) s->data_count =0 ; }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_READ ;break ; } }hw/sd/sdhci.c static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
Quoted 8 lines
hw/sd/sdhci.c +1
-1@@ -669,6 +670,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s) } }if (page_aligned && boundary_count ==0 ) { + s->prnsts &= ~SDHC_DOING_WRITE ;break ; } } --Overall this patch LGTM.
Regards,
Bin
ping
Quoted 16 lines
Hi all,
Booting Linux from SD card on Xilinx Zynq with SDMA (MMC_SDHCI_SDMA=y) currently hangs during image load.
This patch fixes the hang and enables successful image loading.
Thanks!
Tao Ding (1):
fixed sdma boundary bughw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+)base-commit:
608ad9307d5b4797d2254ee3a4bad2bc8c8bcbae