diff --git a/sys/alpha/alpha/busdma_machdep.c b/sys/alpha/alpha/busdma_machdep.c index c48016be2fb3..bd127a1f9ad2 100644 --- a/sys/alpha/alpha/busdma_machdep.c +++ b/sys/alpha/alpha/busdma_machdep.c @@ -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; diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 2ce359b0a795..270d22269914 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -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; diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 2ce359b0a795..270d22269914 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -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; diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c index e7c38bee1209..80f350b98f10 100644 --- a/sys/ia64/ia64/busdma_machdep.c +++ b/sys/ia64/ia64/busdma_machdep.c @@ -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; diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index b7ff1de17c0e..6c6dd36421da 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -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); + } } /* diff --git a/sys/sparc64/sparc64/bus_machdep.c b/sys/sparc64/sparc64/bus_machdep.c index 71e1d0b8f967..4d825f76329f 100644 --- a/sys/sparc64/sparc64/bus_machdep.c +++ b/sys/sparc64/sparc64/bus_machdep.c @@ -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