Google
  Web www.spinics.net

Re: [PATCH] usb: dma bounce buffer support V2

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


On Jan 18, 2008 12:13 AM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, 17 Jan 2008, Magnus Damm wrote:
>
> > usb: dma bounce buffer support V2
> >
> > This patch adds dma bounce buffer support to the usb core. These buffers
> > can be enabled with the HCD_LOCAL_MEM flag, and they make sure that all data
> > passed to the host controller is allocated using dma_alloc_coherent().
>
> This looks good.  Just one little change:
>
> > +static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
> > +                        gfp_t mem_flags)
> > +{
> ...
>
> > +     if (ret == 0 && urb->transfer_buffer_length != 0
> > +         && !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) {
> > +             if (hcd->self.uses_dma)
> >                       urb->transfer_dma = dma_map_single (
> >                                       hcd->self.controller,
> >                                       urb->transfer_buffer,
> >                                       urb->transfer_buffer_length,
> > -                                     usb_urb_dir_in(urb)
> > -                                         ? DMA_FROM_DEVICE
> > -                                         : DMA_TO_DEVICE);
> > +                                     dir);
> > +             else if (hcd->driver->flags & HCD_LOCAL_MEM)
> > +                     ret = hcd_alloc_coherent(
> > +                                     urb->dev->bus, mem_flags,
> > +                                     &urb->transfer_dma,
> > +                                     &urb->transfer_buffer,
> > +                                     urb->transfer_buffer_length,
> > +                                     dir);
> > +
> > +             if (ret && usb_endpoint_xfer_control(&urb->ep->desc)
> > +                 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)
> > +                 && (hcd->driver->flags & HCD_LOCAL_MEM))
> > +                     hcd_free_coherent(urb->dev->bus,
> > +                                       &urb->setup_dma,
> > +                                       (void **)&urb->setup_packet,
> > +                                       sizeof (struct usb_ctrlrequest),
> > +                                       DMA_TO_DEVICE);
>
> This last section should be in the scope of the HCD_LOCAL_MEM test above.

Good idea. I'll repost V3 of this patch in a little while. Thanks for
your patience!

/ magnus

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
linux-usb-devel@xxxxxxxxxxxxxxxxxxxxx
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

[Home]     [Video for Linux]     [Photo]     [Yosemite Forum]     [Yosemite Photos]    [Video Projectors]     [PDAs]     [Hacking TiVo]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Devices]     [Big List of Linux Books]     [Free Dating]

  Powered by Linux