Date: Mon, 23 Feb 2026 11:18:28 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 293381] linuxkpi: Possible incorrect bus_dmasync_op_t mapping for DMA_BIDIRECTIONAL Message-ID: <bug-293381-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293381 Bug ID: 293381 Summary: linuxkpi: Possible incorrect bus_dmasync_op_t mapping for DMA_BIDIRECTIONAL Product: Base System Version: 15.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: zishun.yi.dev@gmail.com CC: bz@FreeBSD.org Created attachment 268296 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=268296&action=edit Illustrative patch In dma_sync_single_for_cpu(), for DMA_BIDIRECTIONAL, the code currently performs BUS_DMASYNC_POSTREAD followed by BUS_DMASYNC_PREREAD. I suspect it should simply be BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE. Reason: dma_sync_single_for_cpu() transfers the ownership of the DMA area to the CPU. Since DMA_BIDIRECTIONAL indicates the area can be used for both Device -> Main Memory and Main Memory -> Device transfers, we must assume the previous device's access was bidirectional. Because the device might have both read from and written to this area, both POST operations are necessary before the CPU accesses it. Furthermore, since the ownership of the DMA area is being transferred to the CPU, the device will no longer access it. Therefore, I believe the PREREAD operation is unnecessary. PREREAD should instead be used when ownership is transferred back to the device. So, for dma_sync_single_for_device(), I suspect it should use BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE to prepare the buffer for potential bidirectional access by the hardware. PS: I noticed this logic was introduced in https://reviews.freebsd.org/D32255. this DR conclusion seemed a bit unclear, and the current mapping was ultimately adopted. Given that context, I just wanted to bring this up to see if it might be an oversight. Please kindly correct me if my understanding is wrong. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-293381-227>
