Patchwork [06/11] de2104x: fix DMA sync_single length error

login
register
mail settings
Submitter stephen hemminger
Date Jan. 20, 2010, 8:45 p.m.
Message ID <20100120204559.177544514@vyatta.com>
Download mbox | patch
Permalink /patch/43368/
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>
Grant Grundler - Jan. 22, 2010, 1:02 a.m.
On Wed, Jan 20, 2010 at 12:45:05PM -0800, Stephen Hemminger wrote:
> The DMA api requires that the full mapping be sync'd when
> copying frame. First found by Jarek on sky2.

Are you referring to the example code in Documentation/PCI/PCI-DMA-mapping.txt?

I don't see any "Use the full mapping" statement otherwise.

Is there a DMA HW implementation that requires the syncing full buffer?

I think it would be interesting to point that out in the commit comments
since other NIC drivers are likely to also have this issue as well.

I have no objection to this patch. Just want to be clear why
it's being pushed.

Please added Acked-by: Grant Grundler <grundler@parisc-linux.org>

thanks,
grant


> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> --- a/drivers/net/tulip/de2104x.c	2010-01-20 11:41:20.878138314 -0800
> +++ b/drivers/net/tulip/de2104x.c	2010-01-20 11:41:59.858847380 -0800
> @@ -456,11 +456,13 @@ static void de_rx (struct de_private *de
>  					       buflen, PCI_DMA_FROMDEVICE);
>  			de->rx_skb[rx_tail].skb = copy_skb;
>  		} else {
> -			pci_dma_sync_single_for_cpu(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
> +			pci_dma_sync_single_for_cpu(de->pdev, mapping,
> +						    buflen, PCI_DMA_FROMDEVICE);
>  			skb_reserve(copy_skb, RX_OFFSET);
>  			skb_copy_from_linear_data(skb, skb_put(copy_skb, len),
>  						  len);
> -			pci_dma_sync_single_for_device(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
> +			pci_dma_sync_single_for_device(de->pdev, mapping,
> +						       buflen, PCI_DMA_FROMDEVICE);
>  
>  			/* We'll reuse the original ring buffer. */
>  			skb = copy_skb;
> 
> -- 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
stephen hemminger - Jan. 22, 2010, 1:12 a.m.
On Thu, 21 Jan 2010 18:02:44 -0700
Grant Grundler <grundler@parisc-linux.org> wrote:

> On Wed, Jan 20, 2010 at 12:45:05PM -0800, Stephen Hemminger wrote:
> > The DMA api requires that the full mapping be sync'd when
> > copying frame. First found by Jarek on sky2.
> 
> Are you referring to the example code in Documentation/PCI/PCI-DMA-mapping.txt?
> 
> I don't see any "Use the full mapping" statement otherwise.
> 
> Is there a DMA HW implementation that requires the syncing full buffer?
> 
> I think it would be interesting to point that out in the commit comments
> since other NIC drivers are likely to also have this issue as well.
> 
> I have no objection to this patch. Just want to be clear why
> it's being pushed.
> 
> Please added Acked-by: Grant Grundler <grundler@parisc-linux.org>

The documentation was in DMA-API.txt and it was wrong.
The DMA debug library was enforcing a bogus restriction.
Dave correctly dropped the patch.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

--- a/drivers/net/tulip/de2104x.c	2010-01-20 11:41:20.878138314 -0800
+++ b/drivers/net/tulip/de2104x.c	2010-01-20 11:41:59.858847380 -0800
@@ -456,11 +456,13 @@  static void de_rx (struct de_private *de
 					       buflen, PCI_DMA_FROMDEVICE);
 			de->rx_skb[rx_tail].skb = copy_skb;
 		} else {
-			pci_dma_sync_single_for_cpu(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
+			pci_dma_sync_single_for_cpu(de->pdev, mapping,
+						    buflen, PCI_DMA_FROMDEVICE);
 			skb_reserve(copy_skb, RX_OFFSET);
 			skb_copy_from_linear_data(skb, skb_put(copy_skb, len),
 						  len);
-			pci_dma_sync_single_for_device(de->pdev, mapping, len, PCI_DMA_FROMDEVICE);
+			pci_dma_sync_single_for_device(de->pdev, mapping,
+						       buflen, PCI_DMA_FROMDEVICE);
 
 			/* We'll reuse the original ring buffer. */
 			skb = copy_skb;