diff options
author | mux <mux@FreeBSD.org> | 2003-07-27 13:52:10 +0000 |
---|---|---|
committer | mux <mux@FreeBSD.org> | 2003-07-27 13:52:10 +0000 |
commit | 4e543dc21243ab3f7b1444dd28899ce4ce4f7a67 (patch) | |
tree | a4a7889831600966a860a57cdff8cfd02bf4f17f /sys/powerpc | |
parent | 0d4044b1e668c1fbed194bf8172757d4d61e9fdb (diff) | |
download | FreeBSD-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/powerpc')
-rw-r--r-- | sys/powerpc/include/bus.h | 1 | ||||
-rw-r--r-- | sys/powerpc/powerpc/busdma_machdep.c | 17 |
2 files changed, 12 insertions, 6 deletions
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) |