Re: [PATCH][1/2] usb: dma bounce buffer support V3
"Magnus Damm" <[email protected]> Tue, 22 Jan 2008 15:50:58 +0900
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
On Jan 22, 2008 3:25 PM, Andrew Morton <[email protected]> wrote: > > On Tue, 22 Jan 2008 15:12:53 +0900 "Magnus Damm" <[email protected]> wrote: > > > On Jan 22, 2008 2:01 PM, Andrew Morton <[email protected]> wrote: > > > On Tue, 22 Jan 2008 12:20:10 +0900 Magnus Damm <[email protected]> wrote: > > > > > > > usb: dma bounce buffer support V3 > > > > > > > > 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(). > > > > > > It is unobvious (to me) why this code uses put_unaligned() and > > > get_unaligned() in the places where it does. So I'll assume that it will > > > be unobvious to other reviewers and readers. > > > > The HCD_LOCAL_MEM dma bounce buffer code is using unaligned functions > > to temporarily save a pointer at the end of the dma data buffer. > > hcd_alloc_coherent() saves the pointer which is needed by > > hcd_free_coherent(). The unaligned functions are used because the size > > of the buffer may be uneven. > > > > It's of course possible to round up the size instead and use aligned > > access if you prefer that. The memory area used for dma may be limited > > though so I felt it was natural to optimize for small memory footprint > > over access speed. > > that wasn't a patch ;) Gotcha. Sorry about the attachment - I have no idea how to reply inline and not mangle patches using gmail... / 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/ _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
linux-2.6.25-pre-usb-local-mem-comment-fix-20080122.patch
(application/octet-stream, 631 B)
--- 0005/drivers/usb/core/hcd.c +++ work/drivers/usb/core/hcd.c 2008-01-22 15:40:32.000000000 +0900 @@ -1125,6 +1125,14 @@ static int hcd_alloc_coherent(struct usb if (!vaddr) return -ENOMEM; + /* + * Store the virtual address of the buffer at the end + * of the allocated dma buffer. The size of the buffer + * may be uneven so use unaligned functions instead + * of just rounding up. It makes sense to optimize for + * memory footprint over access speed since the amount + * of memory available for dma may be limited. + */ put_unaligned((unsigned long)*vaddr_handle, (unsigned long *)(vaddr + size));