Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67aaa6e4 authored by Ahmad Masri's avatar Ahmad Masri Committed by Maya Erez
Browse files

wil6210: fix freeing of rx buffers in EDMA mode



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.

Change-Id: I952f0dc86a7dfce8705786ab1ee7172421cb3901
Signed-off-by: default avatarAhmad Masri <amasri@codeaurora.org>
Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Git-commit: 6470f31927b46846d957628b719dcfda05446664
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git


Signed-off-by: default avatarMaya Erez <merez@codeaurora.org>
parent 3af0b038
Loading
Loading
Loading
Loading
+14 −30
Original line number Original line Diff line number Diff line
@@ -235,9 +235,10 @@ static int wil_rx_refill_edma(struct wil6210_priv *wil)
	struct wil_ring *ring = &wil->ring_rx;
	struct wil_ring *ring = &wil->ring_rx;
	u32 next_head;
	u32 next_head;
	int rc = 0;
	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) {
	     ring->swhead = next_head) {
		rc = wil_ring_alloc_skb_edma(wil, ring, ring->swhead);
		rc = wil_ring_alloc_skb_edma(wil, ring, ring->swhead);
		if (unlikely(rc)) {
		if (unlikely(rc)) {
@@ -265,43 +266,26 @@ static void wil_move_all_rx_buff_to_free_list(struct wil6210_priv *wil,
					      struct wil_ring *ring)
					      struct wil_ring *ring)
{
{
	struct device *dev = wil_to_dev(wil);
	struct device *dev = wil_to_dev(wil);
	u32 next_tail;
	struct list_head *active = &wil->rx_buff_mgmt.active;
	u32 swhead = (ring->swhead + 1) % ring->size;
	dma_addr_t pa;
	dma_addr_t pa;
	u16 dmalen;


	for (; next_tail = wil_ring_next_tail(ring), (next_tail != swhead);
	while (!list_empty(active)) {
	     ring->swtail = next_tail) {
		struct wil_rx_buff *rx_buff =
		struct wil_rx_enhanced_desc dd, *d = &dd;
			list_first_entry(active, struct wil_rx_buff, list);
		struct wil_rx_enhanced_desc *_d =
		struct sk_buff *skb = rx_buff->skb;
			(struct wil_rx_enhanced_desc *)
			&ring->va[ring->swtail].rx.enhanced;
		struct sk_buff *skb;
		u16 buff_id;


		*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)) {
		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 {
		} else {
			pa = wil_rx_desc_get_addr_edma(&d->dma);
			rx_buff->skb = NULL;
			dmalen = le16_to_cpu(d->dma.length);
			memcpy(&pa, skb->cb, sizeof(pa));
			dma_unmap_single(dev, pa, dmalen, DMA_FROM_DEVICE);
			dma_unmap_single(dev, pa, wil->rx_buf_len,

					 DMA_FROM_DEVICE);
			kfree_skb(skb);
			kfree_skb(skb);
		}
		}


		/* Move the buffer from the active to the free list */
		/* Move the buffer from the active to the free list */
		list_move(&wil->rx_buff_mgmt.buff_arr[buff_id].list,
		list_move(&rx_buff->list, &wil->rx_buff_mgmt.free);
			  &wil->rx_buff_mgmt.free);
	}
	}
}
}