Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha/common Switch from an extent mao to a vmem ar...
details: https://anonhg.NetBSD.org/src/rev/4b5858dc701f
branches: trunk
changeset: 934723:4b5858dc701f
user: thorpej <thorpej%NetBSD.org@localhost>
date: Wed Jun 17 04:12:39 2020 +0000
description:
Switch from an extent mao to a vmem arena to manage SGMAP address space.
diffstat:
sys/arch/alpha/common/sgmap_common.c | 26 ++++++++++++++++----------
sys/arch/alpha/common/sgmap_typedep.c | 30 ++++++++++++++++--------------
sys/arch/alpha/common/sgmapvar.h | 6 +++---
3 files changed, 35 insertions(+), 27 deletions(-)
diffs (149 lines):
diff -r 3bf4e5cdd25d -r 4b5858dc701f sys/arch/alpha/common/sgmap_common.c
--- a/sys/arch/alpha/common/sgmap_common.c Wed Jun 17 03:50:04 2020 +0000
+++ b/sys/arch/alpha/common/sgmap_common.c Wed Jun 17 04:12:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_common.c,v 1.26 2012/01/27 18:52:48 para Exp $ */
+/* $NetBSD: sgmap_common.c,v 1.27 2020/06/17 04:12:39 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.26 2012/01/27 18:52:48 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgmap_common.c,v 1.27 2020/06/17 04:12:39 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,16 +103,22 @@
}
/*
- * Create the extent map used to manage the virtual address
+ * Create the arena used to manage the virtual address
* space.
+ *
+ * XXX Consider using a quantum cache up to MAXPHYS+PAGE_SIZE
+ * XXX (extra page to handle the spill page). For now, we don't,
+ * XXX because we are using constrained allocations everywhere.
*/
- sgmap->aps_ex = extent_create(name, sgvabase, sgvasize - 1,
- NULL, 0, EX_NOWAIT|EX_NOCOALESCE);
- if (sgmap->aps_ex == NULL) {
- printf("unable to create extent map for sgmap `%s'\n",
- name);
- goto die;
- }
+ sgmap->aps_arena = vmem_create(name, sgvabase, sgvasize,
+ PAGE_SIZE, /* quantum */
+ NULL, /* importfn */
+ NULL, /* releasefn */
+ NULL, /* source */
+ 0, /* qcache_max */
+ VM_SLEEP,
+ IPL_VM);
+ KASSERT(sgmap->aps_arena != NULL);
/*
* Allocate a spill page if that hasn't already been done.
diff -r 3bf4e5cdd25d -r 4b5858dc701f sys/arch/alpha/common/sgmap_typedep.c
--- a/sys/arch/alpha/common/sgmap_typedep.c Wed Jun 17 03:50:04 2020 +0000
+++ b/sys/arch/alpha/common/sgmap_typedep.c Wed Jun 17 04:12:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.37 2010/12/15 01:28:24 matt Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.38 2020/06/17 04:12:39 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.37 2010/12/15 01:28:24 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sgmap_typedep.c,v 1.38 2020/06/17 04:12:39 thorpej Exp $");
#include "opt_ddb.h"
@@ -66,7 +66,7 @@
bus_addr_t dmaoffset, sgva;
bus_size_t sgvalen, boundary, alignment;
SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
- int s, pteidx, error, spill;
+ int pteidx, error, spill;
/* Initialize the spill page PTE if it hasn't been already. */
if (__C(SGMAP_TYPE,_prefetch_spill_page_pte) == 0)
@@ -131,10 +131,17 @@
}
#endif
- s = splvm();
- error = extent_alloc(sgmap->aps_ex, sgvalen, alignment, boundary,
- (flags & BUS_DMA_NOWAIT) ? EX_NOWAIT : EX_WAITOK, &sgva);
- splx(s);
+ const vm_flag_t vmflags = VM_INSTANTFIT |
+ ((flags & BUS_DMA_NOWAIT) ? VM_SLEEP : VM_NOSLEEP);
+
+ error = vmem_xalloc(sgmap->aps_arena, sgvalen,
+ alignment, /* alignment */
+ 0, /* phase */
+ boundary, /* nocross */
+ VMEM_ADDR_MIN, /* minaddr */
+ VMEM_ADDR_MAX, /* maxaddr */
+ vmflags,
+ &sgva);
if (error)
return (error);
@@ -395,7 +402,7 @@
{
SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
bus_addr_t osgva, sgva, esgva;
- int s, error, spill, seg, pteidx;
+ int spill, seg, pteidx;
for (seg = 0; seg < map->dm_nsegs; seg++) {
/*
@@ -431,12 +438,7 @@
alpha_mb();
/* Free the virtual address space used by the mapping. */
- s = splvm();
- error = extent_free(sgmap->aps_ex, osgva, (esgva - osgva),
- EX_NOWAIT);
- splx(s);
- if (error)
- panic(__S(__C(SGMAP_TYPE,_unload)));
+ vmem_free(sgmap->aps_arena, osgva, (esgva - osgva));
}
map->_dm_flags &= ~(BUS_DMA_READ|BUS_DMA_WRITE);
diff -r 3bf4e5cdd25d -r 4b5858dc701f sys/arch/alpha/common/sgmapvar.h
--- a/sys/arch/alpha/common/sgmapvar.h Wed Jun 17 03:50:04 2020 +0000
+++ b/sys/arch/alpha/common/sgmapvar.h Wed Jun 17 04:12:39 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmapvar.h,v 1.16 2011/07/01 19:22:35 dyoung Exp $ */
+/* $NetBSD: sgmapvar.h,v 1.17 2020/06/17 04:12:39 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -33,8 +33,8 @@
#ifndef _ALPHA_COMMON_SGMAPVAR_H
#define _ALPHA_COMMON_SGMAPVAR_H
-#include <sys/extent.h>
#include <sys/bus.h>
+#include <sys/vmem.h>
/*
* Bits n:13 of the DMA address are the index of the PTE into
@@ -52,7 +52,7 @@
* the map, that region is effectively `locked'.
*/
struct alpha_sgmap {
- struct extent *aps_ex; /* extent map to manage sgva space */
+ vmem_t *aps_arena; /* arena to manage sgva space */
void *aps_pt; /* page table */
bus_addr_t aps_ptpa; /* page table physical address */
bus_addr_t aps_sgvabase; /* base of the sgva space */
Home |
Main Index |
Thread Index |
Old Index