diff options
-rw-r--r-- | sys/arch/alpha/dev/bus_dma.c | 24 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/bus_dma.c | 22 | ||||
-rw-r--r-- | sys/arch/arm/arm/bus_dma.c | 24 | ||||
-rw-r--r-- | sys/arch/loongson/loongson/bus_dma.c | 26 | ||||
-rw-r--r-- | sys/arch/macppc/macppc/dma.c | 24 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/bus_dma.c | 24 | ||||
-rw-r--r-- | sys/arch/mvme88k/mvme88k/bus_dma.c | 24 | ||||
-rw-r--r-- | sys/arch/mvmeppc/mvmeppc/bus_dma.c | 24 | ||||
-rw-r--r-- | sys/arch/sgi/sgi/bus_dma.c | 26 | ||||
-rw-r--r-- | sys/arch/socppc/socppc/dma.c | 24 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/machdep.c | 23 | ||||
-rw-r--r-- | sys/arch/vax/vax/bus_dma.c | 24 |
12 files changed, 215 insertions, 74 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()); diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index 7d76ad0747a..ac95ec64801 100644 --- a/sys/arch/amd64/amd64/bus_dma.c +++ b/sys/arch/amd64/amd64/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.29 2009/08/11 17:15:54 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.30 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -471,9 +471,10 @@ int _bus_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, pmapflags = 0; + int curseg, pmapflags = 0, error; if (flags & BUS_DMA_NOCACHE) pmapflags |= PMAP_NOCACHE; @@ -485,15 +486,26 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, *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 | pmapflags, + error = pmap_enter(pmap_kernel(), va, addr | pmapflags, VM_PROT_READ | VM_PROT_WRITE, VM_PROT_READ | - VM_PROT_WRITE | PMAP_WIRED); + 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()); diff --git a/sys/arch/arm/arm/bus_dma.c b/sys/arch/arm/arm/bus_dma.c index 5cde68127a3..d0b2c8ed199 100644 --- a/sys/arch/arm/arm/bus_dma.c +++ b/sys/arch/arm/arm/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.15 2009/04/20 00:42:05 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.16 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.38 2003/10/30 08:44:13 scw Exp $ */ /*- @@ -685,9 +685,10 @@ int _bus_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; pt_entry_t *ptep/*, pte*/; #ifdef DEBUG_DMA @@ -703,6 +704,8 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, *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); @@ -712,9 +715,18 @@ _bus_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, #endif /* DEBUG_DMA */ 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); + } /* * If the memory must remain coherent with the * cache then we must make the memory uncacheable 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); } diff --git a/sys/arch/macppc/macppc/dma.c b/sys/arch/macppc/macppc/dma.c index d25eb473af5..2b616bfcd5e 100644 --- a/sys/arch/macppc/macppc/dma.c +++ b/sys/arch/macppc/macppc/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.31 2009/04/20 00:42:06 oga Exp $ */ +/* $OpenBSD: dma.c,v 1.32 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()); diff --git a/sys/arch/mvme68k/mvme68k/bus_dma.c b/sys/arch/mvme68k/mvme68k/bus_dma.c index b667cf27972..7918fe16ede 100644 --- a/sys/arch/mvme68k/mvme68k/bus_dma.c +++ b/sys/arch/mvme68k/mvme68k/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.5 2009/06/07 16:02:39 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.6 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -516,9 +516,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; size = round_page(size); @@ -529,15 +530,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()); diff --git a/sys/arch/mvme88k/mvme88k/bus_dma.c b/sys/arch/mvme88k/mvme88k/bus_dma.c index 878f7985216..8f684518eb4 100644 --- a/sys/arch/mvme88k/mvme88k/bus_dma.c +++ b/sys/arch/mvme88k/mvme88k/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.13 2009/06/07 16:02:41 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.14 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -519,9 +519,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; size = round_page(size); @@ -532,15 +533,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()); diff --git a/sys/arch/mvmeppc/mvmeppc/bus_dma.c b/sys/arch/mvmeppc/mvmeppc/bus_dma.c index ccf2acab2cc..3698b8731c7 100644 --- a/sys/arch/mvmeppc/mvmeppc/bus_dma.c +++ b/sys/arch/mvmeppc/mvmeppc/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.25 2009/06/07 16:02:41 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.26 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -486,9 +486,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; size = round_page(size); @@ -499,6 +500,8 @@ _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 = PCI_MEM_TO_PHYS(segs[curseg].ds_addr); addr < (PCI_MEM_TO_PHYS(segs[curseg].ds_addr) @@ -506,9 +509,18 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags) addr += NBPG, va += NBPG, size -= NBPG) { 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()); diff --git a/sys/arch/sgi/sgi/bus_dma.c b/sys/arch/sgi/sgi/bus_dma.c index f5967a1c60f..ae22471d81c 100644 --- a/sys/arch/sgi/sgi/bus_dma.c +++ b/sys/arch/sgi/sgi/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.17 2010/01/09 23:34:29 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.18 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; #ifdef TGT_COHERENT if (ISSET(flags, BUS_DMA_COHERENT)) @@ -458,6 +459,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); @@ -465,9 +468,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), @@ -490,8 +502,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); } 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()); diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index 86a092a89c2..4e60b5d04de 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.122 2009/12/08 21:23:18 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.123 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -1475,9 +1475,11 @@ _bus_dmamem_map(t, t0, segs, nsegs, size, kvap, flags) int flags; { struct vm_page *m; - vaddr_t va; + vaddr_t va, sva; + size_t ssize; bus_addr_t addr, cbit; struct pglist *mlist; + int error; #ifdef DIAGNOSTIC if (nsegs != 1) @@ -1495,6 +1497,8 @@ _bus_dmamem_map(t, t0, segs, nsegs, size, kvap, flags) if (flags & BUS_DMA_NOCACHE) cbit |= PMAP_NC; + sva = va; + ssize = size; mlist = segs[0]._ds_mlist; TAILQ_FOREACH(m, mlist, pageq) { #ifdef DIAGNOSTIC @@ -1502,9 +1506,18 @@ _bus_dmamem_map(t, t0, segs, nsegs, size, kvap, flags) panic("_bus_dmamem_map: size botch"); #endif addr = VM_PAGE_TO_PHYS(m); - pmap_enter(pmap_kernel(), va, addr | cbit, - VM_PROT_READ | VM_PROT_WRITE, - VM_PROT_READ | VM_PROT_WRITE | PMAP_WIRED); + error = pmap_enter(pmap_kernel(), va, addr | cbit, + 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); + } va += PAGE_SIZE; size -= PAGE_SIZE; } diff --git a/sys/arch/vax/vax/bus_dma.c b/sys/arch/vax/vax/bus_dma.c index 87701767d9d..ff904c3e2a8 100644 --- a/sys/arch/vax/vax/bus_dma.c +++ b/sys/arch/vax/vax/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.23 2009/04/20 00:42:06 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.24 2010/03/29 19:21:58 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.5 1999/11/13 00:32:20 thorpej Exp $ */ /*- @@ -423,9 +423,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; /* * Special case (but common): @@ -454,6 +455,8 @@ _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); @@ -462,9 +465,18 @@ _bus_dmamem_map(t, segs, nsegs, size, kvap, flags) panic("_bus_dmamem_map: size botch"); if (vax_boardtype == VAX_BTYP_43) addr |= KA43_DIAGMEM; - 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()); |