From a12c9c3255460f1fdd60260d3158d236732f1072 Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Mon, 29 Mar 2010 19:21:59 +0000 Subject: PMAP_CANFAIL for bus_dmamem_map on all other architectures (and some whitespace tweaks on i386 so that it matches). ok kettenis@ --- sys/arch/mvmeppc/mvmeppc/bus_dma.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'sys/arch/mvmeppc') 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()); -- cgit v1.2.3