From: Ian Campbell Subject: Re: PCI passthrough issue Date: Wed, 2 Feb 2011 15:55:55 +0000 Message-ID: <1296662155.13091.371.camel@zakaz.uk.xensource.com> References: <4D47F9CF.2040107@jbfavre.org> <1296566401.13091.171.camel@zakaz.uk.xensource.com> <4D4814CE.5050303@jbfavre.org> <1296569931.13091.194.camel@zakaz.uk.xensource.com> <4D48234F.2020907@jbfavre.org> <4D4828D9.6090601@jbfavre.org> <1296577389.13091.288.camel@zakaz.uk.xensource.com> <20110201193743.GA18656@dumpdata.com> <4D4890CD.7080009@jbfavre.org> <1296639869.13091.332.camel@zakaz.uk.xensource.com> <20110202153822.GA31878@dumpdata.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20110202153822.GA31878@dumpdata.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Konrad Rzeszutek Wilk Cc: Jean Baptiste Favre , "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org On Wed, 2011-02-02 at 15:38 +0000, Konrad Rzeszutek Wilk wrote: > > > Ping tests work whatever can be packet size. > > > > > > If I understood well what you explain to me, it's now clear that the > > > problem is somewhat Xen related, isn't it ? > > > > It certainly seems that way. I'm not 100% sure that swiotlb=force will > > have actually made the driver use the swiotlb, it may just have forced > > It should have. > > > the swiotlb to be allocated. Konrad? > > Both. It would allocate it and force all DMA operations to go through > the bounce buffer. > > Let me take a look at the driver itself. Ah, so I had a similar card: 3c59x > which hit the same type of failure way back in 2.6.31 time. It had the > pci_dma_sync_single_for_cpu(.. PCI_DMA_FROMDEVICE) turned around so it would never > copy properly. But in my tree (2.6.38) the sky driver looks to be doing just > right.. It has PCI_DMA_FROMDEVICE.. > > Well this looks odd: > > 2330 skb = netdev_alloc_skb_ip_align(sky2->netdev, length); > 2331 if (likely(skb)) { > 2332 pci_dma_sync_single_for_cpu(sky2->hw->pdev, re->data_addr, > 2333 length, PCI_DMA_FROMDEVICE); > =======> skb_copy_from_linear_data(re->skb, skb->data, length); <==== > 2335 skb->ip_summed = re->skb->ip_summed; > 2336 skb->csum = re->skb->csum; > 2337 pci_dma_sync_single_for_device(sky2->hw->pdev, re->data_addr, > 2338 length, PCI_DMA_FROMDEVICE); > 2339 re->skb->ip_summed = CHECKSUM_NONE; > 2340 skb_put(skb, length); > 2341 } > > It copies from skb->data (just allocated) to re->skb (seems that the re->skb->data > has been earlier DMA-mapped). > > But there is no data in skb->data as we just allocated it? Shouldn't this > be the other way around? Like this: skb_copy_from_linear_data's arguments are the other way round to what you may be expecting: static inline void skb_copy_from_linear_data(const struct sk_buff *skb, void *to, const unsigned int len) So the above line is correctly copying from re->skb->data to skb->data not the other way round. I stared at that exact line for ages this morning ;-) Ian.