From owner-freebsd-arch Wed Jan 29 10:42:23 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D431E37B401 for ; Wed, 29 Jan 2003 10:42:21 -0800 (PST) Received: from angelica.unixdaemons.com (angelica.unixdaemons.com [209.148.64.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id 764DB43F93 for ; Wed, 29 Jan 2003 10:42:20 -0800 (PST) (envelope-from hiten@angelica.unixdaemons.com) Received: from angelica.unixdaemons.com (hiten@localhost.unixdaemons.com [127.0.0.1]) by angelica.unixdaemons.com (8.12.7/8.12.1) with ESMTP id h0TIgBa6071044; Wed, 29 Jan 2003 13:42:11 -0500 (EST) Received: (from hiten@localhost) by angelica.unixdaemons.com (8.12.7/8.12.1/Submit) id h0TIgBHk071043; Wed, 29 Jan 2003 13:42:11 -0500 (EST) (envelope-from hiten) Date: Wed, 29 Jan 2003 13:42:11 -0500 From: Hiten Pandya To: Scott Long Cc: arch@FreeBSD.ORG Subject: Re: bus_dmamem_alloc_size() Message-ID: <20030129184211.GA70010@unixdaemons.com> References: <3E35DE8E.2080706@btc.adaptec.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3E35DE8E.2080706@btc.adaptec.com> User-Agent: Mutt/1.4i X-Operating-System: FreeBSD i386 X-Public-Key: http://www.pittgoth.com/~hiten/pubkey.asc X-URL: http://www.unixdaemons.com/~hiten X-PGP: http://pgp.mit.edu:11371/pks/lookup?search=Hiten+Pandya&op=index Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Jan 27, 2003 at 06:36:14PM -0700, Scott Long wrote the words in effect of: > 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. NetBSD had added a size parameter to their bus_dmamem_alloc() at some point. It was merged from thorpej's branch. We should probably do the same, but I think this will be a harder/tedious task. JFYI. Cheers. -- Hiten Pandya (hiten@unixdaemons.com, hiten@uk.FreeBSD.org) http://www.unixdaemons.com/~hiten/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message