svn commit: r259309 - stable/10/sys/arm/arm
Ian Lepore
ian at FreeBSD.org
Fri Dec 13 16:38:22 UTC 2013
Author: ian
Date: Fri Dec 13 16:38:21 2013
New Revision: 259309
URL: http://svnweb.freebsd.org/changeset/base/259309
Log:
MFC r256637:
When calculating the number of bounce pages needed, round the maxsize
up to a multiple of PAGE_SIZE, and add one page because there can always
be one more boundary crossing than the number of pages in the transfer.
Modified:
stable/10/sys/arm/arm/busdma_machdep-v6.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/arm/arm/busdma_machdep-v6.c
==============================================================================
--- stable/10/sys/arm/arm/busdma_machdep-v6.c Fri Dec 13 16:14:08 2013 (r259308)
+++ stable/10/sys/arm/arm/busdma_machdep-v6.c Fri Dec 13 16:38:21 2013 (r259309)
@@ -425,14 +425,21 @@ bus_dma_tag_create(bus_dma_tag_t parent,
if (_bus_dma_can_bounce(newtag->lowaddr, newtag->highaddr)
|| newtag->alignment > 1)
newtag->flags |= BUS_DMA_COULD_BOUNCE;
- else
- maxsize = 2; /* Need at most 2 bounce pages for unaligned access on cache line boundaries */
+ /*
+ * Any request can auto-bounce due to cacheline alignment, in addition
+ * to any alignment or boundary specifications in the tag, so if the
+ * ALLOCNOW flag is set, there's always work to do.
+ */
if ((flags & BUS_DMA_ALLOCNOW) != 0) {
struct bounce_zone *bz;
-
- /* Must bounce */
-
+ /*
+ * Round size up to a full page, and add one more page because
+ * there can always be one more boundary crossing than the
+ * number of pages in a transfer.
+ */
+ maxsize = roundup2(maxsize, PAGE_SIZE) + PAGE_SIZE;
+
if ((error = alloc_bounce_zone(newtag)) != 0) {
free(newtag, M_DEVBUF);
return (error);
@@ -518,20 +525,22 @@ static int allocate_bz_and_pages(bus_dma
STAILQ_INIT(&(mapp->bpages));
/*
- * Attempt to add pages to our pool on a per-instance
- * basis up to a sane limit.
+ * Attempt to add pages to our pool on a per-instance basis up to a sane
+ * limit. Even if the tag isn't flagged as COULD_BOUNCE due to
+ * alignment and boundary constraints, it could still auto-bounce due to
+ * cacheline alignment, which requires at most two bounce pages.
*/
if (dmat->flags & BUS_DMA_COULD_BOUNCE)
maxpages = MAX_BPAGES;
else
- maxpages = 2 * bz->map_count; /* Only need at most 2 pages for buffers unaligned on cache line boundaries */
+ maxpages = 2 * bz->map_count;
if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0
|| (bz->map_count > 0 && bz->total_bpages < maxpages)) {
int pages;
- pages = MAX(atop(dmat->maxsize), 1);
+ pages = atop(roundup2(dmat->maxsize, PAGE_SIZE)) + 1;
pages = MIN(maxpages - bz->total_bpages, pages);
- pages = MAX(pages, 1);
+ pages = MAX(pages, 2);
if (alloc_bounce_pages(dmat, pages) < pages)
return (ENOMEM);
More information about the svn-src-stable-10
mailing list