[alsa-devel] USB transfer_buffer allocations on 64bit systems

Alan Stern stern at rowland.harvard.edu
Wed Apr 7 18:04:33 CEST 2010

On Wed, 7 Apr 2010, Greg KH wrote:

> > FWIW, most drivers I've seen in the past hours use a wild mix of
> > kmalloc(), kzalloc(), kcalloc() and usb_buffer_alloc(). That should
> > really be unified.

Well, kcalloc can easily be replaced by kzalloc, right?  Or the 

The extra overhead of initializing the memory to 0 isn't present in 
kmalloc, so we need to maintain the distinction between kmalloc and 

However usb_buffer_alloc is fundmentally different from all the others.

> Yes, if it is necessary that we have to handle this type of crappy
> hardware, then it all needs to be unified.  Or at least unified into 2
> types of calls, one that needs the bounce buffer fun (what
> usb_buffer_alloc() does today), and one that doesn't (usb_kzalloc()
> perhaps?)

usb_buffer_alloc has very little to do with bounce buffers.  Its 
purpose is to allocate dma-consistent memory, that it, memory which 
does not need to be mapped for DMA before each I/O operation and 
unmapped afterward.

The mapping and unmapping operations aren't extremely time consuming,
so in general it makes sense to avoid them only when the _same_ buffer
is going to be used for many I/O operations during a short period of
time.  For instance, it makes sense for audio and video, where all the
data streams through a small set of buffers arranged in a ring.

But for most other uses it makes no sense.  Especially since some 
platforms have limited amounts of consistent memory available.

Alan Stern

More information about the Alsa-devel mailing list