Author: jhb
Date: Tue May 26 16:01:50 2009
New Revision: 192815
URL: http://svn.freebsd.org/changeset/base/192815

Log:
  MFC:  Reduce the number of bounce zones (and thus the number of bounce
  pages) used in some cases.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/busdma_machdep.c
  stable/7/sys/arm/arm/busdma_machdep.c
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/i386/i386/busdma_machdep.c

Modified: stable/7/sys/amd64/amd64/busdma_machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/busdma_machdep.c   Tue May 26 15:49:09 2009        
(r192814)
+++ stable/7/sys/amd64/amd64/busdma_machdep.c   Tue May 26 16:01:50 2009        
(r192815)
@@ -94,7 +94,6 @@ struct bounce_zone {
        int             total_bounced;
        int             total_deferred;
        bus_size_t      alignment;
-       bus_size_t      boundary;
        bus_addr_t      lowaddr;
        char            zoneid[8];
        char            lowaddrid[20];
@@ -974,7 +973,6 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        /* Check to see if we already have a suitable zone */
        STAILQ_FOREACH(bz, &bounce_zone_list, links) {
                if ((dmat->alignment <= bz->alignment)
-                && (dmat->boundary <= bz->boundary)
                 && (dmat->lowaddr >= bz->lowaddr)) {
                        dmat->bounce_zone = bz;
                        return (0);
@@ -990,8 +988,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        bz->reserved_bpages = 0;
        bz->active_bpages = 0;
        bz->lowaddr = dmat->lowaddr;
-       bz->alignment = dmat->alignment;
-       bz->boundary = dmat->boundary;
+       bz->alignment = MAX(dmat->alignment, PAGE_SIZE);
        snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount);
        busdma_zonecount++;
        snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
@@ -1037,9 +1034,6 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
            SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
            "alignment", CTLFLAG_RD, &bz->alignment, 0, "");
-       SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
-           SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
-           "boundary", CTLFLAG_RD, &bz->boundary, 0, "");
 
        return (0);
 }
@@ -1064,7 +1058,7 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u
                                                         M_NOWAIT, 0ul,
                                                         bz->lowaddr,
                                                         PAGE_SIZE,
-                                                        bz->boundary);
+                                                        0);
                if (bpage->vaddr == 0) {
                        free(bpage, M_DEVBUF);
                        break;

Modified: stable/7/sys/arm/arm/busdma_machdep.c
==============================================================================
--- stable/7/sys/arm/arm/busdma_machdep.c       Tue May 26 15:49:09 2009        
(r192814)
+++ stable/7/sys/arm/arm/busdma_machdep.c       Tue May 26 16:01:50 2009        
(r192815)
@@ -113,7 +113,6 @@ struct bounce_zone {
        int             total_bounced;
        int             total_deferred;
        bus_size_t      alignment;
-       bus_size_t      boundary;
        bus_addr_t      lowaddr;
        char            zoneid[8];
        char            lowaddrid[20];
@@ -683,10 +682,10 @@ _bus_dmamap_count_pages(bus_dma_tag_t dm
                vendaddr = (vm_offset_t)buf + buflen;
 
                while (vaddr < vendaddr) {
-                       if (pmap != NULL)
-                               paddr = pmap_extract(pmap, vaddr);
-                       else
+                       if (__predict_true(pmap == pmap_kernel()))
                                paddr = pmap_kextract(vaddr);
+                       else
+                               paddr = pmap_extract(pmap, vaddr);
                        if (((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) &&
                            run_filter(dmat, paddr) != 0)
                                map->pagesneeded++;
@@ -1259,7 +1258,6 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        /* Check to see if we already have a suitable zone */
        STAILQ_FOREACH(bz, &bounce_zone_list, links) {
                if ((dmat->alignment <= bz->alignment)
-                && (dmat->boundary <= bz->boundary)
                 && (dmat->lowaddr >= bz->lowaddr)) {
                        dmat->bounce_zone = bz;
                        return (0);
@@ -1275,8 +1273,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        bz->reserved_bpages = 0;
        bz->active_bpages = 0;
        bz->lowaddr = dmat->lowaddr;
-       bz->alignment = dmat->alignment;
-       bz->boundary = dmat->boundary;
+       bz->alignment = MAX(dmat->alignment, PAGE_SIZE);
        snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount);
        busdma_zonecount++;
        snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
@@ -1322,9 +1319,6 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
            SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
            "alignment", CTLFLAG_RD, &bz->alignment, 0, "");
-       SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
-           SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
-           "boundary", CTLFLAG_RD, &bz->boundary, 0, "");
 
        return (0);
 }
@@ -1349,7 +1343,7 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u
                                                         M_NOWAIT, 0ul,
                                                         bz->lowaddr,
                                                         PAGE_SIZE,
-                                                        bz->boundary);
+                                                        0);
                if (bpage->vaddr == 0) {
                        free(bpage, M_DEVBUF);
                        break;

Modified: stable/7/sys/i386/i386/busdma_machdep.c
==============================================================================
--- stable/7/sys/i386/i386/busdma_machdep.c     Tue May 26 15:49:09 2009        
(r192814)
+++ stable/7/sys/i386/i386/busdma_machdep.c     Tue May 26 16:01:50 2009        
(r192815)
@@ -99,7 +99,6 @@ struct bounce_zone {
        int             total_bounced;
        int             total_deferred;
        bus_size_t      alignment;
-       bus_size_t      boundary;
        bus_addr_t      lowaddr;
        char            zoneid[8];
        char            lowaddrid[20];
@@ -987,7 +986,6 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        /* Check to see if we already have a suitable zone */
        STAILQ_FOREACH(bz, &bounce_zone_list, links) {
                if ((dmat->alignment <= bz->alignment)
-                && (dmat->boundary <= bz->boundary)
                 && (dmat->lowaddr >= bz->lowaddr)) {
                        dmat->bounce_zone = bz;
                        return (0);
@@ -1003,8 +1001,7 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        bz->reserved_bpages = 0;
        bz->active_bpages = 0;
        bz->lowaddr = dmat->lowaddr;
-       bz->alignment = dmat->alignment;
-       bz->boundary = dmat->boundary;
+       bz->alignment = MAX(dmat->alignment, PAGE_SIZE);
        snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount);
        busdma_zonecount++;
        snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
@@ -1050,9 +1047,6 @@ alloc_bounce_zone(bus_dma_tag_t dmat)
        SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
            SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
            "alignment", CTLFLAG_RD, &bz->alignment, 0, "");
-       SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
-           SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
-           "boundary", CTLFLAG_RD, &bz->boundary, 0, "");
 
        return (0);
 }
@@ -1077,7 +1071,7 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u
                                                         M_NOWAIT, 0ul,
                                                         bz->lowaddr,
                                                         PAGE_SIZE,
-                                                        bz->boundary);
+                                                        0);
                if (bpage->vaddr == 0) {
                        free(bpage, M_DEVBUF);
                        break;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to