Re: [BUG] USB Host Stack and mixing DMA and PIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 3 Aug 2010, Praveena NADAHALLY wrote:

> Hello,

Can you please tell your email client to wrap lines after 72 columns or 
so?

> Some USB HOST chip drivers mix DMA and PIO mode. The USB Host core in Linux assumes that data is always DMA'ed, if the dev->dma_mask is non-zero, and will perform automatic cache operations on the data before and after all USB transfers. This works fine with chips like EHCI/OHCI, but breaks completely on chips like MUSB, which mix PIO and DMA. Our simple workaround is to set dev->dma_mask = 0, in the MUSB init code. Else we see regular data loss during loopback tests. We have been requested to make a better fix for this problem. Could the Linux community advice the places we need to patch, which gives us the possibility for the USB Host chip driver to fully manage cache sync/flush calls through a generalized API? The MUSB driver is an OTG driver, setting dev->dma_mask to zero will kill DMA operation in gadget mode, and is not a long term solution for us.

The easiest solution is to allow usbcore to map all transfer buffers 
for DMA, and then have the HCD call unmap_urb_for_dma in cases where 
it wants to use PIO.  (You'll have to make unmap_urb_for_dma non-static 
and EXPORT it first.  And you'll run into trouble if you want to use 
PIO with the Setup packet of a control transfer and DMA with the Data 
packet.)

A more complicated solution would be to add intelligence to 
map_urb_for_dma so that it would know which URBs will be handled by PIO 
even when the DMA mask is set.  This is a more fragile approach, 
because it relies on keeping the core code in sync with the HCD.

If necessary, you could add a new callback to struct hc_driver to be 
invoked by map_urb_for_dma.  The callback routine would return a value 
indicating whether the Setup and Data packets should be mapped.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux