ath11k zeroes cached REO destination and WBM release rings mapped as DMA_FROM_DEVICE, then enables them without syncing them for the device. The DMA API requires that initial sync and treats this DMA direction as CPU read-only. Use coherent DMA for allocation and free, and stop setting the cached ring flag. Leave the unused cache code for a follow-up. Keeping non-coherent cached rings would require DMA_BIDIRECTIONAL and a device sync before enable. It would also require safe ownership at cache-line granularity: two 32-byte WBM descriptors can share a 64-byte line while the CPU owns one and hardware owns the other. Syncing one descriptor at a time does not solve that. Coherent DMA avoids the overlap but may cost CPU time where coherent mappings are uncached. Signed-off-by: Alexey Immoreev --- Downstream IPQ5018 (RA82) testing saw three zero-status TX completions with cached WBM rings and none with coherent WBM rings. The dp.c change compiles on ARM32 and AArch64 with OpenWrt backports headers. Patch 5/10 of https://patchwork.kernel.org/series/1219647/ changes runtime CPU sync, not startup. This RFC disables the cached path that the series optimizes. The performance impact is not yet measured. OpenAI GPT-6.2 Sol drafted the patch and ran the host checks. GPT-6.2 Astra independently reviewed the DMA issue. I reviewed the email and patch and signed off on the contribution. base-commit: 03b7c601b6e314115015a57061f5b377afe13190 diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c index be65d73b904b..f23c37370280 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -103,12 +103,8 @@ if (!ring->vaddr_unaligned) return; - if (ring->cached) - dma_free_noncoherent(ab->dev, ring->size, ring->vaddr_unaligned, - ring->paddr_unaligned, DMA_FROM_DEVICE); - else - dma_free_coherent(ab->dev, ring->size, ring->vaddr_unaligned, - ring->paddr_unaligned); + dma_free_coherent(ab->dev, ring->size, ring->vaddr_unaligned, + ring->paddr_unaligned); ring->vaddr_unaligned = NULL; } @@ -226,7 +222,6 @@ int entry_sz = ath11k_hal_srng_get_entrysize(ab, type); int max_entries = ath11k_hal_srng_get_max_entries(ab, type); int ret; - bool cached = false; if (max_entries < 0 || entry_sz < 0) return -EINVAL; @@ -236,27 +231,9 @@ ring->size = (num_entries * entry_sz) + HAL_RING_BASE_ALIGN - 1; - if (ab->hw_params.alloc_cacheable_memory) { - /* Allocate the reo dst and tx completion rings from cacheable memory */ - switch (type) { - case HAL_REO_DST: - case HAL_WBM2SW_RELEASE: - cached = true; - break; - default: - cached = false; - } - } - - if (cached) - ring->vaddr_unaligned = dma_alloc_noncoherent(ab->dev, ring->size, - &ring->paddr_unaligned, - DMA_FROM_DEVICE, - GFP_KERNEL); - else - ring->vaddr_unaligned = dma_alloc_coherent(ab->dev, ring->size, - &ring->paddr_unaligned, - GFP_KERNEL); + ring->vaddr_unaligned = dma_alloc_coherent(ab->dev, ring->size, + &ring->paddr_unaligned, + GFP_KERNEL); if (!ring->vaddr_unaligned) return -ENOMEM; @@ -318,11 +295,6 @@ return -EINVAL; } - if (cached) { - params.flags |= HAL_SRNG_FLAGS_CACHED; - ring->cached = 1; - } - ret = ath11k_hal_srng_setup(ab, type, ring_num, mac_id, ¶ms); if (ret < 0) { ath11k_dp_srng_cleanup(ab, ring);