fix: serial: add D-Cache invalidate in DMA RX path - #11659
Conversation
Signed-off-by: jiaoxy0 <jiaoxiaoyu0@163.com>
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-07-24 00:06 CST)
📝 Review Instructions
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
On Cortex-M7 with D-Cache enabled, DMA writes to the RX ring buffer bypass the cache. When the CPU reads the buffer via rt_memcpy(), it may get stale cached data instead of the actual DMA-written content.
Add rt_hw_cpu_dcache_ops(RT_HW_CACHE_INVALIDATE) before each rt_memcpy() in _serial_dma_rx() to ensure cache coherence.