summaryrefslogtreecommitdiff
path: root/sys/arch/loongson
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/loongson
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/loongson')
-rw-r--r--sys/arch/loongson/loongson/bus_dma.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/sys/arch/loongson/loongson/bus_dma.c b/sys/arch/loongson/loongson/bus_dma.c
index 936e67bcbcc..2f74ddd6252 100644
--- a/sys/arch/loongson/loongson/bus_dma.c
+++ b/sys/arch/loongson/loongson/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.3 2010/02/09 19:23:19 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.4 2010/03/29 19:21:58 oga Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -432,10 +432,11 @@ 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;
paddr_t pa;
bus_addr_t addr;
- int curseg;
+ int curseg, error;
if (nsegs == 1) {
pa = (*t->_device_to_pa)(segs[0].ds_addr);
@@ -453,6 +454,8 @@ _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);
@@ -460,9 +463,18 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
if (size == 0)
panic("_dmamem_map: size botch");
pa = (*t->_device_to_pa)(addr);
- pmap_enter(pmap_kernel(), va, pa,
- VM_PROT_READ | VM_PROT_WRITE,
- VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED);
+ error = pmap_enter(pmap_kernel(), va, pa,
+ 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);
+ }
if (flags & BUS_DMA_COHERENT)
pmap_page_cache(PHYS_TO_VM_PAGE(pa),
@@ -485,8 +497,6 @@ _dmamem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
return;
size = round_page(size);
- pmap_remove(pmap_kernel(), (vaddr_t)kva, (vaddr_t)kva + size);
- pmap_update(pmap_kernel());
uvm_km_free(kernel_map, (vaddr_t)kva, size);
}