From nobody Sun Jul 26 12:31:36 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=163.com ARC-Seal: i=1; a=rsa-sha256; t=1781712270; cv=none; d=zohomail.com; s=zohoarc; b=ZUrrZ5XFFu/s/qCHaBw1B9VcOCUjuKb7OpY6rS0J/e6ieZSeBAvqeD8TxWDmuMNSjhNzzW9YDztIBku2Cnx8OU18dcU8sVcH7/l+W4TXk5UUmP7TNGCZv50ATKvP9gr7FLxM5nLLhRtepGLxyQTGDbozD82e7rSqhIaQcSSfktM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781712270; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P+GXD2ZZZ4P+6ukCDik5P2y5MkYdLrS9uYLM9b2o6mA=; b=KHim4misdq1xOc3xZdd8ML4/XuBms0KC8dvsZDMKV35vhpJIX/Lnr8rRYlhvGkjUYWOdxCZTE6gVo8h9MZw4E2vN8KUD8dh6chKMyguxwLeZHrZEh8L7bDlawjYZr0Aqwm+82e7eIyNcmjv/te1ID9PxXK2QjffLUxaEVN8jP54= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781712270510243.87751407018322; Wed, 17 Jun 2026 09:04:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wZsjp-0002r7-7k; Wed, 17 Jun 2026 12:03:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZsja-0002os-MI; Wed, 17 Jun 2026 12:03:26 -0400 Received: from m16.mail.163.com ([220.197.31.4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wZsjV-0000aZ-PH; Wed, 17 Jun 2026 12:03:21 -0400 Received: from dt-VM.localdomain (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wD339FjxDJqmwGZEA--.19873S3; Wed, 17 Jun 2026 23:59:35 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=P+ GXD2ZZZ4P+6ukCDik5P2y5MkYdLrS9uYLM9b2o6mA=; b=KXeSiLwppfPQ6k6z4r ed9R6pJx08trLsrA7y+yapvaQXS4eXvIj1wy8pSVsIvXxiho6JLS+hDpquS4+w91 Lzsea+RKIBg9ajbFqFHBLdjKD8V96UqT8V4IUAN2nR6FKUGZXWzbnNbv9P0F4Xe8 B0TE5xT0hJAU1XkZz4JNmgZJM= From: Tao Ding To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng , qemu-block@nongnu.org, Tao Ding Subject: [PATCH 1/1] fixed sdma boundary bug Date: Wed, 17 Jun 2026 23:58:57 +0800 Message-ID: <20260617155857.7451-2-dingtao0430@163.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260617155857.7451-1-dingtao0430@163.com> References: <20260617155857.7451-1-dingtao0430@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wD339FjxDJqmwGZEA--.19873S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxCF1rur43JFW8Xw1xGr4fAFb_yoWrGw13pF ZFyr4Sgrs7AFy5Z3WkCa4rCFyUuwsrAa43Jr1FyrnY9a1YkFnYqw13K3WrKrW8XrWxXw13 ArZxtr1Yva4UAaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0ziH7K3UUUUU= X-Originating-IP: [112.193.82.42] X-CM-SenderInfo: pglqw3tdrqkjqq6rljoofrz/xtbC4ghysGoyxGhpwAAA31 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=220.197.31.4; envelope-from=dingtao0430@163.com; helo=m16.mail.163.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @163.com) X-ZM-MESSAGEID: 1781712272064158500 Content-Type: text/plain; charset="utf-8" During SDMA transfers, the controller raises an interrupt at buffer boundar= ies 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 a= re ignored. Clear these flags when the transfer ends.=20 (according to PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pd= f section 2.2.1) This is a QTest in npcm7xx_sdhci-test that exercises this boundary conditio= n 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=3D"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=3D./qemu-system-arm \ ./tests/qtest/npcm7xx_sdhci-test \ -p /arm/npcm7xx_sdhci/read_sd_sdma_boundary_continue Before the fix, the test fails with a BLKCNT assertion: ERROR:...wait_for_block_count: assertion failed (qtest_readw(...) =3D=3D = expected): (1 =3D=3D 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 (MM= C_SDHCI_SDMA=3Dy). 2. ./qemu-system-aarch64 -M xilinx-zynq-a9 -machine boot-mode=3Dsd -m 1= 024 -display none -serial null -serial stdio -monitor none \ -device loader,file=3Du-boot-dtb.bin,addr=3D0x04000000,cpu-num=3D0 = \ -drive file=3Dzynq-sd.img,format=3Draw,if=3Dsd -D qemu.log After applying the fix, success load sd card: =20 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: =20 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=3DttyPS0,115200 earlycon ignore_loglevel rdin= it=3D/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 ... Signed-off-by: Tao Ding --- hw/sd/sdhci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index c86dfa281f..0d87289ca4 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -644,6 +644,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState= *s) s->data_count =3D 0; } if (page_aligned && boundary_count =3D=3D 0) { + s->prnsts &=3D ~SDHC_DOING_READ; break; } } @@ -669,6 +670,7 @@ static void sdhci_sdma_transfer_multi_blocks(SDHCIState= *s) } } if (page_aligned && boundary_count =3D=3D 0) { + s->prnsts &=3D ~SDHC_DOING_WRITE; break; } } --=20 2.43.0