diff options
author | 2009-04-14 16:01:04 +0000 | |
---|---|---|
committer | 2009-04-14 16:01:04 +0000 | |
commit | 26340d65a40e491d06ad616323d430c6b4a943a4 (patch) | |
tree | c7918f4c0b85cb4ad243e566a6cdce3be52643bb | |
parent | Update to tzdata2009f from elsie.nci.nih.gov (diff) | |
download | wireguard-openbsd-26340d65a40e491d06ad616323d430c6b4a943a4.tar.xz wireguard-openbsd-26340d65a40e491d06ad616323d430c6b4a943a4.zip |
Convert the waitok field of uvm_pglistalloc to "flags", more will be added soon.
For the possibility of sleeping, the first two flags are UVM_PLA_WAITOK
and UVM_PLA_NOWAIT. It is an error not to show intention, so assert that
one of the two is provided. Switch over every caller in the tree to
using the appropriate flag.
ok art@, ariane@
29 files changed, 126 insertions, 81 deletions
diff --git a/sys/arch/alpha/alpha/cpu.c b/sys/arch/alpha/alpha/cpu.c index 7aafb746feb..17a472e0812 100644 --- a/sys/arch/alpha/alpha/cpu.c +++ b/sys/arch/alpha/alpha/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.22 2008/06/26 05:42:08 ray Exp $ */ +/* $OpenBSD: cpu.c,v 1.23 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: cpu.c,v 1.44 2000/05/23 05:12:53 thorpej Exp $ */ /*- @@ -335,7 +335,7 @@ recognized: */ TAILQ_INIT(&mlist); error = uvm_pglistalloc(USPACE, avail_start, avail_end, 0, 0, - &mlist, 1, 1); + &mlist, 1, UVM_PLA_WAITOK); if (error != 0) { if (ma->ma_slot == hwrpb->rpb_primary_cpu_id) { panic("cpu_attach: unable to allocate idle stack for" diff --git a/sys/arch/alpha/dev/bus_dma.c b/sys/arch/alpha/dev/bus_dma.c index a4307fb73b6..db838e5bc78 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.24 2009/03/07 15:34:32 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.25 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */ /*- @@ -483,7 +483,7 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -491,9 +491,11 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index 8b24447cc64..2732db848e4 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.21 2009/04/09 03:08:36 dlg Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.22 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -633,18 +633,19 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); - TAILQ_INIT(&mlist); - /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/arm/arm/bus_dma.c b/sys/arch/arm/arm/bus_dma.c index cb3196c96ec..a6d20e3b353 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.13 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.14 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.38 2003/10/30 08:44:13 scw Exp $ */ /*- @@ -961,7 +961,7 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; #ifdef DEBUG_DMA printf("alloc_range: t=%p size=%lx align=%lx boundary=%lx segs=%p nsegs=%x rsegs=%p flags=%x lo=%lx hi=%lx\n", @@ -971,12 +971,14 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, /* Always round the size. */ size = round_page(size); - TAILQ_INIT(&mlist); /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/arm/arm/pmap.c b/sys/arch/arm/arm/pmap.c index b47279ea4ec..cad1f22043d 100644 --- a/sys/arch/arm/arm/pmap.c +++ b/sys/arch/arm/arm/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.20 2009/03/23 13:25:11 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.21 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: pmap.c,v 1.147 2004/01/18 13:03:50 scw Exp $ */ /* @@ -4140,7 +4140,7 @@ pmap_postinit(void) TAILQ_INIT(&plist); error = uvm_pglistalloc(L1_TABLE_SIZE, physical_start, - physical_end, L1_TABLE_SIZE, 0, &plist, 1, M_WAITOK); + physical_end, L1_TABLE_SIZE, 0, &plist, 1, UVM_PLA_WAITOK); if (error) panic("Cannot allocate L1 physical pages"); diff --git a/sys/arch/aviion/dev/if_le_syscon.c b/sys/arch/aviion/dev/if_le_syscon.c index 77cc9069dd7..2bdf414a7e8 100644 --- a/sys/arch/aviion/dev/if_le_syscon.c +++ b/sys/arch/aviion/dev/if_le_syscon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le_syscon.c,v 1.6 2009/03/29 21:53:52 sthen Exp $ */ +/* $OpenBSD: if_le_syscon.c,v 1.7 2009/04/14 16:01:04 oga Exp $ */ /*- * Copyright (c) 1996 The NetBSD Foundation, Inc. @@ -149,7 +149,7 @@ le_syscon_attach(parent, self, aux) for (;;) { TAILQ_INIT(&pglist); rc = uvm_pglistalloc(ptoa(etherpages), 0, 1 << 24, - 0, 0, &pglist, 1, 0); + 0, 0, &pglist, 1, UVM_PLA_NOWAIT); if (rc == 0) break; diff --git a/sys/arch/hppa/dev/astro.c b/sys/arch/hppa/dev/astro.c index 13c18a086ee..2edf4596dcd 100644 --- a/sys/arch/hppa/dev/astro.c +++ b/sys/arch/hppa/dev/astro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $ */ +/* $OpenBSD: astro.c,v 1.9 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -271,7 +271,8 @@ astro_attach(struct device *parent, struct device *self, void *aux) size = (1 << (iova_bits - PAGE_SHIFT)) * sizeof(u_int64_t); TAILQ_INIT(&mlist); - if (uvm_pglistalloc(size, 0, -1, PAGE_SIZE, 0, &mlist, 1, 0) != 0) + if (uvm_pglistalloc(size, 0, -1, PAGE_SIZE, 0, &mlist, + 1, UVM_PLA_NOWAIT) != 0) panic("astrottach: no memory"); va = uvm_km_valloc(kernel_map, size); diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c index 2507dc203de..72cb94111dc 100644 --- a/sys/arch/hppa/hppa/mainbus.c +++ b/sys/arch/hppa/hppa/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.72 2009/03/08 19:26:39 martin Exp $ */ +/* $OpenBSD: mainbus.c,v 1.73 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 1998-2004 Michael Shalayeff @@ -937,12 +937,15 @@ mbus_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment, { struct pglist pglist; struct vm_page *pg; + int plaflag; size = round_page(size); + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&pglist); if (uvm_pglistalloc(size, 0, -1, alignment, boundary, - &pglist, 1, flags & BUS_DMA_NOWAIT)) + &pglist, 1, plaflag)) return (ENOMEM); pg = TAILQ_FIRST(&pglist); diff --git a/sys/arch/hppa64/dev/astro.c b/sys/arch/hppa64/dev/astro.c index dd804e91380..0af29e0751b 100644 --- a/sys/arch/hppa64/dev/astro.c +++ b/sys/arch/hppa64/dev/astro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: astro.c,v 1.1 2008/04/20 17:17:32 kettenis Exp $ */ +/* $OpenBSD: astro.c,v 1.2 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -272,7 +272,8 @@ astro_attach(struct device *parent, struct device *self, void *aux) size = (1 << (iova_bits - PAGE_SHIFT)) * sizeof(u_int64_t); TAILQ_INIT(&mlist); - if (uvm_pglistalloc(size, 0, -1, PAGE_SIZE, 0, &mlist, 1, 0) != 0) + if (uvm_pglistalloc(size, 0, -1, PAGE_SIZE, 0, &mlist, + 1, UVM_PLA_NOWAIT) != 0) panic("astrottach: no memory"); va = uvm_km_valloc(kernel_map, size); diff --git a/sys/arch/hppa64/hppa64/mainbus.c b/sys/arch/hppa64/hppa64/mainbus.c index 8feca3234df..183c5aaab75 100644 --- a/sys/arch/hppa64/hppa64/mainbus.c +++ b/sys/arch/hppa64/hppa64/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.8 2009/03/08 19:26:39 martin Exp $ */ +/* $OpenBSD: mainbus.c,v 1.9 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -492,12 +492,15 @@ mbus_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment, { struct pglist pglist; struct vm_page *pg; + int plaflag; size = round_page(size); + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&pglist); if (uvm_pglistalloc(size, (paddr_t)0, (paddr_t)-1, alignment, boundary, - &pglist, 1, flags & BUS_DMA_NOWAIT)) + &pglist, 1, plaflag)) return (ENOMEM); pg = TAILQ_FIRST(&pglist); diff --git a/sys/arch/hppa64/hppa64/pmap.c b/sys/arch/hppa64/hppa64/pmap.c index e04c55ff31b..49497df07a1 100644 --- a/sys/arch/hppa64/hppa64/pmap.c +++ b/sys/arch/hppa64/hppa64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.6 2008/04/27 17:48:10 martin Exp $ */ +/* $OpenBSD: pmap.c,v 1.7 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -622,7 +622,7 @@ pmap_create() TAILQ_INIT(&pmap->pm_pglist); if (uvm_pglistalloc(2 * PAGE_SIZE, 0, VM_MIN_KERNEL_ADDRESS, - PAGE_SIZE, 2 * PAGE_SIZE, &pmap->pm_pglist, 1, 1)) + PAGE_SIZE, 2 * PAGE_SIZE, &pmap->pm_pglist, 1, UVM_PLA_WAITOK)) panic("pmap_create: no pages"); pg = TAILQ_FIRST(&pmap->pm_pglist); diff --git a/sys/arch/i386/i386/bus_dma.c b/sys/arch/i386/i386/bus_dma.c index 7cbd3a8c9b5..bafc5376102 100644 --- a/sys/arch/i386/i386/bus_dma.c +++ b/sys/arch/i386/i386/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.11 2009/04/09 03:08:36 dlg Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.12 2009/04/14 16:01:04 oga Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. * All rights reserved. @@ -588,7 +588,7 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -598,11 +598,13 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, * Allocate pages from the VM system. * For non-ISA mappings first try higher memory segments. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + if (high <= ISA_DMA_BOUNCE_THRESHOLD || (error = uvm_pglistalloc(size, round_page(ISA_DMA_BOUNCE_THRESHOLD), high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0))) + &mlist, nsegs, plaflag))) error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/landisk/landisk/bus_dma.c b/sys/arch/landisk/landisk/bus_dma.c index 0aa9694cb55..f321c81eae9 100644 --- a/sys/arch/landisk/landisk/bus_dma.c +++ b/sys/arch/landisk/landisk/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.6 2009/03/15 09:35:50 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.7 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /* @@ -535,19 +535,21 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, struct pglist mlist; paddr_t curaddr, lastaddr; struct vm_page *m; - int curseg, error; + int curseg, error, plaflag; DPRINTF(("bus_dmamem_alloc: t = %p, size = %ld, alignment = %ld, boundary = %ld, segs = %p, nsegs = %d, rsegs = %p, flags = %x\n", t, size, alignment, boundary, segs, nsegs, rsegs, flags)); /* Always round the size. */ size = round_page(size); - TAILQ_INIT(&mlist); /* * Allocate the pages from the VM system. */ - error = uvm_pglistalloc(size, 0, -1, - alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + + TAILQ_INIT(&mlist); + error = uvm_pglistalloc(size, 0, -1, alignment, boundary, + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/mac68k/dev/if_mc_obio.c b/sys/arch/mac68k/dev/if_mc_obio.c index 7d0f1664a6e..5601ebd76c5 100644 --- a/sys/arch/mac68k/dev/if_mc_obio.c +++ b/sys/arch/mac68k/dev/if_mc_obio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mc_obio.c,v 1.7 2009/03/29 21:53:52 sthen Exp $ */ +/* $OpenBSD: if_mc_obio.c,v 1.8 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: if_mc_obio.c,v 1.13 2004/03/26 12:15:46 wiz Exp $ */ /*- @@ -139,7 +139,7 @@ mc_obio_attach(parent, self, aux) /* allocate memory for transmit buffer and mark it non-cacheable */ TAILQ_INIT(&txlist); if (uvm_pglistalloc(PAGE_SIZE, 0, -PAGE_SIZE, PAGE_SIZE, 0, - &txlist, 1, 0) != 0) { + &txlist, 1, UVM_PLA_NOWAIT) != 0) { printf(": could not allocate transmit buffer memory\n"); goto out1; } @@ -159,7 +159,7 @@ mc_obio_attach(parent, self, aux) */ TAILQ_INIT(&rxlist); if (uvm_pglistalloc(MC_NPAGES * PAGE_SIZE, 0, -PAGE_SIZE, PAGE_SIZE, 0, - &rxlist, 1, 0) != 0) { + &rxlist, 1, UVM_PLA_NOWAIT) != 0) { printf(": could not allocate receive buffer memory\n"); goto out3; } diff --git a/sys/arch/mac68k/dev/if_sn.c b/sys/arch/mac68k/dev/if_sn.c index c9eb7a0c297..74bf85d5c3d 100644 --- a/sys/arch/mac68k/dev/if_sn.c +++ b/sys/arch/mac68k/dev/if_sn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn.c,v 1.52 2009/03/29 21:53:52 sthen Exp $ */ +/* $OpenBSD: if_sn.c,v 1.53 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: if_sn.c,v 1.13 1997/04/25 03:40:10 briggs Exp $ */ /* @@ -114,7 +114,7 @@ snsetup(struct sn_softc *sc, u_int8_t *lladdr) */ TAILQ_INIT(&pglist); error = uvm_pglistalloc(SN_NPAGES * PAGE_SIZE, 0, -PAGE_SIZE, - PAGE_SIZE, 0, &pglist, 1, 0); + PAGE_SIZE, 0, &pglist, 1, UVM_PLA_NOWAIT); if (error != 0) { printf(": could not allocate descriptor memory\n"); return (error); diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c index 9cccd9302f6..e76832070d2 100644 --- a/sys/arch/macppc/macppc/cpu.c +++ b/sys/arch/macppc/macppc/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.60 2008/11/21 17:35:52 deraadt Exp $ */ +/* $OpenBSD: cpu.c,v 1.61 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -583,7 +583,8 @@ cpu_spinup(struct device *self, struct cpu_info *ci) size += 8192; /* SPILLSTK(1k) + DDBSTK(7k) */ TAILQ_INIT(&mlist); - error = uvm_pglistalloc(size, 0x0, 0x10000000, 0, 0, &mlist, 1, 1); + error = uvm_pglistalloc(size, 0x0, 0x10000000, 0, 0, + &mlist, 1, UVM_PLA_WAITOK); if (error) { printf(": unable to allocate idle stack\n"); return -1; diff --git a/sys/arch/macppc/macppc/dma.c b/sys/arch/macppc/macppc/dma.c index 55b6dd4050d..153fe071ecf 100644 --- a/sys/arch/macppc/macppc/dma.c +++ b/sys/arch/macppc/macppc/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.29 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: dma.c,v 1.30 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -552,7 +552,7 @@ _dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, vaddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -560,9 +560,11 @@ _dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, - alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + alignment, boundary, &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/mvme68k/mvme68k/bus_dma.c b/sys/arch/mvme68k/mvme68k/bus_dma.c index cdb73e4fc75..56e3394c37d 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.2 2009/02/18 20:48:55 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.3 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -630,7 +630,7 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -638,9 +638,11 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/mvme88k/mvme88k/bus_dma.c b/sys/arch/mvme88k/mvme88k/bus_dma.c index ab1d2ab67b4..313f8250358 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.10 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.11 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -633,7 +633,7 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -641,9 +641,11 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/mvmeppc/mvmeppc/bus_dma.c b/sys/arch/mvmeppc/mvmeppc/bus_dma.c index aa1c4020021..88f0d31215d 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.22 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.23 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -602,7 +602,7 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -610,9 +610,11 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/sgi/sgi/bus_dma.c b/sys/arch/sgi/sgi/bus_dma.c index 9842544c9eb..f80d9fe350b 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.7 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.8 2009/04/14 16:01:04 oga Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -609,7 +609,7 @@ _dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, vaddr_t curaddr, lastaddr; vm_page_t m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -617,9 +617,11 @@ _dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); - error = uvm_pglistalloc(size, low, high, - alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + error = uvm_pglistalloc(size, low, high, alignment, boundary, + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/socppc/socppc/dma.c b/sys/arch/socppc/socppc/dma.c index bb03dfd0655..2c7c1d99623 100644 --- a/sys/arch/socppc/socppc/dma.c +++ b/sys/arch/socppc/socppc/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.3 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: dma.c,v 1.4 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -552,7 +552,7 @@ _dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, vaddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; /* Always round the size. */ size = round_page(size); @@ -560,9 +560,11 @@ _dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, - alignment, boundary, &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + alignment, boundary, &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/sparc/sparc/iommu.c b/sys/arch/sparc/sparc/iommu.c index 79bfee1250e..e70d66f5ce0 100644 --- a/sys/arch/sparc/sparc/iommu.c +++ b/sys/arch/sparc/sparc/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.20 2007/05/29 09:53:59 sobrado Exp $ */ +/* $OpenBSD: iommu.c,v 1.21 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: iommu.c,v 1.13 1997/07/29 09:42:04 fair Exp $ */ /* @@ -184,7 +184,7 @@ iommu_attach(parent, self, aux) TAILQ_INIT(&mlist); #define DVMA_PTESIZE ((0 - DVMA4M_BASE) / 1024) if (uvm_pglistalloc(DVMA_PTESIZE, 0, 0xffffffff, DVMA_PTESIZE, - 0, &mlist, 1, 0) || + 0, &mlist, 1, UVM_PLA_NOWAIT) || (va = uvm_km_valloc(kernel_map, DVMA_PTESIZE)) == 0) panic("iommu_attach: can't allocate memory for pagetables"); #undef DVMA_PTESIZE diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c index 6f1fd90b236..40f4c81e304 100644 --- a/sys/arch/sparc64/dev/iommu.c +++ b/sys/arch/sparc64/dev/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.56 2009/04/05 21:57:41 oga Exp $ */ +/* $OpenBSD: iommu.c,v 1.57 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */ /* @@ -166,7 +166,7 @@ iommu_init(char *name, struct iommu_state *is, int tsbsize, u_int32_t iovabase) size = PAGE_SIZE << is->is_tsbsize; TAILQ_INIT(&mlist); if (uvm_pglistalloc((psize_t)size, (paddr_t)0, (paddr_t)-1, - (paddr_t)PAGE_SIZE, (paddr_t)0, &mlist, 1, 0) != 0) + (paddr_t)PAGE_SIZE, (paddr_t)0, &mlist, 1, UVM_PLA_NOWAIT) != 0) panic("iommu_init: no memory"); va = uvm_km_valloc(kernel_map, size); diff --git a/sys/arch/sparc64/sparc64/machdep.c b/sys/arch/sparc64/sparc64/machdep.c index dc3473b8614..c71de3b886a 100644 --- a/sys/arch/sparc64/sparc64/machdep.c +++ b/sys/arch/sparc64/sparc64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.116 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.117 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: machdep.c,v 1.108 2001/07/24 19:30:14 eeh Exp $ */ /*- @@ -1423,7 +1423,7 @@ _bus_dmamem_alloc(t, t0, size, alignment, boundary, segs, nsegs, rsegs, flags) int flags; { struct pglist *mlist; - int error; + int error, plaflag; /* Always round the size. */ size = round_page(size); @@ -1445,9 +1445,11 @@ _bus_dmamem_alloc(t, t0, size, alignment, boundary, segs, nsegs, rsegs, flags) /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(mlist); error = uvm_pglistalloc(size, (paddr_t)0, (paddr_t)-1, - alignment, boundary, mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + alignment, boundary, mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/arch/vax/vax/bus_dma.c b/sys/arch/vax/vax/bus_dma.c index 46b5e7e5793..826784b91be 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.21 2009/03/07 15:34:34 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.22 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.5 1999/11/13 00:32:20 thorpej Exp $ */ /*- @@ -682,7 +682,7 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, paddr_t curaddr, lastaddr; struct vm_page *m; struct pglist mlist; - int curseg, error; + int curseg, error, plaflag; #ifdef DEBUG_DMA printf("alloc_range: t=%p size=%lx align=%lx boundary=%lx segs=%p nsegs=%x rsegs=%p flags=%x lo=%lx hi=%lx\n", @@ -695,9 +695,11 @@ _bus_dmamem_alloc_range(t, size, alignment, boundary, segs, nsegs, rsegs, /* * Allocate pages from the VM system. */ + plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; + TAILQ_INIT(&mlist); error = uvm_pglistalloc(size, low, high, alignment, boundary, - &mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0); + &mlist, nsegs, plaflag); if (error) return (error); diff --git a/sys/dev/isa/aha.c b/sys/dev/isa/aha.c index e96d7204819..aeeef8431c1 100644 --- a/sys/dev/isa/aha.c +++ b/sys/dev/isa/aha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aha.c,v 1.62 2009/02/16 21:19:07 miod Exp $ */ +/* $OpenBSD: aha.c,v 1.63 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: aha.c,v 1.11 1996/05/12 23:51:23 mycroft Exp $ */ #undef AHADIAG @@ -1122,10 +1122,10 @@ aha_init(sc) */ size = round_page(sizeof(struct aha_mbx)); TAILQ_INIT(&pglist); - if (uvm_pglistalloc(size, 0, 0xffffff, PAGE_SIZE, 0, &pglist, 1, 0) || - uvm_map(kernel_map, &va, size, NULL, UVM_UNKNOWN_OFFSET, 0, - UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, UVM_INH_NONE, - UVM_ADV_RANDOM, 0))) + if (uvm_pglistalloc(size, 0, 0xffffff, PAGE_SIZE, 0, &pglist, 1, + UVM_PLA_NOWAIT) || uvm_map(kernel_map, &va, size, NULL, + UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_ALL, UVM_PROT_ALL, + UVM_INH_NONE, UVM_ADV_RANDOM, 0))) panic("aha_init: could not allocate mailbox"); wmbx = (struct aha_mbx *)va; diff --git a/sys/uvm/uvm_extern.h b/sys/uvm/uvm_extern.h index 2e97ced5933..95cd3fa3fe2 100644 --- a/sys/uvm/uvm_extern.h +++ b/sys/uvm/uvm_extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_extern.h,v 1.74 2009/03/05 19:52:24 kettenis Exp $ */ +/* $OpenBSD: uvm_extern.h,v 1.75 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: uvm_extern.h,v 1.57 2001/03/09 01:02:12 chs Exp $ */ /* @@ -221,6 +221,12 @@ typedef int vm_prot_t; #define UVM_PGA_ZERO 0x0002 /* returned page must be zeroed */ /* + * flags for uvm_pglistalloc() + */ +#define UVM_PLA_WAITOK 0x0001 /* may sleep */ +#define UVM_PLA_NOWAIT 0x0002 /* can't sleep (need one of the two) */ + +/* * lockflags that control the locking behavior of various functions. */ #define UVM_LK_ENTER 0x00000001 /* map locked on entry */ diff --git a/sys/uvm/uvm_pglist.c b/sys/uvm/uvm_pglist.c index 94d5d732314..b1b4286a243 100644 --- a/sys/uvm/uvm_pglist.c +++ b/sys/uvm/uvm_pglist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_pglist.c,v 1.25 2009/03/20 15:19:04 oga Exp $ */ +/* $OpenBSD: uvm_pglist.c,v 1.26 2009/04/14 16:01:04 oga Exp $ */ /* $NetBSD: uvm_pglist.c,v 1.13 2001/02/18 21:19:08 chs Exp $ */ /*- @@ -184,7 +184,7 @@ out: int uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, - paddr_t boundary, struct pglist *rlist, int nsegs, int waitok) + paddr_t boundary, struct pglist *rlist, int nsegs, int flags) { int psi; struct vm_page *pgs; @@ -201,6 +201,11 @@ uvm_pglistalloc(psize_t size, paddr_t low, paddr_t high, paddr_t alignment, KASSERT((alignment & (alignment - 1)) == 0); KASSERT((boundary & (boundary - 1)) == 0); + /* + * This argument is always ignored for now, but ensure drivers always + * show intention. + */ + KASSERT(!(flags & UVM_PLA_WAITOK) ^ !(flags & UVM_PLA_NOWAIT)); /* * Our allocations are always page granularity, so our alignment |