> -----Original Message----- > From: linux-usb-owner@xxxxxxxxxxxxxxx [mailto:linux-usb-owner@xxxxxxxxxxxxxxx] On Behalf Of Alan > Stern > Sent: Friday, March 19, 2010 10:03 PM > To: Gadiyar, Anand > Cc: Felipe Balbi; USB list > Subject: RE: DMA versus PIO > > On Fri, 19 Mar 2010, Gadiyar, Anand wrote: > > > > Felipe: > > > > > > There's a comment in message.c:usb_sg_init() about some systems needing > > > to revert to PIO when DMA is temporarily unavailable. Does this refer > > > to the musb drivers? Or if not, do you know which drivers it does > > > refer to? > > > > > > This is something we have to be careful about. The CPU generally isn't > > > allowed to access buffers while they are mapped for DMA. If the > > > controller driver needs to use PIO instead of DMA, then it will have to > > > unmap the buffers first. > > > > > > > Alan, > > > > Yes, MUSB is one such driver that could potentially revert to PIO > > when DMA is unavailable. > > > > One of the DMA engines used with MUSB has 8 DMA channels. If all of > > them are in use, then some transfers are carried out using PIO. > > > > > > Also, if the DMA programming call returns an error, then the transfer > > is attempted using PIO. > > > > For a long time, the DMA code never had any error returns added, but > > the backup PIO path was still present in the code. A short while ago, > > I introduced a patch to workaround a hardware bug - this patch > > would make the DMA programming call return failure, and force the > > trasnsfer to be carried out using PIO. (This patch is now in mainline) > > > > After this patch was merged into internal codebases, someone recently > > pointed out that this approach is not correct, and I cannot mix and > > match DMA and PIO accesses the way we're doing it in the driver. > > > > > > I'm afraid I don't understand the DMA APIs very well and their usage > > in the MUSB driver. I still need to study them. > > > > Thanks for pointing this out. > > You shouldn't need to understand much about the DMA APIs in order to > use it in the MUSB driver; usbcore will take care of the details for > you. All you need to know is that when a buffer is mapped for DMA, the > device owns it and the CPU mustn't access the buffer again until it is > unmapped. > > So to fix the issue, all you should need to do is unmap the buffers > before using them with PIO. (Or not map them in the first place if you > know beforehand that PIO will be used.) The code to do this still has > to be added to usbcore and to MUSB. > There was already patch proposed for this on USB list but it was suggested to have two flags approach. http://marc.info/?l=linux-usb&m=126639833626752&w=2 Regards, Santosh -- 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