Maintain the DVMA map extent subregion boundaries in the bus_dma map

structure.
This commit is contained in:
pk 2000-06-24 22:47:45 +00:00
parent f71858b51b
commit 0790f00e68
3 changed files with 54 additions and 6 deletions
sys/arch/sparc

@ -1,4 +1,4 @@
/* $NetBSD: bus.h,v 1.20 2000/06/21 13:41:23 pk Exp $ */
/* $NetBSD: bus.h,v 1.21 2000/06/24 22:47:47 pk Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -1027,6 +1027,13 @@ struct sparc_bus_dmamap {
void *_dm_cookie; /* cookie for bus-specific functions */
u_long _dm_align; /* DVMA alignment; must be a
multiple of the page size */
u_long _dm_ex_start; /* constraints on DVMA map */
u_long _dm_ex_end; /* allocations; used by the VME bus
driver and by the IOMMU driver
when mapping 24-bit devices */
/*
* PUBLIC MEMBERS: these are used by machine-independent code.
*/

@ -1,4 +1,4 @@
/* $NetBSD: iommu.c,v 1.44 2000/05/30 03:26:34 cjs Exp $ */
/* $NetBSD: iommu.c,v 1.45 2000/06/24 22:47:45 pk Exp $ */
/*
* Copyright (c) 1996
@ -91,6 +91,8 @@ struct cfattach iommu_ca = {
};
/* IOMMU DMA map functions */
int iommu_dmamap_create __P((bus_dma_tag_t, bus_size_t, int, bus_size_t,
bus_size_t, int, bus_dmamap_t *));
int iommu_dmamap_load __P((bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int));
int iommu_dmamap_load_mbuf __P((bus_dma_tag_t, bus_dmamap_t,
@ -113,7 +115,7 @@ int iommu_dvma_alloc(bus_dmamap_t, vaddr_t, bus_size_t, int,
struct sparc_bus_dma_tag iommu_dma_tag = {
NULL,
_bus_dmamap_create,
iommu_dmamap_create,
_bus_dmamap_destroy,
iommu_dmamap_load,
iommu_dmamap_load_mbuf,
@ -475,6 +477,40 @@ if ((int)sc->sc_dvmacur + len > 0)
#endif
/*
* IOMMU DMA map functions
*/
int
iommu_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
bus_dma_tag_t t;
bus_size_t size;
int nsegments;
bus_size_t maxsegsz;
bus_size_t boundary;
int flags;
bus_dmamap_t *dmamp;
{
bus_dmamap_t map;
int error;
if ((error = _bus_dmamap_create(t, size, nsegments, maxsegsz,
boundary, flags, &map)) != 0)
return (error);
if ((flags & BUS_DMA_24BIT) != 0) {
/* Limit this map to the range usable by `24-bit' devices */
map->_dm_ex_start = D24_DVMA_BASE;
map->_dm_ex_end = D24_DVMA_END;
} else {
/* Enable allocations from the entire map */
map->_dm_ex_start = iommu_dvmamap->ex_start;
map->_dm_ex_end = iommu_dvmamap->ex_end;
}
*dmamp = map;
return (0);
}
/*
* Internal routine to allocate space in the IOMMU map.
*/
@ -489,7 +525,9 @@ iommu_dvma_alloc(map, va, len, flags, dvap, sgsizep)
{
bus_size_t sgsize;
u_long align, voff;
#if 0
u_long ex_start, ex_end;
#endif
int s, error;
int pagesz = PAGE_SIZE;
@ -504,10 +542,11 @@ iommu_dvma_alloc(map, va, len, flags, dvap, sgsizep)
return (EINVAL);
sgsize = (len + voff + pagesz - 1) & -pagesz;
align = dvma_cachealign ? dvma_cachealign : pagesz;
align = dvma_cachealign ? dvma_cachealign : map->_dm_align;
s = splhigh();
#if 0
/* Check `24 address bits' in the map's attributes */
if ((map->_dm_flags & BUS_DMA_24BIT) != 0) {
ex_start = D24_DVMA_BASE;
@ -516,8 +555,9 @@ iommu_dvma_alloc(map, va, len, flags, dvap, sgsizep)
ex_start = iommu_dvmamap->ex_start;
ex_end = iommu_dvmamap->ex_end;
}
#endif
error = extent_alloc_subregion1(iommu_dvmamap,
ex_start, ex_end,
map->_dm_ex_start, map->_dm_ex_end,
sgsize, align, va & (align-1),
map->_dm_boundary,
(flags & BUS_DMA_NOWAIT) == 0

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.165 2000/05/23 11:39:58 pk Exp $ */
/* $NetBSD: machdep.c,v 1.166 2000/06/24 22:47:45 pk Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -1089,6 +1089,7 @@ _bus_dmamap_create(t, size, nsegments, maxsegsz, boundary, flags, dmamp)
map->_dm_segcnt = nsegments;
map->_dm_maxsegsz = maxsegsz;
map->_dm_boundary = boundary;
map->_dm_align = PAGE_SIZE;
map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT);
map->dm_mapsize = 0; /* no valid mappings */
map->dm_nsegs = 0;