From owner-freebsd-hackers Tue Aug 15 23:24:54 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mass.osd.bsdi.com (adsl-63-202-177-115.dsl.snfc21.pacbell.net [63.202.177.115]) by hub.freebsd.org (Postfix) with ESMTP id 74BC237C308 for ; Tue, 15 Aug 2000 23:24:31 -0700 (PDT) (envelope-from msmith@mass.osd.bsdi.com) Received: from mass.osd.bsdi.com (localhost [127.0.0.1]) by mass.osd.bsdi.com (8.9.3/8.9.3) with ESMTP id XAA18026; Tue, 15 Aug 2000 23:36:35 -0700 (PDT) (envelope-from msmith@mass.osd.bsdi.com) Message-Id: <200008160636.XAA18026@mass.osd.bsdi.com> X-Mailer: exmh version 2.1.1 10/15/1999 To: "Bill Clinton" Cc: freebsd-hackers@freebsd.org Subject: Re: dma to userland address In-reply-to: Your message of "Mon, 14 Aug 2000 18:16:09 GMT." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 15 Aug 2000 23:36:35 -0700 From: Mike Smith Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > lets say, hypothetically, that i have an ioctl interface to my device > driver that takes a buffer that looks something like: > > struct { > int length; > char *buf; > } mystruct; > > and lets say, hypothetically, that i wanted to dma directly > to/from 'buf'. how would i do that? > > i've tried doing vtophys on buf, but that doesn't seem to work. > > i've tried doing vtophys on a kernel-allocated block and the mmapping it > through /dev/mem in userland, but that doesn't seem to work either (this > may have a bug, though - it worked under linux, but was about 10x slower > than just leaving the kernel/user copy in there). > > so what am i missing here? As has been mentioned, you need to look at how the physio mechanism (physread/physwrite) does it. Basically, you temporarily map the region into the kernel and then wire it down. However, typically once you reach this point with an ioctl interface it's time to stop and wonder whether you're going about it the wrong way. Ioctls are usually *not* used for efficient I/O. -- ... every activity meets with opposition, everyone who acts has his rivals and unfortunately opponents also. But not because people want to be opponents, rather because the tasks and relationships force people to take different points of view. [Dr. Fritz Todt] To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message