[bug report] wifi: ath12k: sleeping in atomic bugs

Dan Carpenter
2023-02-16T13:59:09Z

Hello Kalle Valo,

The patch d889913205cf: "wifi: ath12k: driver for Qualcomm Wi-Fi 7
devices" from Nov 28, 2022, leads to the following Smatch static
checker warning:

drivers/net/wireless/ath/ath12k/dbring.c:39 ath12k_dbring_bufs_replenish() warn: make sure GFP_ATOMIC set here
drivers/net/wireless/ath/ath12k/dbring.c:97 ath12k_dbring_fill_bufs() warn: sleeping in atomic context

drivers/net/wireless/ath/ath12k/dbring.c
10 static int ath12k_dbring_bufs_replenish(struct ath12k *ar,
11 struct ath12k_dbring *ring,
12 struct ath12k_dbring_element *buff,
13 gfp_t gfp)
14 {
15 struct ath12k_base *ab = ar->ab;
16 struct hal_srng *srng;
17 dma_addr_t paddr;
18 void *ptr_aligned, *ptr_unaligned, *desc;
19 int ret;
20 int buf_id;
21 u32 cookie;
22
23 srng = &ab->hal.srng_list[ring->refill_srng.ring_id];
24
25 lockdep_assert_held(&srng->lock);
26
27 ath12k_hal_srng_access_begin(ab, srng);
28
29 ptr_unaligned = buff->payload;
30 ptr_aligned = PTR_ALIGN(ptr_unaligned, ring->buf_align);
31 paddr = dma_map_single(ab->dev, ptr_aligned, ring->buf_sz,
32 DMA_FROM_DEVICE);
33
34 ret = dma_mapping_error(ab->dev, paddr);
35 if (ret)
36 goto err;
37
38 spin_lock_bh(&ring->idr_lock);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Atomic context.

--> 39 buf_id = idr_alloc(&ring->bufs_idr, buff, 0, ring->bufs_max, gfp);
40 spin_unlock_bh(&ring->idr_lock);

ath12k_dbring_buf_setup() passes GFP_KERNEL to here as the gfp. I think
this is a sleeping in atomic bug. The caller definitely has a bug.

41 if (buf_id < 0) {
42 ret = -ENOBUFS;
43 goto err_dma_unmap;
44 }
45

regards,
dan carpenter

--
ath12k mailing list
ath12k@lists.infradead.org