Patchwork [07/11] sungem: fix DMA sync_single length error

login
register
mail settings
Submitter stephen hemminger
Date Jan. 20, 2010, 8:45 p.m.
Message ID <20100120204559.246153541@vyatta.com>
Download mbox | patch
Permalink /patch/43371/
State Rejected
Delegated to: David Miller
Headers show

Comments

stephen hemminger - Jan. 20, 2010, 8:45 p.m.
The DMA api requires that the full mapping be sync'd when
copying frame. First found by Jarek on sky2.

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

Patch

--- a/drivers/net/sungem.c	2010-01-20 11:43:58.779387706 -0800
+++ b/drivers/net/sungem.c	2010-01-20 11:52:50.398529616 -0800
@@ -847,9 +847,13 @@  static int gem_rx(struct gem *gp, int wo
 
 			skb_reserve(copy_skb, 2);
 			skb_put(copy_skb, len);
-			pci_dma_sync_single_for_cpu(gp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
+			pci_dma_sync_single_for_cpu(gp->pdev, dma_addr,
+						    RX_BUF_ALLOC_SIZE(gp),
+						    PCI_DMA_FROMDEVICE);
 			skb_copy_from_linear_data(skb, copy_skb->data, len);
-			pci_dma_sync_single_for_device(gp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
+			pci_dma_sync_single_for_device(gp->pdev, dma_addr,
+						       RX_BUF_ALLOC_SIZE(gp),
+						       PCI_DMA_FROMDEVICE);
 
 			/* We'll reuse the original ring buffer. */
 			skb = copy_skb;