From owner-freebsd-arch Mon Jan 27 17:39:39 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 7B31F37B401 for ; Mon, 27 Jan 2003 17:39:38 -0800 (PST) Received: from magic.adaptec.com (magic.adaptec.com [208.236.45.80]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04A0243F79 for ; Mon, 27 Jan 2003 17:39:38 -0800 (PST) (envelope-from scott_long@btc.adaptec.com) Received: from redfish.adaptec.com (redfish.adaptec.com [162.62.50.11]) by magic.adaptec.com (8.11.6+Sun/8.11.6) with ESMTP id h0S1dbD12976 for ; Mon, 27 Jan 2003 17:39:37 -0800 (PST) Received: from btc.btc.adaptec.com (btc.btc.adaptec.com [10.100.0.52]) by redfish.adaptec.com (8.8.8+Sun/8.8.8) with ESMTP id RAA09125 for ; Mon, 27 Jan 2003 17:39:27 -0800 (PST) Received: from btc.adaptec.com (hollin [10.100.253.56]) by btc.btc.adaptec.com (8.8.8+Sun/8.8.8) with ESMTP id SAA24782 for ; Mon, 27 Jan 2003 18:39:24 -0700 (MST) Message-ID: <3E35DE8E.2080706@btc.adaptec.com> Date: Mon, 27 Jan 2003 18:36:14 -0700 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.3a) Gecko/20030127 X-Accept-Language: en-us, en MIME-Version: 1.0 To: arch@freebsd.org Subject: bus_dmamem_alloc_size() Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 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