summaryrefslogtreecommitdiffstats
path: root/sys/sparc64
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-01-24 19:21:53 +0000
committerian <ian@FreeBSD.org>2016-01-24 19:21:53 +0000
commit6e826779c72ba605eb445362d8558a6233a9a7c8 (patch)
treef942af14f01fe26be62f9e0538420a01c60aab8e /sys/sparc64
parent89f44178f6f559f38929d5240797dcbdb21a857b (diff)
downloadFreeBSD-src-6e826779c72ba605eb445362d8558a6233a9a7c8.zip
FreeBSD-src-6e826779c72ba605eb445362d8558a6233a9a7c8.tar.gz
MFC r289618, r290316:
Fix printf format to allow for bus_size_t not being u_long on all platforms. Fix an alignment check that is wrong in half the busdma implementations. This will enable the elimination of a workaround in the USB driver that artifically allocates buffers twice as big as they need to be (which actually saves memory for very small buffers on the buggy platforms). When deciding how to allocate a dma buffer, armv4, armv6, mips, and x86/iommu all correctly check for the tag alignment <= maxsize as enabling simple uma/malloc based allocation. Powerpc, sparc64, x86/bounce, and arm64/bounce were all checking for alignment < maxsize; on those platforms when alignment was equal to the max size it would fall back to page-based allocators even for very small buffers. This change makes all platforms use the <= check. It should be noted that on all platforms other than arm[v6] and mips, this check is relying on undocumented behavior in malloc(9) that if you allocate a block of a given size it will be aligned to the next larger power-of-2 boundary. There is nothing in the malloc(9) man page that makes that explicit promise (but the busdma code has been relying on this behavior all along so I guess it works). Arm and mips code uses the allocator in kern/subr_busdma_buffalloc.c, which does explicitly implement this promise about size and alignment. Other platforms probably should switch to the aligned allocator.
Diffstat (limited to 'sys/sparc64')
-rw-r--r--sys/sparc64/sparc64/bus_machdep.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/sparc64/sparc64/bus_machdep.c b/sys/sparc64/sparc64/bus_machdep.c
index 415f43d..fcac25a 100644
--- a/sys/sparc64/sparc64/bus_machdep.c
+++ b/sys/sparc64/sparc64/bus_machdep.c
@@ -521,14 +521,14 @@ nexus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
/*
* XXX:
- * (dmat->dt_alignment < dmat->dt_maxsize) is just a quick hack; the
+ * (dmat->dt_alignment <= dmat->dt_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 warn the user if malloc gets it wrong.
*/
if (dmat->dt_maxsize <= PAGE_SIZE &&
- dmat->dt_alignment < dmat->dt_maxsize)
+ dmat->dt_alignment <= dmat->dt_maxsize)
*vaddr = malloc(dmat->dt_maxsize, M_DEVBUF, mflags);
else {
/*
OpenPOWER on IntegriCloud