1 |
From bd62630eb3efbb905a11457a9235086a40cc6647 Mon Sep 17 00:00:00 2001 |
2 |
From: Maya Erez <merez@codeaurora.org> |
3 |
Date: Thu, 23 Aug 2018 14:47:11 +0300 |
4 |
Subject: [PATCH 079/145] wil6210: fix RX buffers release and unmap |
5 |
|
6 |
[ Upstream commit 84f16fbb62384fb209cd35741d94eb00b5ca2746 ] |
7 |
|
8 |
RX SKBs are released in both wil6210 rmmod and RX handle. |
9 |
As there is no lock to protect the buffers DMA unmap, |
10 |
the SKB pointer in buff_arr is used to check if the buffer |
11 |
memory was already released. |
12 |
Setting wil->rx_buff_mgmt.buff_arr[buff_id].skb to NULL before the DMA |
13 |
memory unmap will prevent duplicate unmapping of the same memory. |
14 |
Move the buffer ID to the free list also in case the SKB is NULL. |
15 |
|
16 |
Signed-off-by: Maya Erez <merez@codeaurora.org> |
17 |
Signed-off-by: Kalle Valo <kvalo@codeaurora.org> |
18 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
19 |
--- |
20 |
drivers/net/wireless/ath/wil6210/txrx_edma.c | 15 ++++++++++----- |
21 |
1 file changed, 10 insertions(+), 5 deletions(-) |
22 |
|
23 |
diff --git a/drivers/net/wireless/ath/wil6210/txrx_edma.c b/drivers/net/wireless/ath/wil6210/txrx_edma.c |
24 |
index bca61cb44c37..3e7fc2983cbb 100644 |
25 |
--- a/drivers/net/wireless/ath/wil6210/txrx_edma.c |
26 |
+++ b/drivers/net/wireless/ath/wil6210/txrx_edma.c |
27 |
@@ -279,9 +279,6 @@ static void wil_move_all_rx_buff_to_free_list(struct wil6210_priv *wil, |
28 |
u16 buff_id; |
29 |
|
30 |
*d = *_d; |
31 |
- pa = wil_rx_desc_get_addr_edma(&d->dma); |
32 |
- dmalen = le16_to_cpu(d->dma.length); |
33 |
- dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE); |
34 |
|
35 |
/* Extract the SKB from the rx_buff management array */ |
36 |
buff_id = __le16_to_cpu(d->mac.buff_id); |
37 |
@@ -291,10 +288,15 @@ static void wil_move_all_rx_buff_to_free_list(struct wil6210_priv *wil, |
38 |
} |
39 |
skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb; |
40 |
wil->rx_buff_mgmt.buff_arr[buff_id].skb = NULL; |
41 |
- if (unlikely(!skb)) |
42 |
+ if (unlikely(!skb)) { |
43 |
wil_err(wil, "No Rx skb at buff_id %d\n", buff_id); |
44 |
- else |
45 |
+ } else { |
46 |
+ pa = wil_rx_desc_get_addr_edma(&d->dma); |
47 |
+ dmalen = le16_to_cpu(d->dma.length); |
48 |
+ dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE); |
49 |
+ |
50 |
kfree_skb(skb); |
51 |
+ } |
52 |
|
53 |
/* Move the buffer from the active to the free list */ |
54 |
list_move(&wil->rx_buff_mgmt.buff_arr[buff_id].list, |
55 |
@@ -906,6 +908,9 @@ static struct sk_buff *wil_sring_reap_rx_edma(struct wil6210_priv *wil, |
56 |
wil->rx_buff_mgmt.buff_arr[buff_id].skb = NULL; |
57 |
if (!skb) { |
58 |
wil_err(wil, "No Rx skb at buff_id %d\n", buff_id); |
59 |
+ /* Move the buffer from the active list to the free list */ |
60 |
+ list_move(&wil->rx_buff_mgmt.buff_arr[buff_id].list, |
61 |
+ &wil->rx_buff_mgmt.free); |
62 |
goto again; |
63 |
} |
64 |
|
65 |
-- |
66 |
2.19.1 |
67 |
|