Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jan 2003 18:36:14 -0700
From:      Scott Long <scott_long@btc.adaptec.com>
To:        arch@freebsd.org
Subject:   bus_dmamem_alloc_size()
Message-ID:  <3E35DE8E.2080706@btc.adaptec.com>

next in thread | raw e-mail | index | archive | help
All,

With the ongoing effort to convert all of our drivers to busdma, it's
becoming painfully apparrent that bus_dmamem_alloc() needs to
be able to specify the size of the buffer to create, and not just
default to the max_size field of the dma tag.  The reason is that a
lot of simple hardware out there do understand scatter-gather lists,
so any data passed to them must be physically contiguous in a
single segment.  This in turn means that drivers need to allocate a
single segment buffer via busdma and copy their i/o contents
into/out of it when talking to the card.  These i/o lengths are often
extremely variable in size.  Without the ability to allocate variable
sized buffers, you're forced to either create a custom dma tag per
i/o transaction, or pre-allocate a huge chunk up front and do your
own sub allocations out of it.  Both are rather tedious and
inefficient.

So, how about adding a method called bus_dmamem_alloc_size()
that takes the normal arguments of bus_dmamem_alloc(), plus an
allocation size.  Driver writers would still be encouraged to be smart
about memory management since contigmalloc() would still be the
underlying allocator, and contigmalloc rounds all requests up
PAGE_SIZE.

Patches to do this are trivial and can be provided on request.  If
I don't hear any arguments against this, I'll commit it this week.
In case anyone cares, the my motivation for this comes from trying
to convert the usb driver to busdma.

Scott


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E35DE8E.2080706>