netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>,
	Jarek Poplawski <jarkao2@gmail.com>,
	Francois Romieu <romieu@fr.zoreil.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH 04/11] r8169: fix DMA sync_single length error
Date: Wed, 20 Jan 2010 12:45:03 -0800	[thread overview]
Message-ID: <20100120204559.039197464@vyatta.com> (raw)
In-Reply-To: 20100120204459.820265084@vyatta.com

[-- Attachment #1: r8169-dmar-error.patch --]
[-- Type: text/plain, Size: 1623 bytes --]

The DMA api requires that the full mapping be sync'd when
copying frame. First found by Jarek on sky2.

Get rid of unnecessary flag variable and move sync for
device to logical place next to sync_for_cpu

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

--- a/drivers/net/r8169.c	2010-01-20 10:12:22.488138228 -0800
+++ b/drivers/net/r8169.c	2010-01-20 10:15:21.199555458 -0800
@@ -4437,22 +4437,21 @@ static inline bool rtl8169_try_rx_copy(s
 				       dma_addr_t addr)
 {
 	struct sk_buff *skb;
-	bool done = false;
 
 	if (pkt_size >= rx_copybreak)
-		goto out;
+		return false;
 
 	skb = netdev_alloc_skb_ip_align(tp->dev, pkt_size);
 	if (!skb)
-		goto out;
+		return false;
 
-	pci_dma_sync_single_for_cpu(tp->pci_dev, addr, pkt_size,
+	pci_dma_sync_single_for_cpu(tp->pci_dev, addr, tp->rx_buf_sz,
 				    PCI_DMA_FROMDEVICE);
 	skb_copy_from_linear_data(*sk_buff, skb->data, pkt_size);
 	*sk_buff = skb;
-	done = true;
-out:
-	return done;
+	pci_dma_sync_single_for_device(tp->pci_dev, addr, tp->rx_buf_sz,
+				       PCI_DMA_FROMDEVICE);
+	return true;
 }
 
 static int rtl8169_rx_interrupt(struct net_device *dev,
@@ -4512,11 +4511,9 @@ static int rtl8169_rx_interrupt(struct n
 
 			rtl8169_rx_csum(skb, desc);
 
-			if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr)) {
-				pci_dma_sync_single_for_device(pdev, addr,
-					pkt_size, PCI_DMA_FROMDEVICE);
+			if (rtl8169_try_rx_copy(&skb, tp, pkt_size, addr))
 				rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
-			} else {
+			else {
 				pci_unmap_single(pdev, addr, tp->rx_buf_sz,
 						 PCI_DMA_FROMDEVICE);
 				tp->Rx_skbuff[entry] = NULL;

-- 


  parent reply	other threads:[~2010-01-20 21:23 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20 20:44 [PATCH 00/11] DMA sync errors Stephen Hemminger
2010-01-20 20:45 ` [PATCH 01/11] tg3: fix DMA sync_single length error Stephen Hemminger
2010-01-20 20:45 ` [PATCH 02/11] sky2: " Stephen Hemminger
2010-01-20 21:32   ` Jarek Poplawski
2010-01-20 22:52     ` David Miller
2010-01-20 23:21       ` Jarek Poplawski
2010-01-20 23:34         ` David Miller
2010-01-20 23:41           ` David Miller
2010-01-20 23:59             ` Jarek Poplawski
2010-01-21  0:04               ` Stephen Hemminger
2010-01-21  0:15                 ` David Miller
2010-01-20 23:52           ` Jarek Poplawski
2010-01-20 23:56             ` David Miller
2010-01-20 20:45 ` [PATCH 03/11] skge: " Stephen Hemminger
2010-01-20 20:45 ` Stephen Hemminger [this message]
2010-01-20 20:45 ` [PATCH 05/11] rrunner: " Stephen Hemminger
2010-01-20 20:45 ` [PATCH 06/11] de2104x: " Stephen Hemminger
2010-01-22  1:02   ` Grant Grundler
2010-01-22  1:12     ` Stephen Hemminger
2010-01-20 20:45 ` [PATCH 07/11] sungem: " Stephen Hemminger
2010-01-20 20:45 ` [PATCH 08/11] sunhme: " Stephen Hemminger
2010-01-20 20:45 ` [PATCH 09/11] cassini: " Stephen Hemminger
2010-01-20 20:45 ` [PATCH 10/11] cxgb3: " Stephen Hemminger
2010-01-20 20:45 ` [PATCH 11/11] ipoib: " Stephen Hemminger
2010-01-20 22:46 ` [PATCH 00/11] DMA sync errors David Miller
2010-01-20 23:28   ` Stephen Hemminger
2010-01-21  0:18     ` David Miller
2010-01-21  0:34       ` Stephen Hemminger
2010-01-21  0:36         ` David Miller
2010-01-21 12:44         ` Jarek Poplawski
2010-01-21 13:12           ` David Miller

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=20100120204559.039197464@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=jarkao2@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=romieu@fr.zoreil.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).