- When creating dma map, allocate at least one bounce page even if the
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 14 Jul 2007 07:29:30 +0000 (07:29 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 14 Jul 2007 07:29:30 +0000 (07:29 +0000)
  max size of the dma tag is less than one page.
- alloc_bounce_pages() returns number of bounce pages that have been
  allocated, not error value.
- Increase MAX_BPAGES to 1024 to cooperate with modern devices.

Tested-by: Jörg Anslik <joerg@anslik.de>
Approved-by: dillon@
sys/platform/pc32/i386/busdma_machdep.c

index 5bc5e1b..6f98284 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/i386/busdma_machdep.c,v 1.16.2.2 2003/01/23 00:55:27 scottl Exp $
- * $DragonFly: src/sys/platform/pc32/i386/busdma_machdep.c,v 1.20 2007/06/03 13:02:24 corecode Exp $
+ * $DragonFly: src/sys/platform/pc32/i386/busdma_machdep.c,v 1.21 2007/07/14 07:29:30 sephe Exp $
  */
 
 #include <sys/param.h>
@@ -45,7 +45,7 @@
 
 #include <machine/md_var.h>
 
-#define MAX_BPAGES 128
+#define MAX_BPAGES 1024
 
 struct bus_dma_tag {
        bus_dma_tag_t     parent;
@@ -289,9 +289,12 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
                                panic("bus_dmamap_create: page reallocation "
                                      "not implemented");
                        }
-                       pages = atop(dmat->maxsize);
+
+                       pages = MAX(atop(dmat->maxsize), 1);
                        pages = MIN(maxpages - total_bpages, pages);
-                       error = alloc_bounce_pages(dmat, pages);
+                       pages = MAX(pages, 1);
+                       if (alloc_bounce_pages(dmat, pages) < pages)
+                               error = ENOMEM;
 
                        if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0) {
                                if (error == 0)