All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Fietkau <nbd@openwrt.org>
To: netdev@vger.kernel.org
Cc: zajec5@gmail.com, hauke@hauke-m.de, eric.dumazet@gmail.com
Subject: [PATCH v3 4/9] bgmac: simplify rx DMA error handling
Date: Sun, 12 Apr 2015 23:38:26 +0200	[thread overview]
Message-ID: <1428874711-23950-4-git-send-email-nbd@openwrt.org> (raw)
In-Reply-To: <1428874711-23950-1-git-send-email-nbd@openwrt.org>

Unmap the DMA buffer before checking it. If it is poisoned, map it again
and pass it back to the hardware.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
---
 drivers/net/ethernet/broadcom/bgmac.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index e332de8..e004588 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -405,25 +405,20 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 		u16 len, flags;
 
 		/* Unmap buffer to make it accessible to the CPU */
-		dma_sync_single_for_cpu(dma_dev, slot->dma_addr,
-					BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
+		dma_unmap_single(dma_dev, slot->dma_addr,
+				 BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
 
 		/* Get info from the header */
 		len = le16_to_cpu(rx->len);
 		flags = le16_to_cpu(rx->flags);
 
 		do {
-			dma_addr_t old_dma_addr = slot->dma_addr;
 			int err;
 
 			/* Check for poison and drop or pass the packet */
 			if (len == 0xdead && flags == 0xbeef) {
 				bgmac_err(bgmac, "Found poisoned packet at slot %d, DMA issue!\n",
 					  ring->start);
-				dma_sync_single_for_device(dma_dev,
-							   slot->dma_addr,
-							   BGMAC_RX_BUF_SIZE,
-							   DMA_FROM_DEVICE);
 				break;
 			}
 
@@ -436,18 +431,8 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 				/* Poison the old skb */
 				rx->len = cpu_to_le16(0xdead);
 				rx->flags = cpu_to_le16(0xbeef);
-
-				dma_sync_single_for_device(dma_dev,
-							   slot->dma_addr,
-							   BGMAC_RX_BUF_SIZE,
-							   DMA_FROM_DEVICE);
 				break;
 			}
-			bgmac_dma_rx_setup_desc(bgmac, ring, ring->start);
-
-			/* Unmap old skb, we'll pass it to the netfif */
-			dma_unmap_single(dma_dev, old_dma_addr,
-					 BGMAC_RX_BUF_SIZE, DMA_FROM_DEVICE);
 
 			skb = build_skb(buf, BGMAC_RX_ALLOC_SIZE);
 			skb_put(skb, BGMAC_RX_FRAME_OFFSET +
@@ -461,6 +446,8 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring,
 			handled++;
 		} while (0);
 
+		bgmac_dma_rx_setup_desc(bgmac, ring, ring->start);
+
 		if (++ring->start >= BGMAC_RX_RING_SLOTS)
 			ring->start = 0;
 
-- 
2.2.2

  parent reply	other threads:[~2015-04-12 21:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-12 21:38 [PATCH v3 1/9] bgmac: simplify tx ring index handling Felix Fietkau
2015-04-12 21:38 ` [PATCH v3 2/9] bgmac: leave interrupts disabled as long as there is work to do Felix Fietkau
2015-04-12 21:38 ` [PATCH v3 3/9] bgmac: set received skb headroom to NET_SKB_PAD Felix Fietkau
2015-04-12 21:38 ` Felix Fietkau [this message]
2015-04-12 21:38 ` [PATCH v3 5/9] bgmac: add check for oversized packets Felix Fietkau
2015-04-12 21:38 ` [PATCH v3 6/9] bgmac: increase rx ring size from 511 to 512 Felix Fietkau
2015-04-12 21:38 ` [PATCH v3 7/9] bgmac: simplify dma init/cleanup Felix Fietkau
2015-04-12 22:53   ` Francois Romieu
2015-04-12 21:38 ` [PATCH v3 8/9] bgmac: fix DMA rx corruption Felix Fietkau
2015-04-12 21:38 ` [PATCH v3 9/9] bgmac: drop ring->num_slots Felix Fietkau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428874711-23950-4-git-send-email-nbd@openwrt.org \
    --to=nbd@openwrt.org \
    --cc=eric.dumazet@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=netdev@vger.kernel.org \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.