1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

Grab Giant around calls to contigmalloc() and contigfree() so

that drivers converted to be MP safe don't have to deal with it.
This commit is contained in:
Maxime Henrion 2003-03-13 17:18:48 +00:00
parent ea458bbcdb
commit c0796d1cb4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112196
6 changed files with 44 additions and 6 deletions

View File

@ -367,10 +367,12 @@ bus_dmamem_alloc_size(bus_dma_tag_t dmat, void** vaddr, int flags,
* and handles multi-seg allocations. Nobody is doing
* multi-seg allocations yet though.
*/
mtx_lock(&Giant);
*vaddr = contigmalloc(size, M_DEVBUF,
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
dmat->boundary);
mtx_unlock(&Giant);
}
if (*vaddr == NULL)
return (ENOMEM);
@ -400,8 +402,11 @@ bus_dmamem_free_size(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map,
panic("bus_dmamem_free: Invalid map freed\n");
if ((size <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem))
free(vaddr, M_DEVBUF);
else
else {
mtx_lock(&Giant);
contigfree(vaddr, size, M_DEVBUF);
mtx_unlock(&Giant);
}
}
void
@ -842,11 +847,13 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
if (bpage == NULL)
break;
mtx_lock(&Giant);
bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
M_NOWAIT, 0ul,
dmat->lowaddr,
PAGE_SIZE,
dmat->boundary);
mtx_unlock(&Giant);
if (bpage->vaddr == NULL) {
free(bpage, M_DEVBUF);
break;

View File

@ -348,10 +348,12 @@ bus_dmamem_alloc_size(bus_dma_tag_t dmat, void** vaddr, int flags,
* and handles multi-seg allocations. Nobody is doing
* multi-seg allocations yet though.
*/
mtx_lock(&Giant);
*vaddr = contigmalloc(size, M_DEVBUF,
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
dmat->boundary);
mtx_unlock(&Giant);
}
if (*vaddr == NULL)
return (ENOMEM);
@ -381,8 +383,11 @@ bus_dmamem_free_size(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map,
panic("bus_dmamem_free: Invalid map freed\n");
if ((size <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem))
free(vaddr, M_DEVBUF);
else
else {
mtx_lock(&Giant);
contigfree(vaddr, size, M_DEVBUF);
mtx_unlock(&Giant);
}
}
void
@ -793,11 +798,13 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
if (bpage == NULL)
break;
mtx_lock(&Giant);
bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
M_NOWAIT, 0ul,
dmat->lowaddr,
PAGE_SIZE,
0);
mtx_unlock(&Giant);
if (bpage->vaddr == 0) {
free(bpage, M_DEVBUF);
break;

View File

@ -348,10 +348,12 @@ bus_dmamem_alloc_size(bus_dma_tag_t dmat, void** vaddr, int flags,
* and handles multi-seg allocations. Nobody is doing
* multi-seg allocations yet though.
*/
mtx_lock(&Giant);
*vaddr = contigmalloc(size, M_DEVBUF,
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
dmat->boundary);
mtx_unlock(&Giant);
}
if (*vaddr == NULL)
return (ENOMEM);
@ -381,8 +383,11 @@ bus_dmamem_free_size(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map,
panic("bus_dmamem_free: Invalid map freed\n");
if ((size <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem))
free(vaddr, M_DEVBUF);
else
else {
mtx_lock(&Giant);
contigfree(vaddr, size, M_DEVBUF);
mtx_unlock(&Giant);
}
}
void
@ -793,11 +798,13 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
if (bpage == NULL)
break;
mtx_lock(&Giant);
bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
M_NOWAIT, 0ul,
dmat->lowaddr,
PAGE_SIZE,
0);
mtx_unlock(&Giant);
if (bpage->vaddr == 0) {
free(bpage, M_DEVBUF);
break;

View File

@ -354,10 +354,12 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
* and handles multi-seg allocations. Nobody is doing
* multi-seg allocations yet though.
*/
mtx_lock(&Giant);
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF,
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
dmat->boundary);
mtx_unlock(&Giant);
}
if (*vaddr == NULL)
return (ENOMEM);
@ -379,8 +381,11 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
panic("bus_dmamem_free: Invalid map freed\n");
if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem))
free(vaddr, M_DEVBUF);
else
else {
mtx_lock(&Giant);
contigfree(vaddr, dmat->maxsize, M_DEVBUF);
mtx_unlock(&Giant);
}
}
#define BUS_DMAMAP_NSEGS ((64 * 1024 / PAGE_SIZE) + 1)
@ -817,11 +822,13 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
if (bpage == NULL)
break;
mtx_lock(&Giant);
bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
M_NOWAIT, 0ul,
dmat->lowaddr,
PAGE_SIZE,
0);
mtx_unlock(&Giant);
if (bpage->vaddr == NULL) {
free(bpage, M_DEVBUF);
break;

View File

@ -217,10 +217,12 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
* and handles multi-seg allocations. Nobody is doing
* multi-seg allocations yet though.
*/
mtx_lock(&Giant);
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF,
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
dmat->boundary);
mtx_unlock(&Giant);
}
if (*vaddr == NULL)
@ -240,8 +242,11 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
panic("bus_dmamem_free: Invalid map freed\n");
if (dmat->maxsize <= PAGE_SIZE)
free(vaddr, M_DEVBUF);
else
else {
mtx_lock(&Giant);
contigfree(vaddr, dmat->maxsize, M_DEVBUF);
mtx_unlock(&Giant);
}
}
/*

View File

@ -630,11 +630,13 @@ nexus_dmamem_alloc_size(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, void **vaddr,
* and handles multi-seg allocations. Nobody is doing multi-seg
* allocations yet though.
*/
mtx_lock(&Giant);
*vaddr = contigmalloc(size, M_DEVBUF,
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
0ul, ddmat->dt_lowaddr,
ddmat->dt_alignment ? ddmat->dt_alignment : 1UL,
ddmat->dt_boundary);
mtx_unlock(&Giant);
}
if (*vaddr == NULL) {
free(*mapp, M_DEVBUF);
@ -663,8 +665,11 @@ nexus_dmamem_free_size(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, void *vaddr,
sparc64_dmamem_free_map(ddmat, map);
if ((size <= PAGE_SIZE))
free(vaddr, M_DEVBUF);
else
else {
mtx_lock(&Giant);
contigfree(vaddr, size, M_DEVBUF);
mtx_unlock(&Giant);
}
}
static void