From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 10 13:49:30 2010 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 E0DE2106566B for ; Wed, 10 Mar 2010 13:49:30 +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 B64DE8FC08 for ; Wed, 10 Mar 2010 13:49:30 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 71D1846B1A; Wed, 10 Mar 2010 08:49:30 -0500 (EST) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id 967008A01F; Wed, 10 Mar 2010 08:49:29 -0500 (EST) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Wed, 10 Mar 2010 07:53:14 -0500 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201003100753.14092.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Wed, 10 Mar 2010 08:49:29 -0500 (EST) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.6 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: son goku Subject: Re: physio and vmapbuf 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, 10 Mar 2010 13:49:31 -0000 On Wednesday 10 March 2010 6:40:18 am son goku wrote: > Hi hackers, > I have some experience with other UNIX kernels but none with FreeBSD. > FreeBSD interests me for a potential project I might be involved in , and > therefore I started researching it. > Browsing through the I/O layer code, I stumbled upon something that looked > strange, and perhaps you guys can help me with it. > Mainly, when reading the physio path, when the I/O buffer is from user-mode, > physio calls vmapbuf. The comments says that vmapbuf actually maps the > user-buffer into kernel address space. From my experience, such mapping is > needed only for very old devices that use PIO. Newer device just use DMA for > data copy, and therefore don't need the mapping, instead they just need to > pin the memory. Checking out vmapbuf only confused me further, I couldn't > find where such kernel mapping was taken place, nevertheless I did saw that > the buf->b_data was updated according to buf->b_saveaddr in some weird > offset calculation. > Adding to this confusion, there is a buf field called b_kvabase which > supposedly stores the kernel virtual address which wasn't touched at all!! > > Any help with understanding the flow and the usage of those fields/variables > will be greatly appreciated!! bus_dma (which drivers use to manage DMA), still uses virtual addressed buffers to build scatter/gather lists of physical addresses for DMA transfers. There has been much discussion and some prototype work to change this, but it's not a trivial project. (I have converted physio to using bio's backed by sglist's with no kernel addresses in a prototype branch in p4 for example.) -- John Baldwin