Switch from an extent mao to a vmem arena to manage SGMAP address space.
This commit is contained in:
parent
1be67ebe62
commit
1fd968ef01
@ -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 @@ alpha_sgmap_init(bus_dma_tag_t t, struct alpha_sgmap *sgmap, const char *name,
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
@ -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 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
|
||||
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 @@ __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
|
||||
}
|
||||
#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 @@ __C(SGMAP_TYPE,_unload)(bus_dma_tag_t t, bus_dmamap_t map,
|
||||
{
|
||||
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 @@ __C(SGMAP_TYPE,_unload)(bus_dma_tag_t t, bus_dmamap_t map,
|
||||
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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user