Module Name: src
Committed By: thorpej
Date: Thu Dec 7 03:46:10 UTC 2023
Modified Files:
src/sys/arch/arc/arc: bus_space.c machdep.c wired_map_machdep.c
src/sys/arch/arc/include: bus_defs.h bus_funcs.h
src/sys/arch/arc/isa: isabus.c
src/sys/arch/arc/pci: necpb.c
Log Message:
extent(9) -> vmem(9)
To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arc/arc/bus_space.c
cvs rdiff -u -r1.131 -r1.132 src/sys/arch/arc/arc/machdep.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arc/arc/wired_map_machdep.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arc/include/bus_defs.h \
src/sys/arch/arc/include/bus_funcs.h
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/arc/isa/isabus.c
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/arc/pci/necpb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arc/arc/bus_space.c
diff -u src/sys/arch/arc/arc/bus_space.c:1.12 src/sys/arch/arc/arc/bus_space.c:1.13
--- src/sys/arch/arc/arc/bus_space.c:1.12 Fri Jan 27 18:52:49 2012
+++ src/sys/arch/arc/arc/bus_space.c Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_space.c,v 1.12 2012/01/27 18:52:49 para Exp $ */
+/* $NetBSD: bus_space.c,v 1.13 2023/12/07 03:46:10 thorpej Exp $ */
/* NetBSD: bus_machdep.c,v 1.1 2000/01/26 18:48:00 drochner Exp */
/*-
@@ -32,12 +32,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.12 2012/01/27 18:52:49 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.13 2023/12/07 03:46:10 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
-#include <sys/extent.h>
+#include <sys/vmem_impl.h>
#include <uvm/uvm_extern.h>
@@ -316,7 +316,7 @@ arc_bus_space_init(bus_space_tag_t bst,
{
bst->bs_name = name;
- bst->bs_extent = NULL;
+ bst->bs_arena = NULL;
bst->bs_start = start;
bst->bs_size = size;
bst->bs_pbase = paddr;
@@ -338,16 +338,28 @@ arc_bus_space_init(bus_space_tag_t bst,
}
void
-arc_bus_space_init_extent(bus_space_tag_t bst, void *storage,
- size_t storagesize)
+arc_bus_space_init_arena(bus_space_tag_t bst, struct vmem *arena_store,
+ struct vmem_btag *btag_store, unsigned int btag_count)
{
+ int error __diagused;
- bst->bs_extent = extent_create(bst->bs_name,
- bst->bs_start, bst->bs_start + bst->bs_size,
- storage, storagesize, EX_NOWAIT);
- if (bst->bs_extent == NULL)
- panic("arc_bus_space_init_extent: cannot create extent map %s",
- bst->bs_name);
+ bst->bs_arena = vmem_init(arena_store,
+ bst->bs_name, /* name */
+ 0, /* addr */
+ 0, /* size */
+ 1, /* quantum */
+ NULL, /* importfn */
+ NULL, /* releasefn */
+ NULL, /* source */
+ 0, /* qcache_max */
+ VM_NOSLEEP | VM_PRIVTAGS,
+ IPL_NONE);
+ KASSERT(bst->bs_arena != NULL);
+
+ vmem_add_bts(bst->bs_arena, btag_store, btag_count);
+ error = vmem_add(bst->bs_arena, bst->bs_start, bst->bs_size,
+ VM_NOSLEEP);
+ KASSERT(error == 0);
}
void
@@ -367,22 +379,6 @@ arc_bus_space_set_aligned_stride(bus_spa
bst->bs_stride_8 = alignment_shift;
}
-static int malloc_safe = 0;
-
-void
-arc_bus_space_malloc_set_safe(void)
-{
-
- malloc_safe = EX_MALLOCOK;
-}
-
-int
-arc_bus_space_extent_malloc_flag(void)
-{
-
- return malloc_safe;
-}
-
int
arc_bus_space_compose_handle(bus_space_tag_t bst, bus_addr_t addr,
bus_size_t size, int flags, bus_space_handle_t *bshp)
@@ -457,9 +453,8 @@ arc_bus_space_map(bus_space_tag_t bst, b
if (addr < bst->bs_start || addr + size > bst->bs_start + bst->bs_size)
return EINVAL;
- if (bst->bs_extent != NULL) {
- err = extent_alloc_region(bst->bs_extent, addr, size,
- EX_NOWAIT | malloc_safe);
+ if (bst->bs_arena != NULL) {
+ err = vmem_xalloc_addr(bst->bs_arena, addr, size, VM_NOSLEEP);
if (err)
return err;
}
@@ -472,7 +467,7 @@ arc_bus_space_unmap(bus_space_tag_t bst,
bus_size_t size)
{
- if (bst->bs_extent != NULL) {
+ if (bst->bs_arena != NULL) {
paddr_t pa;
bus_addr_t addr;
int err;
@@ -483,8 +478,7 @@ arc_bus_space_unmap(bus_space_tag_t bst,
panic("arc_bus_space_unmap: %s va 0x%qx: error %d",
bst->bs_name, (unsigned long long) bsh, err);
addr = (bus_size_t)(pa - bst->bs_pbase) + bst->bs_start;
- extent_free(bst->bs_extent, addr, size,
- EX_NOWAIT | malloc_safe);
+ vmem_xfree(bst->bs_arena, addr, size);
}
bus_space_dispose_handle(bst, bsh, size);
}
@@ -520,19 +514,25 @@ arc_bus_space_alloc(bus_space_tag_t bst,
bus_size_t size, bus_size_t align, bus_size_t boundary, int flags,
bus_addr_t *addrp, bus_space_handle_t *bshp)
{
- u_long addr;
+ vmem_addr_t addr;
int err;
- if (bst->bs_extent == NULL)
- panic("arc_bus_space_alloc: extent map %s not available",
+ if (bst->bs_arena == NULL)
+ panic("arc_bus_space_alloc: vmem arena %s not available",
bst->bs_name);
if (start < bst->bs_start ||
start + size > bst->bs_start + bst->bs_size)
return EINVAL;
- err = extent_alloc_subregion(bst->bs_extent, start, end, size,
- align, boundary, EX_FAST | EX_NOWAIT | malloc_safe, &addr);
+ err = vmem_xalloc(bst->bs_arena, size,
+ align, /* align */
+ 0, /* phase */
+ boundary, /* nocross */
+ start, /* minaddr */
+ end, /* maxaddr */
+ VM_BESTFIT | VM_NOSLEEP,
+ &addr);
if (err)
return err;
Index: src/sys/arch/arc/arc/machdep.c
diff -u src/sys/arch/arc/arc/machdep.c:1.131 src/sys/arch/arc/arc/machdep.c:1.132
--- src/sys/arch/arc/arc/machdep.c:1.131 Tue Aug 29 21:34:50 2023
+++ src/sys/arch/arc/arc/machdep.c Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.131 2023/08/29 21:34:50 andvar Exp $ */
+/* $NetBSD: machdep.c,v 1.132 2023/12/07 03:46:10 thorpej Exp $ */
/* $OpenBSD: machdep.c,v 1.36 1999/05/22 21:22:19 weingart Exp $ */
/*
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.131 2023/08/29 21:34:50 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.132 2023/12/07 03:46:10 thorpej Exp $");
#include "opt_ddb.h"
#include "opt_ddbparam.h"
@@ -492,8 +492,6 @@ cpu_startup(void)
#endif
cpu_startup_common();
-
- arc_bus_space_malloc_set_safe();
}
void *
Index: src/sys/arch/arc/arc/wired_map_machdep.c
diff -u src/sys/arch/arc/arc/wired_map_machdep.c:1.7 src/sys/arch/arc/arc/wired_map_machdep.c:1.8
--- src/sys/arch/arc/arc/wired_map_machdep.c:1.7 Fri Jan 27 18:52:50 2012
+++ src/sys/arch/arc/arc/wired_map_machdep.c Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: wired_map_machdep.c,v 1.7 2012/01/27 18:52:50 para Exp $ */
+/* $NetBSD: wired_map_machdep.c,v 1.8 2023/12/07 03:46:10 thorpej Exp $ */
/*-
* Copyright (C) 2000 Shuichiro URATA. All rights reserved.
@@ -27,12 +27,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wired_map_machdep.c,v 1.7 2012/01/27 18:52:50 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wired_map_machdep.c,v 1.8 2023/12/07 03:46:10 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
-#include <sys/extent.h>
+#include <sys/vmem_impl.h>
#include <uvm/uvm_extern.h>
#include <machine/cpu.h>
@@ -46,20 +46,38 @@ static bool arc_wired_map_paddr_entry(pa
static bool arc_wired_map_vaddr_entry(vaddr_t va, paddr_t *pap,
vsize_t *sizep);
-static struct extent *arc_wired_map_ex;
-static long wired_map_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
+#define ARC_WIRED_MAP_BTCOUNT VMEM_EST_BTCOUNT(1, 8)
+
+static vmem_t *arc_wired_map_arena;
+static struct vmem arc_wired_map_arena_store;
+static struct vmem_btag arc_wired_map_btag_store[ARC_WIRED_MAP_BTCOUNT];
void
arc_init_wired_map(void)
{
+ int error __diagused;
mips3_nwired_page = 0;
- arc_wired_map_ex = extent_create("wired_map",
- VM_MIN_WIRED_MAP_ADDRESS, VM_MAX_WIRED_MAP_ADDRESS,
- (void *)wired_map_ex_storage, sizeof(wired_map_ex_storage),
- EX_NOWAIT);
- if (arc_wired_map_ex == NULL)
- panic("arc_init_wired_map: can't create extent");
+
+ arc_wired_map_arena = vmem_init(&arc_wired_map_arena_store,
+ "wired_map", /* name */
+ 0, /* addr */
+ 0, /* size */
+ 1, /* quantum */
+ NULL, /* importfn */
+ NULL, /* releasefn */
+ NULL, /* source */
+ 0, /* qcache_max */
+ VM_NOSLEEP | VM_PRIVTAGS,
+ IPL_NONE);
+ KASSERT(arc_wired_map_arena != NULL);
+
+ vmem_add_bts(arc_wired_map_arena, arc_wired_map_btag_store,
+ ARC_WIRED_MAP_BTCOUNT);
+ error = vmem_add(arc_wired_map_arena, VM_MIN_WIRED_MAP_ADDRESS,
+ VM_MAX_WIRED_MAP_ADDRESS - VM_MIN_WIRED_MAP_ADDRESS,
+ VM_NOSLEEP);
+ KASSERT(error == 0);
}
void
@@ -77,7 +95,7 @@ arc_wired_enter_page(vaddr_t va, paddr_t
return;
}
- error = extent_alloc_region(arc_wired_map_ex, va, pg_size, EX_NOWAIT);
+ error = vmem_xalloc_addr(arc_wired_map_arena, va, pg_size, VM_NOSLEEP);
if (error) {
#ifdef DIAGNOSTIC
printf("arc_wired_enter_page: cannot allocate region.\n");
@@ -169,7 +187,7 @@ arc_contiguously_wired_mapped(paddr_t pa
vaddr_t
arc_map_wired(paddr_t pa, vsize_t size)
{
- u_long va;
+ vmem_addr_t va;
vsize_t off;
int error;
@@ -190,8 +208,14 @@ arc_map_wired(paddr_t pa, vsize_t size)
return 0; /* free wired TLB is not enough */
}
- error = extent_alloc(arc_wired_map_ex, size, MIPS3_WIRED_SIZE,
- 0, EX_NOWAIT, &va);
+ error = vmem_xalloc(arc_wired_map_arena, size,
+ MIPS3_WIRED_SIZE, /* align */
+ 0, /* phase */
+ 0, /* nocross */
+ VMEM_ADDR_MIN, /* minaddr */
+ VMEM_ADDR_MAX, /* maxaddr */
+ VM_BESTFIT | VM_NOSLEEP,
+ &va);
if (error) {
#ifdef DIAGNOSTIC
printf("arc_map_wired: can't allocate region\n");
Index: src/sys/arch/arc/include/bus_defs.h
diff -u src/sys/arch/arc/include/bus_defs.h:1.2 src/sys/arch/arc/include/bus_defs.h:1.3
--- src/sys/arch/arc/include/bus_defs.h:1.2 Mon Sep 23 16:17:54 2019
+++ src/sys/arch/arc/include/bus_defs.h Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_defs.h,v 1.2 2019/09/23 16:17:54 skrll Exp $ */
+/* $NetBSD: bus_defs.h,v 1.3 2023/12/07 03:46:10 thorpej Exp $ */
/* NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp */
/* $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */
@@ -67,6 +67,8 @@
#define _ARC_BUS_DEFS_H_
#ifdef _KERNEL
+#include <sys/vmem.h>
+
/*
* Bus address and size types
*/
@@ -116,7 +118,7 @@ typedef struct arc_bus_space *bus_space_
struct arc_bus_space {
const char *bs_name;
- struct extent *bs_extent;
+ vmem_t *bs_arena;
bus_addr_t bs_start;
bus_size_t bs_size;
Index: src/sys/arch/arc/include/bus_funcs.h
diff -u src/sys/arch/arc/include/bus_funcs.h:1.2 src/sys/arch/arc/include/bus_funcs.h:1.3
--- src/sys/arch/arc/include/bus_funcs.h:1.2 Fri Apr 23 06:13:05 2021
+++ src/sys/arch/arc/include/bus_funcs.h Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_funcs.h,v 1.2 2021/04/23 06:13:05 skrll Exp $ */
+/* $NetBSD: bus_funcs.h,v 1.3 2023/12/07 03:46:10 thorpej Exp $ */
/* NetBSD: bus.h,v 1.27 2000/03/15 16:44:50 drochner Exp */
/* $OpenBSD: bus.h,v 1.15 1999/08/11 23:15:21 niklas Exp $ */
@@ -67,20 +67,20 @@
#define _ARC_BUS_FUNCS_H_
#ifdef _KERNEL
+struct vmem;
+struct vmem_btag;
+
/* machine dependent utility function for bus_space users */
-void arc_bus_space_malloc_set_safe(void);
void arc_bus_space_init(bus_space_tag_t, const char *,
paddr_t, vaddr_t, bus_addr_t, bus_size_t);
-void arc_bus_space_init_extent(bus_space_tag_t, void *, size_t);
+void arc_bus_space_init_arena(bus_space_tag_t, struct vmem *,
+ struct vmem_btag *, unsigned int);
void arc_bus_space_set_aligned_stride(bus_space_tag_t, unsigned int);
void arc_sparse_bus_space_init(bus_space_tag_t, const char *,
paddr_t, bus_addr_t, bus_size_t);
void arc_large_bus_space_init(bus_space_tag_t, const char *,
paddr_t, bus_addr_t, bus_size_t);
-/* machine dependent utility function for bus_space implementations */
-int arc_bus_space_extent_malloc_flag(void);
-
/* these are provided for subclasses which override base bus_space. */
int arc_bus_space_compose_handle(bus_space_tag_t,
Index: src/sys/arch/arc/isa/isabus.c
diff -u src/sys/arch/arc/isa/isabus.c:1.53 src/sys/arch/arc/isa/isabus.c:1.54
--- src/sys/arch/arc/isa/isabus.c:1.53 Sat Aug 7 16:18:42 2021
+++ src/sys/arch/arc/isa/isabus.c Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: isabus.c,v 1.53 2021/08/07 16:18:42 thorpej Exp $ */
+/* $NetBSD: isabus.c,v 1.54 2023/12/07 03:46:10 thorpej Exp $ */
/* $OpenBSD: isabus.c,v 1.15 1998/03/16 09:38:46 pefo Exp $ */
/* NetBSD: isa.c,v 1.33 1995/06/28 04:30:51 cgd Exp */
@@ -120,7 +120,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1.53 2021/08/07 16:18:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1.54 2023/12/07 03:46:10 thorpej Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -130,7 +130,7 @@ __KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/kmem.h>
-#include <sys/extent.h>
+#include <sys/vmem_impl.h>
#include <uvm/uvm_extern.h>
@@ -153,8 +153,13 @@ __KERNEL_RCSID(0, "$NetBSD: isabus.c,v 1
static int beeping;
static callout_t sysbeep_ch;
-static long isa_mem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(16) / sizeof(long)];
-static long isa_io_ex_storage[EXTENT_FIXED_STORAGE_SIZE(16) / sizeof(long)];
+#define ISA_MEM_BTAG_COUNT VMEM_EST_BTCOUNT(1, 16)
+#define ISA_IO_BTAG_COUNT VMEM_EST_BTCOUNT(1, 16)
+
+static struct vmem isa_mem_arena_store;
+static struct vmem isa_io_arena_store;
+static struct vmem_btag isa_mem_btag_store[ISA_MEM_BTAG_COUNT];
+static struct vmem_btag isa_io_btag_store[ISA_IO_BTAG_COUNT];
#define IRQ_SLAVE 2
@@ -198,10 +203,10 @@ isabrattach(struct isabr_softc *sc)
sc->arc_isa_cs.ic_intr_establish = isabr_intr_establish;
sc->arc_isa_cs.ic_intr_disestablish = isabr_intr_disestablish;
- arc_bus_space_init_extent(&arc_bus_mem, (void *)isa_mem_ex_storage,
- sizeof(isa_mem_ex_storage));
- arc_bus_space_init_extent(&arc_bus_io, (void *)isa_io_ex_storage,
- sizeof(isa_io_ex_storage));
+ arc_bus_space_init_arena(&arc_bus_mem, &isa_mem_arena_store,
+ isa_mem_btag_store, ISA_MEM_BTAG_COUNT);
+ arc_bus_space_init_arena(&arc_bus_io, &isa_io_arena_store,
+ isa_io_btag_store, ISA_IO_BTAG_COUNT);
iba.iba_iot = &arc_bus_io;
iba.iba_memt = &arc_bus_mem;
Index: src/sys/arch/arc/pci/necpb.c
diff -u src/sys/arch/arc/pci/necpb.c:1.48 src/sys/arch/arc/pci/necpb.c:1.49
--- src/sys/arch/arc/pci/necpb.c:1.48 Sat Aug 7 16:18:42 2021
+++ src/sys/arch/arc/pci/necpb.c Thu Dec 7 03:46:10 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: necpb.c,v 1.48 2021/08/07 16:18:42 thorpej Exp $ */
+/* $NetBSD: necpb.c,v 1.49 2023/12/07 03:46:10 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: necpb.c,v 1.48 2021/08/07 16:18:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: necpb.c,v 1.49 2023/12/07 03:46:10 thorpej Exp $");
#include "opt_pci.h"
@@ -72,7 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: necpb.c,v 1.
#include <sys/errno.h>
#include <sys/device.h>
#include <sys/kmem.h>
-#include <sys/extent.h>
+#include <sys/vmem_impl.h>
#include <uvm/uvm_extern.h>
@@ -134,8 +134,14 @@ static struct necpb_intrhand *necpb_intt
/* There can be only one. */
int necpbfound;
struct necpb_context necpb_main_context;
-static long necpb_mem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(10) / sizeof(long)];
-static long necpb_io_ex_storage[EXTENT_FIXED_STORAGE_SIZE(10) / sizeof(long)];
+
+#define NECPB_MEM_BTAG_COUNT VMEM_EST_BTCOUNT(1, 10)
+#define NECPB_IO_BTAG_COUNT VMEM_EST_BTCOUNT(1, 10)
+
+static struct vmem necpb_mem_arena_store;
+static struct vmem necpb_io_arena_store;
+static struct vmem_btag necpb_mem_btag_store[NECPB_MEM_BTAG_COUNT];
+static struct vmem_btag necpb_io_btag_store[NECPB_IO_BTAG_COUNT];
#define PCI_IO_START 0x00100000
#define PCI_IO_END 0x01ffffff
@@ -177,13 +183,13 @@ necpb_init(struct necpb_context *ncp)
arc_large_bus_space_init(&ncp->nc_memt, "necpcimem",
RD94_P_PCI_MEM, 0, RD94_S_PCI_MEM);
- arc_bus_space_init_extent(&ncp->nc_memt, (void *)necpb_mem_ex_storage,
- sizeof(necpb_mem_ex_storage));
+ arc_bus_space_init_arena(&ncp->nc_memt, &necpb_mem_arena_store,
+ necpb_mem_btag_store, NECPB_MEM_BTAG_COUNT);
arc_bus_space_init(&ncp->nc_iot, "necpciio",
RD94_P_PCI_IO, RD94_V_PCI_IO, 0, RD94_S_PCI_IO);
- arc_bus_space_init_extent(&ncp->nc_iot, (void *)necpb_io_ex_storage,
- sizeof(necpb_io_ex_storage));
+ arc_bus_space_init_arena(&ncp->nc_iot, &necpb_io_arena_store,
+ necpb_io_btag_store, NECPB_IO_BTAG_COUNT);
jazz_bus_dma_tag_init(&ncp->nc_dmat);