summaryrefslogtreecommitdiff
path: root/sys/arch/sgi
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-07-11 09:36:27 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-07-11 09:36:27 +0000
commit9d682a4ae1ab248336807e15680bca44ff161e05 (patch)
tree507e0dcaf315952bacfdbc92a1523335193d9d1b /sys/arch/sgi
parent953625aa76abbcc1a81a8d96092a2ec90005f775 (diff)
Convert bus_dmamem_map(9) to km_alloc(9) in order to make it fail and
not sleep if the allocator cannot obtain a lock when BUS_DMA_NOWAIT is specified. idea and inputs from kettenis@, ok miod@
Diffstat (limited to 'sys/arch/sgi')
-rw-r--r--sys/arch/sgi/sgi/bus_dma.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/arch/sgi/sgi/bus_dma.c b/sys/arch/sgi/sgi/bus_dma.c
index f932d5dd156..915d529ddf7 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.34 2014/05/19 21:18:42 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.35 2014/07/11 09:36:26 mpi Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -443,6 +443,7 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
paddr_t pa;
bus_addr_t addr;
int curseg, error, pmap_flags;
+ const struct kmem_dyn_mode *kd;
#if defined(TGT_INDIGO2)
/*
@@ -471,7 +472,8 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
}
size = round_page(size);
- va = uvm_km_valloc(kernel_map, size);
+ kd = flags & BUS_DMA_NOWAIT ? &kd_trylock : &kd_waitok;
+ va = (vaddr_t)km_alloc(size, &kv_any, &kp_none, kd);
if (va == 0)
return (ENOMEM);
@@ -496,7 +498,7 @@ _dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, size_t size,
VM_PROT_WRITE | pmap_flags);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
@@ -528,8 +530,7 @@ _dmamem_unmap(bus_dma_tag_t t, caddr_t kva, size_t size)
if (IS_XKPHYS((vaddr_t)kva))
return;
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*