Skip to content

Commit 9b59c76

Browse files
Dan Carpentergregkh
authored andcommitted
ath11k: fix some sleeping in atomic bugs
[ Upstream commit aadf7c8 ] The ath11k_dbring_bufs_replenish() and ath11k_dbring_fill_bufs() take a "gfp" parameter but they since they take spinlocks, the allocations they do have to be atomic. This causes a bug because ath11k_dbring_buf_setup passes GFP_KERNEL for the gfp flags. The fix is to use GFP_ATOMIC and remove the unused parameters. Fixes: bd64785 ("ath11k: Add direct buffer ring support") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20210812070434.GE31863@kili Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e1ddaa5 commit 9b59c76

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
static int ath11k_dbring_bufs_replenish(struct ath11k *ar,
1010
struct ath11k_dbring *ring,
11-
struct ath11k_dbring_element *buff,
12-
gfp_t gfp)
11+
struct ath11k_dbring_element *buff)
1312
{
1413
struct ath11k_base *ab = ar->ab;
1514
struct hal_srng *srng;
@@ -35,7 +34,7 @@ static int ath11k_dbring_bufs_replenish(struct ath11k *ar,
3534
goto err;
3635

3736
spin_lock_bh(&ring->idr_lock);
38-
buf_id = idr_alloc(&ring->bufs_idr, buff, 0, ring->bufs_max, gfp);
37+
buf_id = idr_alloc(&ring->bufs_idr, buff, 0, ring->bufs_max, GFP_ATOMIC);
3938
spin_unlock_bh(&ring->idr_lock);
4039
if (buf_id < 0) {
4140
ret = -ENOBUFS;
@@ -72,8 +71,7 @@ static int ath11k_dbring_bufs_replenish(struct ath11k *ar,
7271
}
7372

7473
static int ath11k_dbring_fill_bufs(struct ath11k *ar,
75-
struct ath11k_dbring *ring,
76-
gfp_t gfp)
74+
struct ath11k_dbring *ring)
7775
{
7876
struct ath11k_dbring_element *buff;
7977
struct hal_srng *srng;
@@ -92,11 +90,11 @@ static int ath11k_dbring_fill_bufs(struct ath11k *ar,
9290
size = sizeof(*buff) + ring->buf_sz + align - 1;
9391

9492
while (num_remain > 0) {
95-
buff = kzalloc(size, gfp);
93+
buff = kzalloc(size, GFP_ATOMIC);
9694
if (!buff)
9795
break;
9896

99-
ret = ath11k_dbring_bufs_replenish(ar, ring, buff, gfp);
97+
ret = ath11k_dbring_bufs_replenish(ar, ring, buff);
10098
if (ret) {
10199
ath11k_warn(ar->ab, "failed to replenish db ring num_remain %d req_ent %d\n",
102100
num_remain, req_entries);
@@ -176,7 +174,7 @@ int ath11k_dbring_buf_setup(struct ath11k *ar,
176174
ring->hp_addr = ath11k_hal_srng_get_hp_addr(ar->ab, srng);
177175
ring->tp_addr = ath11k_hal_srng_get_tp_addr(ar->ab, srng);
178176

179-
ret = ath11k_dbring_fill_bufs(ar, ring, GFP_KERNEL);
177+
ret = ath11k_dbring_fill_bufs(ar, ring);
180178

181179
return ret;
182180
}
@@ -322,7 +320,7 @@ int ath11k_dbring_buffer_release_event(struct ath11k_base *ab,
322320
}
323321

324322
memset(buff, 0, size);
325-
ath11k_dbring_bufs_replenish(ar, ring, buff, GFP_ATOMIC);
323+
ath11k_dbring_bufs_replenish(ar, ring, buff);
326324
}
327325

328326
spin_unlock_bh(&srng->lock);

0 commit comments

Comments
 (0)