diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 2007-06-08 04:46:50 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2007-06-08 04:46:50 +0000 |
commit | ba49b9f7731e185045eb2222c4c3864d539136bf (patch) | |
tree | 5744396749da0a46995acd7d8846b7eb06ce7a9a | |
parent | 293b847542ebfac574cd9a9d888df9769d45e77f (diff) | |
download | src-ba49b9f7731e185045eb2222c4c3864d539136bf.tar.gz src-ba49b9f7731e185045eb2222c4c3864d539136bf.zip |
Sync with other platforms: add kluge to use contigmalloc when the
alignment is larger than the size and print a diagnostic when we
didn't satisfy the alignment.
Notes
Notes:
svn path=/head/; revision=170421
-rw-r--r-- | sys/powerpc/powerpc/busdma_machdep.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 2fe0a6d6d9d3..802b2105b546 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -263,9 +263,18 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, mflags |= M_ZERO; *mapp = NULL; - - if (dmat->maxsize <= PAGE_SIZE) { - *vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags); + + /* + * XXX: + * (dmat->alignment < dmat->maxsize) is just a quick hack; the exact + * alignment guarantees of malloc need to be nailed down, and the + * code below should be rewritten to take that into account. + * + * In the meantime, we'll return an error if malloc gets it wrong. + */ + if (dmat->maxsize <= PAGE_SIZE && + dmat->alignment < dmat->maxsize) { + *vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags); } else { /* * XXX Use Contigmalloc until it is merged into this facility @@ -280,6 +289,9 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags, if (*vaddr == NULL) return (ENOMEM); + if ((uintptr_t)*vaddr % dmat->alignment) + printf("XXX: %s: alignment not respected!\n", __func__); + return (0); } @@ -292,11 +304,11 @@ bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map) { if (map != NULL) panic("bus_dmamem_free: Invalid map freed\n"); - if (dmat->maxsize <= PAGE_SIZE) + if (dmat->maxsize <= PAGE_SIZE && + dmat->alignment < dmat->maxsize) free(vaddr, M_DEVBUF); - else { + else contigfree(vaddr, dmat->maxsize, M_DEVBUF); - } } /* |