From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 4 17:35:45 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6391716A468 for ; Wed, 4 Jul 2007 17:35:45 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (gate.funkthat.com [69.17.45.168]) by mx1.freebsd.org (Postfix) with ESMTP id E7F5913C44B for ; Wed, 4 Jul 2007 17:35:44 +0000 (UTC) (envelope-from jmg@hydrogen.funkthat.com) Received: from hydrogen.funkthat.com (anaa50glgw5srse9@localhost.funkthat.com [127.0.0.1]) by hydrogen.funkthat.com (8.13.6/8.13.3) with ESMTP id l64HZWu9077430; Wed, 4 Jul 2007 10:35:32 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.13.6/8.13.3/Submit) id l64HZWaG077429; Wed, 4 Jul 2007 10:35:32 -0700 (PDT) (envelope-from jmg) Date: Wed, 4 Jul 2007 10:35:31 -0700 From: John-Mark Gurney To: Hans Petter Selasky Message-ID: <20070704173531.GO1221@funkthat.com> Mail-Followup-To: Hans Petter Selasky , freebsd-hackers@freebsd.org, freebsd-usb@freebsd.org References: <200707040901.33019.hselasky@c2i.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200707040901.33019.hselasky@c2i.net> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD 5.4-RELEASE-p6 i386 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html Cc: freebsd-hackers@freebsd.org, freebsd-usb@freebsd.org Subject: Re: New USB stack and Zero copy. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John-Mark Gurney List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jul 2007 17:35:45 -0000 Hans Petter Selasky wrote this message on Wed, Jul 04, 2007 at 09:01 +0200: > I want to get rid of the copying between DMA'able memory and non-DMA'able > memory. > > Currently I allocate N memory-pages for each USB transfer like separate pages. How do you allocate these pages? With malloc(9) or w/ bus_dmamem_alloc(9)? > The bus-dma system then assigns all of these pages each their virtual > address. > > What I see is that when I allocate more than PAGE_SIZE bytes using bus-dma, I > get physically contiguous memory. I don't need that for the USB stack. That is a limitation of how bus_dma currently allocates memory... It calls contigmalloc, which doesn't handle multi-segment memory allocations yet.. > The question is: > > Should we change bus-dma to support so called scatter and gather allocations, > where the physical allocation is non-contiguous, and the virtual allocation > is contiguous accross all the scattered pages ? You can already support this by using malloc, and loading that buffer into your bus_dma map... or using the passing in userland buffer, and loading that into the map... > Also: How is the easiest way to load memory pages into DMA ? And I want that > the loadig works like this, that when the page must be bounced it should not > allocate a bounce buffer, hence I already have a bounce buffer. I only need > to know which pages I can forward directly to the USB hardware, and the rest > I will bounce somewhere else. Why do you not want to let bus_dma do the bouncing for you? If it's to save a copy to another buffer, why don't you load the final buffer into bus_dma? -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."