Subject: Re: via-velocity dma-debug warnings again. (2.6.35.2)

From: Dave Jones <[email-masked]>
Date: Wed, 1 Sep 2010 16:05:55 -0400

On Wed, Sep 01, 2010 at 01:03:33PM -0700, David Miller wrote:
 > From: Simon Kagstrom <[email-masked]>
 > Date: Wed, 1 Sep 2010 12:20:59 +0200
 > 
 > > I'm not really an expert on the subject, but with skb_headlen(), the size
 > > should be the same for pci_map_single and pci_unmap_single as far as I
 > > can tell.
 > 
 > That's not the case.
 > 
 > You'll have to use exactly the same formula for computing the length
 > as the pci_map_single() call uses, which is:
 > 
 > 	pktlen = skb_shinfo(skb)->nr_frags == 0 ?
 > 			max_t(unsigned int, skb->len, ETH_ZLEN) :
 > 				skb_headlen(skb);
 > 
 > Otherwise packets smaller than ETH_ZLEN will be unmapped properly
 > and trigger the same kind of debugging checks Dave is seeing.

Looks like you're right.

[ 5674.506024] via-velocity 0000:00:0e.0: DMA-API: device driver frees DMA memory with different size [device address=0x0000000018e555fa] [map size=54 bytes] [unmap size=108 bytes]

	Dave