RE: [PATCH V3] usb: musb: host: Unmap the buffer for PIO data transfers

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

 



Maulik wrote:
> > -----Original Message-----
> > From: Alan Stern [mailto:stern@xxxxxxxxxxxxxxxxxxx]
> > Sent: Tuesday, August 24, 2010 8:30 PM
> > To: Maulik Mankad
> > Cc: linux-usb@xxxxxxxxxxxxxxx; Felipe Balbi
> > Subject: Re: [PATCH V3] usb: musb: host: Unmap the buffer for PIO data transfers
> > 
> > On Tue, 24 Aug 2010, Maulik Mankad wrote:
> > 
> > > The USB stack maps the buffer for DMA if the controller supports DMA.
> > > MUSB controller can perform DMA as well as PIO transfers.
> > > The buffer needs to be unmapped before CPU can perform
> > > PIO data transfers.
> > >
> > > Export unmap_urb_for_dma() so that drivers can perform
> > > the DMA unmapping in a sane way.
> > >
> > > Signed-off-by: Maulik Mankad <x0082077@xxxxxx>
> > > Cc: Felipe Balbi <felipe.balbi@xxxxxxxxx>
> > > Cc: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
> > > ---
> > > Based on 2.6.36-rc1
> > > V3: Fix Alan's comments.
> > >  drivers/usb/core/hcd.c       |    3 ++-
> > >  drivers/usb/musb/musb_host.c |    5 +++++
> > >  include/linux/usb/hcd.h      |    1 +
> > >  3 files changed, 8 insertions(+), 1 deletion(-)
> > 
> > > Index: mainline/include/linux/usb/hcd.h
> > > ===================================================================
> > > --- mainline.orig/include/linux/usb/hcd.h
> > > +++ mainline/include/linux/usb/hcd.h
> > > @@ -349,6 +349,7 @@ extern void usb_put_hcd(struct usb_hcd *
> > >  extern int usb_add_hcd(struct usb_hcd *hcd,
> > >  		unsigned int irqnum, unsigned long irqflags);
> > >  extern void usb_remove_hcd(struct usb_hcd *hcd);
> > > +extern void unmap_urb_for_dma(struct usb_hcd *, struct urb *);
> > 
> > Hmm.  Since this deals with an URB rather than with the host controller
> > itself, I would have put it just after usb_hcd_giveback_urb instead of
> > here.  Apart from this one drawback, it looks okay to me.
> 
> Ok will correct this.
> > 
> > By the way, which URBs do you need to unmap in this way?  Doesn't the
> > musb driver already tell the core not to map control URBs for DMA?
> > 
> 
> These are Bulk URB's. 
> 

The driver cannot handle carry out some bulk transfers using DMA
(for example, if we run out of DMA channels, or if the DMA start
adresses are not aligned to a 4-byte boundary). In this case, the
driver code falls back to carrying out those transfers using PIO.

This fallback code used to work earlier, but recent changes have
exposed bugs in the driver like having CPU accesses to buffers
that are mapped for the peripheral to DMA data into.

- Anand
--
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