Subject: Re: Machine-independent bus DMA interface proposal
To: Wolfgang Solfrank <firstname.lastname@example.org>
From: Jason Thorpe <email@example.com>
Date: 09/24/1996 16:14:57
On Mon, 23 Sep 1996 14:28:50 +0200
firstname.lastname@example.org (Wolfgang Solfrank) wrote:
> What about DMA to somewhere not in kernel vitual address space?
> Note that e.g. the current i386 port is quite scarce on kernel
> virtual address
> space, and I've (actually a friend of mine has) got a machine with two frame
> grabbers that both will want quite significant memory (easily several MB) to
> dma their data to. I'd like to have the interface support this too.
> Something like having bus_dmamem_alloc() return a cookie that can be used as
> argument to bus_dmamap_load(), and, if needed, can also be used to map the
> memory into kernel virtual space.
Ok, so I finally got a chance to think about this today, and it seems
to me that the solution to this is actually quite simple...
Change bus_dmamap_load() to take a proc *, like this:
int bus_dmamap_load __P((bus_dma_tag_t tag, bus_dma_handle_t dmah,
caddr_t va, size_t size, struct proc *p, int flags));
The proc argument can be interpreted this way:
If "p" is NULL, "va" is a kernel virtual address. Use whatever
method to translate the address you normally would (i.e.
kvtop(), K0SEG_TO_PHYS(), whatever...) in the machine-dependent
If "p" is not NULL, use it to get the user's pmap, and pass it
as an argument to pmap_extract() in the machine-dependent
mapping functions to get the physical pages corresponding to
In Wolfgang's framegrabber example, maybe he could have an ioctl, say
FGIOCMAPUBUF ... the user's pages would then be wired down, and
DMA mapped via bus_dmamap_load()...
Perhaps bus_dmamap_unload() should also take a proc *, unless the
state for that is kept in the dma handle...
Also, bus_dmamap_load() should probably make sure the pages are wired
down, and bus_dmamap_unload() can unwire...
The only strange interaction I could think of would be with Sun DVMA...
In those cases, I think the buffer would just have to be mapped into
kva space, but the caller doesn't have to know that... (Maybe someone
who knows more of the intracacies of Sun DVMA can clear this up?)
Does this seem like a reasonable way to get this functionality?
-- save the ancient forests - http://www.bayarea.net/~thorpej/forest/ --
Jason R. Thorpe email@example.com
NASA Ames Research Center Home: 408.866.1912
NAS: M/S 258-6 Work: 415.604.0935
Moffett Field, CA 94035 Pager: 415.428.6939