-/* $OpenBSD: bus_dma.c,v 1.31 2011/06/23 20:44:38 ariane Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.32 2014/07/11 09:36:25 mpi Exp $ */
/* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg, error;
+ const struct kmem_dyn_mode *kd;
/*
* If we're only mapping 1 segment, use K0SEG, to avoid
}
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
}
kva <= (caddr_t)ALPHA_K0SEG_END)
return;
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.43 2014/05/04 20:09:15 sf Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.44 2014/07/11 09:36:25 mpi Exp $ */
/* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg, pmapflags = 0, error;
+ const struct kmem_dyn_mode *kd;
if (nsegs == 1 && (flags & BUS_DMA_NOCACHE) == 0) {
*kvap = (caddr_t)PMAP_DIRECT_MAP(segs[0].ds_addr);
pmapflags |= PMAP_NOCACHE;
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
}
if (kva >= (caddr_t)PMAP_DIRECT_BASE && kva <= (caddr_t)PMAP_DIRECT_END)
return;
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.24 2013/05/10 20:25:28 patrick Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.25 2014/07/11 09:36:25 mpi Exp $ */
/* $NetBSD: bus_dma.c,v 1.38 2003/10/30 08:44:13 scw Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg;
+ const struct kmem_dyn_mode *kd;
#ifdef DEBUG_DMA
pt_entry_t *ptep;
#endif
#endif /* DEBUG_DMA */
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);
panic("_bus_dmamem_unmap");
#endif /* DIAGNOSTIC */
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.5 2011/10/09 17:08:21 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.6 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg, error;
+ const struct kmem_dyn_mode *kd;
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);
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) {
- pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
- return (error);
+ if (error) {
+ pmap_update(pmap_kernel());
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
+ return (error);
}
if (flags & BUS_DMA_COHERENT)
pmap_page_uncache(addr);
panic("bus_dmamem_unmap");
#endif
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.29 2014/03/29 18:09:29 guenther Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.30 2014/07/11 09:36:26 mpi Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
size_t ssize;
bus_addr_t addr;
int curseg, pmapflags = 0, ret;
+ struct kmem_pa_mode *kd;
if (flags & BUS_DMA_NOCACHE)
pmapflags |= PMAP_NOCACHE;
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (ret) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (ret);
}
panic("_bus_dmamem_unmap");
#endif
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.9 2010/04/21 03:03:26 deraadt Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.10 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: bus_dma.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*
vaddr_t va;
bus_addr_t addr;
int curseg;
+ const struct kmem_dyn_mode *kd;
DPRINTF(("bus_dmamem_map: t = %p, segs = %p, nsegs = %d, size = %d, kvap = %p, flags = %x\n", t, segs, nsegs, size, kvap, flags));
/* Always round the 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);
size = round_page(size);
pmap_kremove((vaddr_t)kva, size);
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, size, &kv_any, &kp_none);
}
paddr_t
-/* $OpenBSD: bus_dma.c,v 1.13 2014/03/21 21:49:45 miod Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.14 2014/07/11 09:36:26 mpi Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
paddr_t pa;
bus_addr_t addr;
int curseg, error, pmap_flags;
+ const struct kmem_dyn_mode *kd;
if (nsegs == 1) {
pa = (*t->_device_to_pa)(segs[0].ds_addr);
}
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);
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);
}
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);
}
/*
-/* $OpenBSD: dma.c,v 1.38 2014/03/31 18:58:41 mpi Exp $ */
+/* $OpenBSD: dma.c,v 1.39 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg, pmapflags = 0, error;
+ const struct kmem_dyn_mode *kd;
if (flags & BUS_DMA_NOCACHE)
pmapflags |= PMAP_NOCACHE;
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
}
panic("_bus_dmamem_unmap");
#endif
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.10 2014/05/10 22:25:16 jasper Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.11 2014/07/11 09:36:26 mpi Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
paddr_t pa;
bus_addr_t addr;
int curseg, error, pmap_flags;
+ const struct kmem_dyn_mode *kd;
if (nsegs == 1) {
pa = (*t->_device_to_pa)(segs[0].ds_addr);
}
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);
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);
}
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);
}
/*
-/* $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)
paddr_t pa;
bus_addr_t addr;
int curseg, error, pmap_flags;
+ const struct kmem_dyn_mode *kd;
#if defined(TGT_INDIGO2)
/*
}
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);
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);
}
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);
}
/*
-/* $OpenBSD: dma.c,v 1.10 2014/03/31 18:58:41 mpi Exp $ */
+/* $OpenBSD: dma.c,v 1.11 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg, error;
+ const struct kmem_dyn_mode *kd;
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
}
panic("_bus_dmamem_unmap");
#endif
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: iommu.c,v 1.26 2014/04/08 13:23:51 mpi Exp $ */
+/* $OpenBSD: iommu.c,v 1.27 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: iommu.c,v 1.13 1997/07/29 09:42:04 fair Exp $ */
/*
int cbit;
u_long align;
int pagesz = PAGE_SIZE;
+ const struct kmem_dyn_mode *kd;
if (nsegs != 1)
panic("iommu_dmamem_map: nsegs = %d", nsegs);
va = _bus_dma_valloc_skewed(size, 0, align,
segs[0].ds_addr & (align - 1));
#else
- 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);
#endif
if (va == 0)
return (ENOMEM);
panic("iommu_dmamem_unmap");
#endif
- size = round_page(size);
- pmap_kremove((vaddr_t)kva, size);
- pmap_update(pmap_kernel());
- uvm_unmap(kernel_map, (vaddr_t)kva, (vaddr_t)kva + size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
-/* $OpenBSD: machdep.c,v 1.158 2014/07/10 21:46:03 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.159 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
panic("_bus_dmamem_unmap");
#endif
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, (vaddr_t)size + size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: machdep.c,v 1.161 2014/07/10 21:46:03 mpi Exp $ */
+/* $OpenBSD: machdep.c,v 1.162 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */
/*-
caddr_t *kvap;
int flags;
{
+ const struct kmem_dyn_mode *kd;
struct vm_page *m;
vaddr_t va, sva;
size_t ssize;
#endif
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
va += PAGE_SIZE;
panic("_bus_dmamem_unmap");
#endif
- size = round_page(size);
- uvm_km_free(kernel_map, (vaddr_t)kva, size);
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*
-/* $OpenBSD: bus_dma.c,v 1.27 2011/06/23 20:44:39 ariane Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.28 2014/07/11 09:36:26 mpi Exp $ */
/* $NetBSD: bus_dma.c,v 1.5 1999/11/13 00:32:20 thorpej Exp $ */
/*-
size_t ssize;
bus_addr_t addr;
int curseg, error;
+ const struct kmem_dyn_mode *kd;
/*
* Special case (but common):
return 0;
}
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);
VM_PROT_WRITE | PMAP_WIRED | PMAP_CANFAIL);
if (error) {
pmap_update(pmap_kernel());
- uvm_km_free(kernel_map, sva, ssize);
+ km_free((void *)sva, ssize, &kv_any, &kp_none);
return (error);
}
}
/* Avoid free'ing if not mapped */
if (kva >= (caddr_t)virtual_avail)
- uvm_km_free(kernel_map, (vaddr_t)kva, round_page(size));
+ km_free(kva, round_page(size), &kv_any, &kp_none);
}
/*