From owner-freebsd-hackers Mon Feb 24 2:58:16 2003 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 9D7FF37B401; Mon, 24 Feb 2003 02:58:14 -0800 (PST) Received: from heron.mail.pas.earthlink.net (heron.mail.pas.earthlink.net [207.217.120.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0616243F93; Mon, 24 Feb 2003 02:58:14 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from pool0041.cvx40-bradley.dialup.earthlink.net ([216.244.42.41] helo=mindspring.com) by heron.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 18nGJI-0005G4-00; Mon, 24 Feb 2003 02:58:13 -0800 Message-ID: <3E59FA6C.CF8CB852@mindspring.com> Date: Mon, 24 Feb 2003 02:56:44 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: David Schultz Cc: Byunghyun Oh , freebsd-hackers@FreeBSD.ORG Subject: Re: Replacement for get_user_pages() of Linux References: <20030223163746.A19421@shell.postech.ac.kr> <20030224100346.GA6374@HAL9000.homeunix.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a49bc7e577ba53e3c123e48e9157758690387f7b89c61deb1d350badd9bab72f9c350badd9bab72f9c Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG David Schultz wrote: > Thus spake Byunghyun Oh : > > I'm porting Plex86 x86 VM, which uses get_user_pages() function at > > Linux-version kernel module to find and pin physical pages of memory > > in user space (according to its documentation). I tried many > > candidates as its replacement (PHYS_TO_VM_PAGE() macro in vm/vm_page.h > > seems most useful now), but they haven't worked at all. > > > > Any experience about porting VM-related things in Linux will be > > appreciated. :) > > Glancing at the Linux source, it looks like you want vm_map_wire(). > BTW, in the future, it helps if you can describe what you're > looking for, since we're not all Linux experts. I'm pretty sure this isn't what he really wants, it's just what he thinks he wants, and he's wrong about it, but he hasn't told us what problem he's trying to solve, so that we can correct his misconception. In general, FreeBSD drivers DMA to pages for which there is an established kernel mapping, period. With specific exceptions, kernel pages are not pageable, and so they do not need to be wired (you have to go way out of your way to get pageable kernel memory; most people don't do it, and I'm not even sure UMA allows you to get this type of memory any more). No FreeBSD driver DMA's into user space address space directly, bypassing kernel space address space; either there is a kernel mapping AND a user mapping, or there is ONLY a kernel mapping. The closest FreeBSD ever comes to this is to map a set of kernel space allocated pages into a user process address space, by the process opening a device node, and calling mmap() on it. In a pinch, you can force this on the process from kernel space, so you don't have to rewrite your code (e.g. the code is running under Linux or other emulation), but this is really frowned upon. In this case, the memory is usually allocated directly to the device at the time the device is attached, e.g. the video memory in a VGA card, or the memory window onto the AGP in the agpart device. Then it is mapped into the user process address space (e.g. the XFree86 server process), and DMAs into that memory are implicitly DMAs into the user process address space. Again, it would be really, really nice to know what problem he is trying to solve, so that people who know FreeBSD can tell him the FreeBSD way of solving the problem. I suspect that he wants to use bus_dmamem_alloc(), bus_dmamap_create(), bus_dma_tag_create(), etc., and write a standard FreeBSD device driver for his device, so that it will work on things like Alpha, SPARC64, IA64, PPC, and other platforms which care about memory windows onto main memory via "bus space". Without knowing the problem he's trying to solve though... you get the point... -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message