From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 4 14:26:29 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 316871065675 for ; Wed, 4 Feb 2009 14:26:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0028D8FC24 for ; Wed, 4 Feb 2009 14:26:28 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 8E1A346B0D; Wed, 4 Feb 2009 09:26:28 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n14EQG88059441; Wed, 4 Feb 2009 09:26:22 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Wed, 4 Feb 2009 09:00:23 -0500 User-Agent: KMail/1.9.7 References: <6699015.16785.1233539817447.JavaMail.root@vms063.mailsrvcs.net> <7d6fde3d0902020046o7640f217ye88336b53920a538@mail.gmail.com> <671bb5fc0902020823p3ee8d9edl715a074603ab97de@mail.gmail.com> In-Reply-To: <671bb5fc0902020823p3ee8d9edl715a074603ab97de@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902040900.24320.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 04 Feb 2009 09:26:22 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8950/Wed Feb 4 06:19:05 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Alexej Sokolov , Garrett Cooper Subject: Re: bus_dma (9). What exactly means "Loading of memory allocation" ? 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: Wed, 04 Feb 2009 14:26:29 -0000 On Monday 02 February 2009 11:23:33 am Alexej Sokolov wrote: > Hi, > thanx for your answer. I checked the source code of the *dma() functions. > If I understand it correctly, "loading of memory allocation" means the > following: > > 1. At first memory allocation should be done: bufp = *alloc(sizeof ....) > 2. then in ... _bus_dmamap_load_buffer() we get physical addres of allocated > buffer: > if (pmap) > curaddr = pmap_extract(pmap, vaddr); > else > curaddr = pmap_kextract(vaddr); > > ... then some "magic" with bouncing > > 3. then physical address will passed to dmat->segments > segs[seg].ds_addr = curaddr; > segs[seg].ds_len = sgsize; > > Ok, it all means: getting of physical address of allocated buffer. If > physical space not accessble for device, allocating bounce buffers. Getting > of physical addresses of allocated buffers. And then put these physical > addresses and sizes of buffers in dmat->segments array. <- loading of > memory allocation (-: Yes. On architectures with an IOMMU, the load may also program entries into the IOMMU for the specified buffer and then populate the S/G array with the associated DMA addresses (sparc64 uses this). I think the "load" name has more to do with this case in that you are "loading" a buffer into the DMA virtual address space (with IOMMUs you have a separate virtual address space for DMA that is not 1:1 with physical addresses as on i386 machines). If you look at bus_dma as basically implementing an abstract IOMMU on all architectures then it might make a bit more sense. -- John Baldwin