Subject: Re: bus_dma
To: None <email@example.com>
From: Manuel Bouyer <firstname.lastname@example.org>
Date: 12/12/2004 17:00:10
On Sat, Dec 11, 2004 at 09:41:31PM -0800, Kamal R. Prasad wrote:
> I looked at the paper by Jason Thorpe sometime back
> and I BELIEVE it says it is used for kernel<-->user
> exchange of bulk data.
No, it's for data exchange between kernel and devices, using bus-master DMA
(of course the device has to support it).
> I have written an mmap() interface for a usb device.
> Userland does an mmap() to read in a block of data
> without involving a copyout(). I am using vtophys()
> [on freebsd for the moment] to map kernel virtual
> address to a physical interface which is returned in
OK, so you have 2 different things here:
1) provide a set of physical pages to the USB device, to which
it can do bus-master DMA.
2) provide a mmap() interface, so that this set of physical pages can be mapped
in userland by a process.
1) requires you to use bus_dma(9). The man page, and other drivers in sys/dev/
should give you enouth informations on how to use it.
For this, you need to know how you will alloc the set of physical pages.
My guess is that bus_dmamem_alloc() is the best way to go in this case.
2) depends on how you allocated the memory in 1). If the memory comes from
bus_dmamem_alloc(), bus_dmamem_mmap() should do what you want. You have
examples for this in audio drivers, such as pci/auich.c.
> I have been given to understand that vtophys() will
> not be available in future and I should use bus_dma in
Yes, for the good reason that vtophys() isn't portable, and not
all architectures have it.
Manuel Bouyer <email@example.com>
NetBSD: 26 ans d'experience feront toujours la difference