diff options
author | Zhenghao Gu <imguzh@gmail.com> | 2023-12-20 21:33:08 +0300 |
---|---|---|
committer | Kalle Valo <quic_kvalo@quicinc.com> | 2024-01-11 14:18:49 +0300 |
commit | aaf244141ed7195a9a56e03c2367f4a9d0b727a8 (patch) | |
tree | 2bb66b0ab1f57f1fd892ac0eabee63f4ed7a0c10 /drivers/net/wireless/ath/ath11k/dp.c | |
parent | e7ab40b733094dfc50dad58bbce81f544af1d8cc (diff) | |
download | linux-aaf244141ed7195a9a56e03c2367f4a9d0b727a8.tar.xz |
wifi: ath11k: fix IOMMU errors on buffer rings
virt_to_phys() doesn't work on systems with IOMMU enabled, which have
non-identity physical-to-IOVA mappings. It leads to IO_PAGE_FAULTs like this:
[IO_PAGE_FAULT domain=0x0023 address=0x1cce00000 flags=0x0020]
And no association to the AP can be established.
This patch changes that to dma_map_single(), which works correctly. Even
virt_to_phys() documentation says device drivers should not use it:
This function does not give bus mappings for DMA transfers. In
almost all conceivable cases a device driver should not be using
this function
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
Signed-off-by: Zhenghao Gu <imguzh@gmail.com>
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://msgid.link/20231212031914.47339-1-imguzh@gmail.com
Diffstat (limited to 'drivers/net/wireless/ath/ath11k/dp.c')
-rw-r--r-- | drivers/net/wireless/ath/ath11k/dp.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/net/wireless/ath/ath11k/dp.c b/drivers/net/wireless/ath/ath11k/dp.c index 8975dc57ad77..1a62407e5a9f 100644 --- a/drivers/net/wireless/ath/ath11k/dp.c +++ b/drivers/net/wireless/ath/ath11k/dp.c @@ -104,11 +104,14 @@ void ath11k_dp_srng_cleanup(struct ath11k_base *ab, struct dp_srng *ring) if (!ring->vaddr_unaligned) return; - if (ring->cached) + if (ring->cached) { + dma_unmap_single(ab->dev, ring->paddr_unaligned, ring->size, + DMA_FROM_DEVICE); kfree(ring->vaddr_unaligned); - else + } else { dma_free_coherent(ab->dev, ring->size, ring->vaddr_unaligned, ring->paddr_unaligned); + } ring->vaddr_unaligned = NULL; } @@ -249,7 +252,18 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring, if (cached) { ring->vaddr_unaligned = kzalloc(ring->size, GFP_KERNEL); - ring->paddr_unaligned = virt_to_phys(ring->vaddr_unaligned); + if (!ring->vaddr_unaligned) + return -ENOMEM; + + ring->paddr_unaligned = dma_map_single(ab->dev, + ring->vaddr_unaligned, + ring->size, + DMA_FROM_DEVICE); + if (dma_mapping_error(ab->dev, ring->paddr_unaligned)) { + kfree(ring->vaddr_unaligned); + ring->vaddr_unaligned = NULL; + return -ENOMEM; + } } } |