bus_dmamap_load_uio() and user data

John Baldwin jhb at freebsd.org
Fri Jan 8 13:47:21 UTC 2010


On Thursday 07 January 2010 4:17:52 pm Mark Tinguely wrote:
> 
> In the user space case of bus_dmamap_load_uio(), the calling thread is
> stored in uio->uio_td, in which the user's pmap can be determined.
> 
> The ARM processor, with the possible exception of the ARMv7 MPcore
> with snoop control unit, needs to make the caches consistent before
> DMA. I noticed that the routine, _bus_dmamap_sync(), copies data into
> the bounce buffer using current pmap.
> 
> Can/should we assume the uio sent from to bus_dmamap_load_uio() is
> always in the same address space as thread that is executing
> the _bus_dmamap_sync()? 

You should use the pmap from the thread in the uio structure.  Similar to
this from the x86 bus_dma code:

        if (uio->uio_segflg == UIO_USERSPACE) {
                KASSERT(uio->uio_td != NULL,
                        ("bus_dmamap_load_uio: USERSPACE but no proc"));
                pmap = vmspace_pmap(uio->uio_td->td_proc->p_vmspace);
        } else
                pmap = NULL;

Later when doing VA -> PA conversions the code does this:

                        if (pmap)
                                paddr = pmap_extract(pmap, vaddr);
                        else
                                paddr = pmap_kextract(vaddr);

-- 
John Baldwin


More information about the freebsd-hackers mailing list