Message ID | 20100831111052.31f22185@marrow.netinsight.se |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
On Tue, Aug 31, 2010 at 11:10:52AM +0200, Simon Kagstrom wrote: > On Mon, 30 Aug 2010 21:13:49 -0400 > Dave Jones <davej@redhat.com> wrote: > > > I installed the Fedora 14 alpha, which is based on 2.6.35.2, and hit > > the following trace.. > > > > WARNING: at lib/dma-debug.c:811 check_unmap+0x212/0x59b() > > Hardware name: > > via-velocity 0000:00:0e.0: DMA-API: device driver frees DMA memory with different size [device address=0x00000000194ba27e] [map size=66 bytes] [unmap size=182 bytes] > > I can't reproduce it here, but does the patch below help for you? It's looking good so far. It's been up 30 minutes and hasn't triggered yet (normally it triggers very shortly after bootup) Dave -- 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
On Tue, 31 Aug 2010 13:21:07 -0400 Dave Jones <davej@redhat.com> wrote: > On Tue, Aug 31, 2010 at 11:10:52AM +0200, Simon Kagstrom wrote: > > On Mon, 30 Aug 2010 21:13:49 -0400 > > Dave Jones <davej@redhat.com> wrote: > > > > > I installed the Fedora 14 alpha, which is based on 2.6.35.2, and hit > > > the following trace.. > > > > > > WARNING: at lib/dma-debug.c:811 check_unmap+0x212/0x59b() > > > Hardware name: > > > via-velocity 0000:00:0e.0: DMA-API: device driver frees DMA memory with different size [device address=0x00000000194ba27e] [map size=66 bytes] [unmap size=182 bytes] > > > > I can't reproduce it here, but does the patch below help for you? > > It's looking good so far. It's been up 30 minutes and hasn't triggered yet > (normally it triggers very shortly after bootup) Sounds good. I'll think a bit more about this and submit the patch after that. 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. // Simon -- 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
From: Simon Kagstrom <simon.kagstrom@netinsight.net> 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. -- 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
On Wed, Sep 01, 2010 at 01:03:33PM -0700, David Miller wrote: > From: Simon Kagstrom <simon.kagstrom@netinsight.net> > 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 -- 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
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index fd69095..305192e 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c @@ -1721,7 +1721,7 @@ static void velocity_free_tx_buf(struct velocity_info *vptr, /* For scatter-gather */ if (skb_shinfo(skb)->nr_frags > 0) pktlen = max_t(size_t, pktlen, - td->td_buf[i].size & ~TD_QUEUE); + skb_headlen(skb)); pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], le16_to_cpu(pktlen), PCI_DMA_TODEVICE);