On Tuesday 22 May 2007, Oliver Neukum wrote:
> Am Dienstag, 22. Mai 2007 15:28 schrieb Laurent Pinchart:
> > I'd like to change usb_buffer_alloc to make it a general purpose
> > allocator. A parameter would tell the function to just allocate memory
> > (default behaviour)
>
> Nope. What for? We avoid such flags if we can. If you need two version,
> create two functions.

Ok

> And before that, what's the advantage over kmalloc? 

Buffer allocation could then be fine-tuned using information that USB device 
drivers should care about. For instance, on systems with a PIO HCD, buffers 
could be vmalloc'ed.

My idea was to have a general purpose URB buffer allocation function that all 
(most?) drivers could use, with flags (or another function) for specific 
cases. usb_buffer_alloc is currently used by some drivers when they should 
use kmalloc. The function is documented as a general purpose URB buffer 
allocator. Even if we fixed all drivers today to use kmalloc when they 
should, I'm pretty sure some new drivers will use usb_buffer_alloc.

The alternative is to clearly document that URB buffer allocation should be 
done with kmalloc, and rename usb_buffer_alloc to 
usb_alloc_coherent_dma_buffer like Alan suggests. Even then some people might 
still use it when they shouldn't. Some USB drivers developers have no 
knowledge of DMA, and will just look around for anything that looks like a 
buffer allocator. Providing a general-purpose buffer allocator would in my 
opinion help avoiding those mistakes.

Laurent Pinchart

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to