Skip to content

Commit b92c517

Browse files
P Praneeshgregkh
authored andcommitted
wifi: ath11k: Fix DMA buffer allocation to resolve SWIOTLB issues
[ Upstream commit 1bcd209 ] Currently, the driver allocates cacheable DMA buffers for rings like HAL_REO_DST and HAL_WBM2SW_RELEASE. The buffers for HAL_WBM2SW_RELEASE are large (1024 KiB), exceeding the SWIOTLB slot size of 256 KiB. This leads to "swiotlb buffer is full" error messages on systems without an IOMMU that use SWIOTLB, causing driver initialization failures. The driver calls dma_map_single() with these large buffers obtained from kzalloc(), resulting in ring initialization errors on systems without an IOMMU that use SWIOTLB. To address these issues, replace the flawed buffer allocation mechanism with the appropriate DMA API. Specifically, use dma_alloc_noncoherent() for cacheable DMA buffers, ensuring proper freeing of buffers with dma_free_noncoherent(). Error log: [ 10.194343] ath11k_pci 0000:04:00.0: swiotlb buffer is full (sz:1048583 bytes), total 32768 (slots), used 2529 (slots) [ 10.194406] ath11k_pci 0000:04:00.0: failed to set up tcl_comp ring (0) :-12 [ 10.194781] ath11k_pci 0000:04:00.0: failed to init DP: -12 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-03125-QCAHSPSWPL_V1_V2_SILICONZ_LITE-3 Reported-by: Tim Harvey <tharvey@gateworks.com> Closes: https://lore.kernel.org/all/20241210041133.GA17116@lst.de/ Signed-off-by: P Praneesh <quic_ppranees@quicinc.com> Tested-by: Tim Harvey <tharvey@gateworks.com> Link: https://patch.msgid.link/20250119164219.647059-2-quic_ppranees@quicinc.com Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 90a5892 commit b92c517

File tree

1 file changed

+11
-24
lines changed
  • drivers/net/wireless/ath/ath11k

1 file changed

+11
-24
lines changed

drivers/net/wireless/ath/ath11k/dp.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <crypto/hash.h>
@@ -104,14 +104,12 @@ void ath11k_dp_srng_cleanup(struct ath11k_base *ab, struct dp_srng *ring)
104104
if (!ring->vaddr_unaligned)
105105
return;
106106

107-
if (ring->cached) {
108-
dma_unmap_single(ab->dev, ring->paddr_unaligned, ring->size,
109-
DMA_FROM_DEVICE);
110-
kfree(ring->vaddr_unaligned);
111-
} else {
107+
if (ring->cached)
108+
dma_free_noncoherent(ab->dev, ring->size, ring->vaddr_unaligned,
109+
ring->paddr_unaligned, DMA_FROM_DEVICE);
110+
else
112111
dma_free_coherent(ab->dev, ring->size, ring->vaddr_unaligned,
113112
ring->paddr_unaligned);
114-
}
115113

116114
ring->vaddr_unaligned = NULL;
117115
}
@@ -249,25 +247,14 @@ int ath11k_dp_srng_setup(struct ath11k_base *ab, struct dp_srng *ring,
249247
default:
250248
cached = false;
251249
}
252-
253-
if (cached) {
254-
ring->vaddr_unaligned = kzalloc(ring->size, GFP_KERNEL);
255-
if (!ring->vaddr_unaligned)
256-
return -ENOMEM;
257-
258-
ring->paddr_unaligned = dma_map_single(ab->dev,
259-
ring->vaddr_unaligned,
260-
ring->size,
261-
DMA_FROM_DEVICE);
262-
if (dma_mapping_error(ab->dev, ring->paddr_unaligned)) {
263-
kfree(ring->vaddr_unaligned);
264-
ring->vaddr_unaligned = NULL;
265-
return -ENOMEM;
266-
}
267-
}
268250
}
269251

270-
if (!cached)
252+
if (cached)
253+
ring->vaddr_unaligned = dma_alloc_noncoherent(ab->dev, ring->size,
254+
&ring->paddr_unaligned,
255+
DMA_FROM_DEVICE,
256+
GFP_KERNEL);
257+
else
271258
ring->vaddr_unaligned = dma_alloc_coherent(ab->dev, ring->size,
272259
&ring->paddr_unaligned,
273260
GFP_KERNEL);

0 commit comments

Comments
 (0)