mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-13 10:02:38 +00:00
- Introduce a new busdma flag BUS_DMA_ZERO to request for zero'ed
memory in bus_dmamem_alloc(). This is possible now that contigmalloc() supports the M_ZERO flag. - Remove the locking of Giant around calls to contigmalloc() since contigmalloc() now grabs Giant itself.
This commit is contained in:
parent
f5eb4a6a5e
commit
d5afecd068
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118081
sys
alpha
amd64
i386
ia64
powerpc
sparc64
sys
@ -413,24 +413,29 @@ int
|
||||
bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
bus_dmamap_t *mapp)
|
||||
{
|
||||
int mflags;
|
||||
|
||||
if (flags & BUS_DMA_NOWAIT)
|
||||
mflags = M_NOWAIT;
|
||||
else
|
||||
mflags = M_WAITOK;
|
||||
if (flags & BUS_DMA_ZERO)
|
||||
mflags |= M_ZERO;
|
||||
|
||||
/* If we succeed, no mapping/bouncing will be required */
|
||||
*mapp = &nobounce_dmamap;
|
||||
|
||||
if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem)) {
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
|
||||
} else {
|
||||
/*
|
||||
* XXX Use Contigmalloc until it is merged into this facility
|
||||
* 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,
|
||||
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF, mflags,
|
||||
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
|
||||
dmat->boundary);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
if (*vaddr == NULL)
|
||||
return (ENOMEM);
|
||||
@ -894,13 +899,11 @@ 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 == 0) {
|
||||
free(bpage, M_DEVBUF);
|
||||
break;
|
||||
|
@ -470,6 +470,7 @@ void busspace_generic_barrier(struct alpha_busspace *space,
|
||||
#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x04 /* hint: map memory in a coherent way */
|
||||
#define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_ISA 0x10 /* map memory for ISA dma */
|
||||
#define BUS_DMA_BUS2 0x20 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS3 0x40
|
||||
|
@ -390,25 +390,30 @@ int
|
||||
bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
bus_dmamap_t *mapp)
|
||||
{
|
||||
int mflags;
|
||||
|
||||
if (flags & BUS_DMA_NOWAIT)
|
||||
mflags = M_NOWAIT;
|
||||
else
|
||||
mflags = M_WAITOK;
|
||||
if (flags & BUS_DMA_ZERO)
|
||||
mflags |= M_ZERO;
|
||||
|
||||
/* If we succeed, no mapping/bouncing will be required */
|
||||
*mapp = NULL;
|
||||
|
||||
if ((dmat->maxsize <= PAGE_SIZE) &&
|
||||
dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem)) {
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
|
||||
} else {
|
||||
/*
|
||||
* XXX Use Contigmalloc until it is merged into this facility
|
||||
* 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,
|
||||
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF, mflags,
|
||||
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
|
||||
dmat->boundary);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
if (*vaddr == NULL)
|
||||
return (ENOMEM);
|
||||
@ -809,13 +814,11 @@ 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 == 0) {
|
||||
free(bpage, M_DEVBUF);
|
||||
break;
|
||||
|
@ -79,6 +79,7 @@
|
||||
#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x04 /* hint map memory in a coherent way */
|
||||
#define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS2 0x20
|
||||
#define BUS_DMA_BUS3 0x40
|
||||
|
@ -386,25 +386,30 @@ int
|
||||
bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
bus_dmamap_t *mapp)
|
||||
{
|
||||
int mflags;
|
||||
|
||||
if (flags & BUS_DMA_NOWAIT)
|
||||
mflags = M_NOWAIT;
|
||||
else
|
||||
mflags = M_WAITOK;
|
||||
if (flags & BUS_DMA_ZERO)
|
||||
mflags |= M_ZERO;
|
||||
|
||||
/* If we succeed, no mapping/bouncing will be required */
|
||||
*mapp = NULL;
|
||||
|
||||
if ((dmat->maxsize <= PAGE_SIZE) &&
|
||||
dmat->lowaddr >= ptoa((vm_paddr_t)Maxmem)) {
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
|
||||
} else {
|
||||
/*
|
||||
* XXX Use Contigmalloc until it is merged into this facility
|
||||
* 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,
|
||||
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF, mflags,
|
||||
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
|
||||
dmat->boundary);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
if (*vaddr == NULL)
|
||||
return (ENOMEM);
|
||||
@ -805,13 +810,11 @@ 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 == 0) {
|
||||
free(bpage, M_DEVBUF);
|
||||
break;
|
||||
|
@ -79,6 +79,7 @@
|
||||
#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x04 /* hint: map memory in a coherent way */
|
||||
#define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS2 0x20
|
||||
#define BUS_DMA_BUS3 0x40
|
||||
|
@ -413,24 +413,29 @@ int
|
||||
bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
bus_dmamap_t *mapp)
|
||||
{
|
||||
int mflags;
|
||||
|
||||
if (flags & BUS_DMA_NOWAIT)
|
||||
mflags = M_NOWAIT;
|
||||
else
|
||||
mflags = M_WAITOK;
|
||||
if (flags & BUS_DMA_ZERO)
|
||||
mflags |= M_ZERO;
|
||||
|
||||
/* If we succeed, no mapping/bouncing will be required */
|
||||
*mapp = &nobounce_dmamap;
|
||||
|
||||
if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem)) {
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
|
||||
} else {
|
||||
/*
|
||||
* XXX Use Contigmalloc until it is merged into this facility
|
||||
* 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,
|
||||
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF, mflags,
|
||||
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
|
||||
dmat->boundary);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
if (*vaddr == NULL)
|
||||
return (ENOMEM);
|
||||
@ -896,13 +901,11 @@ 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 == 0) {
|
||||
free(bpage, M_DEVBUF);
|
||||
break;
|
||||
|
@ -852,6 +852,7 @@ bus_space_copy_region_8(bus_space_tag_t bst, bus_space_handle_t bsh1,
|
||||
#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x04 /* hint: map memory in a coherent way */
|
||||
#define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_ISA 0x10 /* map memory for ISA dma */
|
||||
#define BUS_DMA_BUS2 0x20 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS3 0x40
|
||||
|
@ -744,6 +744,7 @@ bus_space_set_region_stream_4(bus_space_tag_t tag, bus_space_handle_t bsh,
|
||||
#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x04 /* hint: map memory DMA coherent */
|
||||
#define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS2 0x20
|
||||
#define BUS_DMA_BUS3 0x40
|
||||
|
@ -254,23 +254,28 @@ int
|
||||
bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
bus_dmamap_t *mapp)
|
||||
{
|
||||
int mflags;
|
||||
|
||||
if (flags & BUS_DMA_NOWAIT)
|
||||
mflags = M_NOWAIT;
|
||||
else
|
||||
mflags = M_WAITOK;
|
||||
if (flags & BUS_DMA_ZERO)
|
||||
mflags |= M_ZERO;
|
||||
|
||||
*mapp = NULL;
|
||||
|
||||
if (dmat->maxsize <= PAGE_SIZE) {
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
||||
*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
|
||||
} else {
|
||||
/*
|
||||
* XXX Use Contigmalloc until it is merged into this facility
|
||||
* 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,
|
||||
*vaddr = contigmalloc(dmat->maxsize, M_DEVBUF, mflags,
|
||||
0ul, dmat->lowaddr, dmat->alignment? dmat->alignment : 1ul,
|
||||
dmat->boundary);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
|
||||
if (*vaddr == NULL)
|
||||
|
@ -900,6 +900,7 @@ memsetw(void *d, int val, size_t size)
|
||||
#define BUS_DMA_NOWAIT 0x001 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x002 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x004 /* hint: map memory in a coherent way */
|
||||
#define BUS_DMA_ZERO 0x008 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_BUS1 0x010
|
||||
#define BUS_DMA_BUS2 0x020
|
||||
#define BUS_DMA_BUS3 0x040
|
||||
|
@ -612,23 +612,27 @@ static int
|
||||
nexus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
|
||||
bus_dmamap_t *mapp)
|
||||
{
|
||||
int mflags;
|
||||
|
||||
if (flags & BUS_DMA_NOWAIT)
|
||||
mflags = M_NOWAIT;
|
||||
else
|
||||
mflags = M_WAITOK;
|
||||
if (flags & BUS_DMA_ZERO)
|
||||
mflags |= M_ZERO;
|
||||
|
||||
if ((dmat->dt_maxsize <= PAGE_SIZE)) {
|
||||
*vaddr = malloc(dmat->dt_maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK);
|
||||
*vaddr = malloc(dmat->dt_maxsize, M_DEVBUF, mflags);
|
||||
} else {
|
||||
/*
|
||||
* XXX: Use contigmalloc until it is merged into this facility
|
||||
* and handles multi-seg allocations. Nobody is doing multi-seg
|
||||
* allocations yet though.
|
||||
*/
|
||||
mtx_lock(&Giant);
|
||||
*vaddr = contigmalloc(dmat->dt_maxsize, M_DEVBUF,
|
||||
(flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK,
|
||||
*vaddr = contigmalloc(dmat->dt_maxsize, M_DEVBUF, mflags,
|
||||
0ul, dmat->dt_lowaddr,
|
||||
dmat->dt_alignment ? dmat->dt_alignment : 1UL,
|
||||
dmat->dt_boundary);
|
||||
mtx_unlock(&Giant);
|
||||
}
|
||||
if (*vaddr == NULL)
|
||||
return (ENOMEM);
|
||||
|
@ -79,6 +79,7 @@
|
||||
#define BUS_DMA_NOWAIT 0x01 /* not safe to sleep */
|
||||
#define BUS_DMA_ALLOCNOW 0x02 /* perform resource allocation now */
|
||||
#define BUS_DMA_COHERENT 0x04 /* hint: map memory in a coherent way */
|
||||
#define BUS_DMA_ZERO 0x08 /* allocate zero'ed memory */
|
||||
#define BUS_DMA_BUS1 0x10 /* placeholders for bus functions... */
|
||||
#define BUS_DMA_BUS2 0x20
|
||||
#define BUS_DMA_BUS3 0x40
|
||||
|
Loading…
Reference in New Issue
Block a user