From owner-freebsd-hackers@FreeBSD.ORG Sun Jul 2 00:40:25 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1AA3A16A4B3 for ; Sun, 2 Jul 2006 00:40:25 +0000 (UTC) (envelope-from dwmalone@maths.tcd.ie) Received: from salmon.maths.tcd.ie (salmon.maths.tcd.ie [134.226.81.11]) by mx1.FreeBSD.org (Postfix) with SMTP id D00DE44A9D for ; Sat, 1 Jul 2006 19:44:37 +0000 (GMT) (envelope-from dwmalone@maths.tcd.ie) Received: from walton.maths.tcd.ie ([134.226.81.10] helo=walton.maths.tcd.ie) by salmon.maths.tcd.ie with SMTP id ; 1 Jul 2006 20:44:36 +0100 (BST) Date: Sat, 1 Jul 2006 20:44:35 +0100 From: David Malone To: Hans Petter Selasky Message-ID: <20060701194435.GA30115@walton.maths.tcd.ie> References: <200605271102.19799.hselasky@c2i.net> <200606302029.28563.hselasky@c2i.net> <20060630203226.GG734@turion.vk2pj.dyndns.org> <200607011044.54872.hselasky@c2i.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200607011044.54872.hselasky@c2i.net> User-Agent: Mutt/1.5.6i Sender: dwmalone@maths.tcd.ie Cc: freebsd-hackers@freebsd.org Subject: Re: contiguous memory allocation problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jul 2006 00:40:25 -0000 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 help? David. 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.