wil6210: fix freeing of rx buffers in EDMA mode
authorAhmad Masri <amasri@codeaurora.org>
Wed, 31 Oct 2018 08:52:23 +0000 (10:52 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 6 Nov 2018 16:04:16 +0000 (18:04 +0200)
After being associated with some EDMA rx traffic, upon "down" driver
doesn't free all skbs in the rx ring.
Modify wil_move_all_rx_buff_to_free_list to loop on active list of rx
buffers, unmap the physical memory and free the skb.

Signed-off-by: Ahmad Masri <amasri@codeaurora.org>
Signed-off-by: Maya Erez <merez@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/wil6210/txrx_edma.c

index 686ba3463970e3c89736c6457b00a2ce356b49fe..05a8348bd7b963c8d414ea00e8c03f7c315997ed 100644 (file)
@@ -234,9 +234,10 @@ static int wil_rx_refill_edma(struct wil6210_priv *wil)
        struct wil_ring *ring = &wil->ring_rx;
        u32 next_head;
        int rc = 0;
-       u32 swtail = *ring->edma_rx_swtail.va;
+       ring->swtail = *ring->edma_rx_swtail.va;
 
-       for (; next_head = wil_ring_next_head(ring), (next_head != swtail);
+       for (; next_head = wil_ring_next_head(ring),
+            (next_head != ring->swtail);
             ring->swhead = next_head) {
                rc = wil_ring_alloc_skb_edma(wil, ring, ring->swhead);
                if (unlikely(rc)) {
@@ -264,43 +265,26 @@ static void wil_move_all_rx_buff_to_free_list(struct wil6210_priv *wil,
                                              struct wil_ring *ring)
 {
        struct device *dev = wil_to_dev(wil);
-       u32 next_tail;
-       u32 swhead = (ring->swhead + 1) % ring->size;
+       struct list_head *active = &wil->rx_buff_mgmt.active;
        dma_addr_t pa;
-       u16 dmalen;
 
-       for (; next_tail = wil_ring_next_tail(ring), (next_tail != swhead);
-            ring->swtail = next_tail) {
-               struct wil_rx_enhanced_desc dd, *d = &dd;
-               struct wil_rx_enhanced_desc *_d =
-                       (struct wil_rx_enhanced_desc *)
-                       &ring->va[ring->swtail].rx.enhanced;
-               struct sk_buff *skb;
-               u16 buff_id;
+       while (!list_empty(active)) {
+               struct wil_rx_buff *rx_buff =
+                       list_first_entry(active, struct wil_rx_buff, list);
+               struct sk_buff *skb = rx_buff->skb;
 
-               *d = *_d;
-
-               /* Extract the SKB from the rx_buff management array */
-               buff_id = __le16_to_cpu(d->mac.buff_id);
-               if (buff_id >= wil->rx_buff_mgmt.size) {
-                       wil_err(wil, "invalid buff_id %d\n", buff_id);
-                       continue;
-               }
-               skb = wil->rx_buff_mgmt.buff_arr[buff_id].skb;
-               wil->rx_buff_mgmt.buff_arr[buff_id].skb = NULL;
                if (unlikely(!skb)) {
-                       wil_err(wil, "No Rx skb at buff_id %d\n", buff_id);
+                       wil_err(wil, "No Rx skb at buff_id %d\n", rx_buff->id);
                } else {
-                       pa = wil_rx_desc_get_addr_edma(&d->dma);
-                       dmalen = le16_to_cpu(d->dma.length);
-                       dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE);
-
+                       rx_buff->skb = NULL;
+                       memcpy(&pa, skb->cb, sizeof(pa));
+                       dma_unmap_single(dev, pa, wil->rx_buf_len,
+                                        DMA_FROM_DEVICE);
                        kfree_skb(skb);
                }
 
                /* Move the buffer from the active to the free list */
-               list_move(&wil->rx_buff_mgmt.buff_arr[buff_id].list,
-                         &wil->rx_buff_mgmt.free);
+               list_move(&rx_buff->list, &wil->rx_buff_mgmt.free);
        }
 }