diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-03-29 19:21:59 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2010-03-29 19:21:59 +0000 |
commit | a12c9c3255460f1fdd60260d3158d236732f1072 (patch) | |
tree | 4f1eeeb429755e21e4652dcc786c1a9ffcf7ee54 /sys/arch/socppc | |
parent | 15d917b49909d373f99de0945cdd7afa929e4550 (diff) |
PMAP_CANFAIL for bus_dmamem_map on all other architectures (and some
whitespace tweaks on i386 so that it matches).
ok kettenis@
Diffstat (limited to 'sys/arch/socppc')
-rw-r--r-- | sys/arch/socppc/socppc/dma.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/arch/socppc/socppc/dma.c b/sys/arch/socppc/socppc/dma.c index 2a48299d9f5..599bc0048db 100644 --- a/sys/arch/socppc/socppc/dma.c +++ b/sys/arch/socppc/socppc/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.5 2009/04/20 00:42:06 oga Exp $ */ +/* $OpenBSD: dma.c,v 1.6 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -460,9 +460,10 @@ int _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size, caddr_t *kvap, int flags) { - vaddr_t va; + vaddr_t va, sva; + size_t ssize; bus_addr_t addr; - int curseg; + int curseg, error; size = round_page(size); va = uvm_km_valloc(kernel_map, size); @@ -471,15 +472,26 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size, *kvap = (caddr_t)va; + sva = va; + ssize = size; for (curseg = 0; curseg < nsegs; curseg++) { for (addr = segs[curseg].ds_addr; addr < (segs[curseg].ds_addr + segs[curseg].ds_len); addr += PAGE_SIZE, va += PAGE_SIZE, size -= PAGE_SIZE) { if (size == 0) panic("_bus_dmamem_map: size botch"); - pmap_enter(pmap_kernel(), va, addr, - VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED); + error = pmap_enter(pmap_kernel(), va, addr, + VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ | + VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL); + if (error) { + /* + * Clean up after ourselves. + * XXX uvm_wait on WAITOK + */ + pmap_update(pmap_kernel()); + uvm_km_free(kernel_map, va, ssize); + return (error); + } } } pmap_update(pmap_kernel()); |