summaryrefslogtreecommitdiff
path: root/sys/arch/alpha/dev/bus_dma.c
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2010-03-29 19:21:59 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2010-03-29 19:21:59 +0000
commita12c9c3255460f1fdd60260d3158d236732f1072 (patch)
tree4f1eeeb429755e21e4652dcc786c1a9ffcf7ee54 /sys/arch/alpha/dev/bus_dma.c
parent15d917b49909d373f99de0945cdd7afa929e4550 (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/alpha/dev/bus_dma.c')
-rw-r--r--sys/arch/alpha/dev/bus_dma.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/arch/alpha/dev/bus_dma.c b/sys/arch/alpha/dev/bus_dma.c
index 38413848c64..ddd8099ec21 100644
--- a/sys/arch/alpha/dev/bus_dma.c
+++ b/sys/arch/alpha/dev/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.26 2009/04/20 00:42:05 oga Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.27 2010/03/29 19:21:58 oga Exp $ */
/* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */
/*-
@@ -579,9 +579,10 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags)
caddr_t *kvap;
int flags;
{
- vaddr_t va;
+ vaddr_t va, sva;
+ size_t ssize;
bus_addr_t addr;
- int curseg;
+ int curseg, error;
/*
* If we're only mapping 1 segment, use K0SEG, to avoid
@@ -601,15 +602,26 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags)
*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());