summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authormux <mux@FreeBSD.org>2003-07-27 13:52:10 +0000
committermux <mux@FreeBSD.org>2003-07-27 13:52:10 +0000
commit4e543dc21243ab3f7b1444dd28899ce4ce4f7a67 (patch)
treea4a7889831600966a860a57cdff8cfd02bf4f17f /sys
parent0d4044b1e668c1fbed194bf8172757d4d61e9fdb (diff)
downloadFreeBSD-src-4e543dc21243ab3f7b1444dd28899ce4ce4f7a67.zip
FreeBSD-src-4e543dc21243ab3f7b1444dd28899ce4ce4f7a67.tar.gz
- 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.
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/alpha/busdma_machdep.c19
-rw-r--r--sys/alpha/include/bus.h1
-rw-r--r--sys/amd64/amd64/busdma_machdep.c19
-rw-r--r--sys/amd64/include/bus_dma.h1
-rw-r--r--sys/i386/i386/busdma_machdep.c19
-rw-r--r--sys/i386/include/bus_dma.h1
-rw-r--r--sys/ia64/ia64/busdma_machdep.c19
-rw-r--r--sys/ia64/include/bus.h1
-rw-r--r--sys/powerpc/include/bus.h1
-rw-r--r--sys/powerpc/powerpc/busdma_machdep.c17
-rw-r--r--sys/sparc64/include/bus.h1
-rw-r--r--sys/sparc64/sparc64/bus_machdep.c16
-rw-r--r--sys/sys/bus_dma.h1
13 files changed, 72 insertions, 44 deletions
diff --git a/sys/alpha/alpha/busdma_machdep.c b/sys/alpha/alpha/busdma_machdep.c
index d743e8d..279d3a6 100644
--- a/sys/alpha/alpha/busdma_machdep.c
+++ b/sys/alpha/alpha/busdma_machdep.c
@@ -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;
diff --git a/sys/alpha/include/bus.h b/sys/alpha/include/bus.h
index 582484c..53eefd8 100644
--- a/sys/alpha/include/bus.h
+++ b/sys/alpha/include/bus.h
@@ -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
diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c
index 2339641..058210b 100644
--- a/sys/amd64/amd64/busdma_machdep.c
+++ b/sys/amd64/amd64/busdma_machdep.c
@@ -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;
diff --git a/sys/amd64/include/bus_dma.h b/sys/amd64/include/bus_dma.h
index b0928f1..b9129e9 100644
--- a/sys/amd64/include/bus_dma.h
+++ b/sys/amd64/include/bus_dma.h
@@ -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
diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c
index 5ebaa00..8bf5b0b 100644
--- a/sys/i386/i386/busdma_machdep.c
+++ b/sys/i386/i386/busdma_machdep.c
@@ -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;
diff --git a/sys/i386/include/bus_dma.h b/sys/i386/include/bus_dma.h
index 3539a33..9b75eae 100644
--- a/sys/i386/include/bus_dma.h
+++ b/sys/i386/include/bus_dma.h
@@ -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
diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c
index 231ac3b..29ade1f 100644
--- a/sys/ia64/ia64/busdma_machdep.c
+++ b/sys/ia64/ia64/busdma_machdep.c
@@ -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;
diff --git a/sys/ia64/include/bus.h b/sys/ia64/include/bus.h
index 7a5c0f4..0db84a4 100644
--- a/sys/ia64/include/bus.h
+++ b/sys/ia64/include/bus.h
@@ -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
diff --git a/sys/powerpc/include/bus.h b/sys/powerpc/include/bus.h
index 3ee2de5..bb5f357 100644
--- a/sys/powerpc/include/bus.h
+++ b/sys/powerpc/include/bus.h
@@ -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
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c
index f3ef3e3..829d29ab 100644
--- a/sys/powerpc/powerpc/busdma_machdep.c
+++ b/sys/powerpc/powerpc/busdma_machdep.c
@@ -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)
diff --git a/sys/sparc64/include/bus.h b/sys/sparc64/include/bus.h
index f97c13b..90d33ab 100644
--- a/sys/sparc64/include/bus.h
+++ b/sys/sparc64/include/bus.h
@@ -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
diff --git a/sys/sparc64/sparc64/bus_machdep.c b/sys/sparc64/sparc64/bus_machdep.c
index 5843b73..e0655e2 100644
--- a/sys/sparc64/sparc64/bus_machdep.c
+++ b/sys/sparc64/sparc64/bus_machdep.c
@@ -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);
diff --git a/sys/sys/bus_dma.h b/sys/sys/bus_dma.h
index 3539a33..9b75eae 100644
--- a/sys/sys/bus_dma.h
+++ b/sys/sys/bus_dma.h
@@ -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
OpenPOWER on IntegriCloud