summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2007-06-08 04:46:50 +0000
committermarcel <marcel@FreeBSD.org>2007-06-08 04:46:50 +0000
commit024859acd22a3d016b8fd5450f32b37974da21b0 (patch)
tree5744396749da0a46995acd7d8846b7eb06ce7a9a /sys/powerpc
parent5f5cd9e4f2416485720aae4009f2bb7bd44d277a (diff)
downloadFreeBSD-src-024859acd22a3d016b8fd5450f32b37974da21b0.zip
FreeBSD-src-024859acd22a3d016b8fd5450f32b37974da21b0.tar.gz
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.
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/powerpc/busdma_machdep.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c
index 2fe0a6d..802b210 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);
- }
}
/*
OpenPOWER on IntegriCloud