contiguous memory allocation problem
dwmalone at maths.tcd.ie
Sun Jul 2 00:40:25 UTC 2006
On Sat, Jul 01, 2006 at 10:44:54AM +0200, Hans Petter Selasky wrote:
> > The latest concensus seems to be that the USB system should make use of
> > the scatter-gather facilities in the hardware to avoid the need to
> > allocate large contiguous memory chunks. iedowse@ had mostly finished
> > implementing this in mid May.
> Yes, but scatter and gather will add extra complexity to the driver, and maybe
> an extra memory copy in most cases. The idea is to allocate less than or
> equal to a page of memory, and then avoid the problem?
I believe the USB drivers in -current grew scatter/gather support
about a month ago. See the commit message below. Is this likely to
Use the limited scatter-gather capabilities of ehci, ohci and uhci
host controllers to avoid the need to allocate any multi-page
physically contiguous memory blocks. This makes it possible to use
USB devices reliably on low-memory systems or when memory is too
fragmented for contiguous allocations to succeed.
The USB subsystem now uses bus_dmamap_load() directly on the buffers
supplied by USB peripheral drivers, so this also avoids having to
copy data back and forth before and after transfers. The ehci and
ohci controllers support scatter/gather as long as the buffer is
contiguous in the virtual address space. For uhci the hardware
cannot handle a physical address discontinuity within a USB packet,
so it is necessary to copy small memory fragments at times.
More information about the freebsd-hackers