Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-7-0]: src/sys/arch/x86/x86 Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/9e2920e4870b
branches:  netbsd-7-0
changeset: 801068:9e2920e4870b
user:      riz <riz%NetBSD.org@localhost>
date:      Sun Nov 08 00:30:48 2015 +0000

description:
Pull up following revision(s) (requested by christos in ticket #1011):
        sys/arch/x86/x86/bus_dma.c: revision 1.72
        sys/arch/x86/x86/bus_dma.c: revision 1.73
        sys/arch/x86/x86/bus_dma.c: revision 1.74
- If we succeeded allocating a buffer that did not need bouncing before, but
  the buffer in the previous mapping did, clear the bounce bit. Fixes the
  ld_virtio.c bug with machines 8GB and dd if=/dev/zero of=crash bs=1g count=4.
- Allocate with M_ZERO instead of doing memset
- The panic string can take a format, use it.
- When checking for the bounce buffer boundary check addr + len < limit, not
  addr < limit.
make sure we have a cookie before we try to clear it.
fix operator precedence.

diffstat:

 sys/arch/x86/x86/bus_dma.c |  44 +++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 21 deletions(-)

diffs (117 lines):

diff -r 34b18b4393ef -r 9e2920e4870b sys/arch/x86/x86/bus_dma.c
--- a/sys/arch/x86/x86/bus_dma.c        Sun Nov 08 00:16:39 2015 +0000
+++ b/sys/arch/x86/x86/bus_dma.c        Sun Nov 08 00:30:48 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.71 2013/12/24 15:42:56 christos Exp $    */
+/*     $NetBSD: bus_dma.c,v 1.71.8.1 2015/11/08 00:30:48 riz Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.71 2013/12/24 15:42:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.71.8.1 2015/11/08 00:30:48 riz Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -291,11 +291,10 @@
        error = 0;
        mapsize = sizeof(struct x86_bus_dmamap) +
            (sizeof(bus_dma_segment_t) * (nsegments - 1));
-       if ((mapstore = malloc(mapsize, M_DMAMAP,
-           (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+       if ((mapstore = malloc(mapsize, M_DMAMAP, M_ZERO |
+           ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK))) == NULL)
                return (ENOMEM);
 
-       memset(mapstore, 0, mapsize);
        map = (struct x86_bus_dmamap *)mapstore;
        map->_dm_size = size;
        map->_dm_segcnt = nsegments;
@@ -331,12 +330,11 @@
        /*
         * Allocate our cookie.
         */
-       if ((cookiestore = malloc(cookiesize, M_DMAMAP,
-           (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) {
+       if ((cookiestore = malloc(cookiesize, M_DMAMAP, M_ZERO |
+           ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK))) == NULL) {
                error = ENOMEM;
                goto out;
        }
-       memset(cookiestore, 0, cookiesize);
        cookie = (struct x86_bus_dma_cookie *)cookiestore;
        cookie->id_flags = cookieflags;
        map->_dm_cookie = cookie;
@@ -399,6 +397,8 @@
        }
        error = _bus_dmamap_load_buffer(t, map, buf, buflen, vm, flags);
        if (error == 0) {
+               if (cookie != NULL)
+                       cookie->id_flags &= ~X86_DMA_IS_BOUNCING;
                map->dm_mapsize = buflen;
                return 0;
        }
@@ -797,7 +797,7 @@
         */
        if ((ops & (BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE)) != 0 &&
            (ops & (BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE)) != 0)
-               panic("_bus_dmamap_sync: mix PRE and POST");
+               panic("%s: mix PRE and POST", __func__);
 
 #ifdef DIAGNOSTIC
        if ((ops & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTREAD)) != 0) {
@@ -927,16 +927,17 @@
            }
 
        case X86_DMA_BUFTYPE_RAW:
-               panic("_bus_dmamap_sync: X86_DMA_BUFTYPE_RAW");
+               panic("%s: X86_DMA_BUFTYPE_RAW", __func__);
                break;
 
        case X86_DMA_BUFTYPE_INVALID:
-               panic("_bus_dmamap_sync: X86_DMA_BUFTYPE_INVALID");
+               panic("%s: X86_DMA_BUFTYPE_INVALID", __func__);
                break;
 
        default:
-               printf("unknown buffer type %d\n", cookie->id_buftype);
-               panic("_bus_dmamap_sync");
+               panic("%s: unknown buffer type %d", __func__,
+                   cookie->id_buftype);
+               break;
        }
 end:
        if (ops & (BUS_DMASYNC_PREWRITE|BUS_DMASYNC_POSTWRITE)) {
@@ -1244,20 +1245,21 @@
                curaddr = _BUS_VIRT_TO_BUS(pmap, vaddr);
 
                /*
-                * If we're beyond the bounce threshold, notify
-                * the caller.
-                */
-               if (map->_dm_bounce_thresh != 0 &&
-                   curaddr >= map->_dm_bounce_thresh)
-                       return (EINVAL);
-
-               /*
                 * Compute the segment size, and adjust counts.
                 */
                sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET);
                if (buflen < sgsize)
                        sgsize = buflen;
 
+               /*
+                * If we're beyond the bounce threshold, notify
+                * the caller.
+                */
+               if (map->_dm_bounce_thresh != 0 &&
+                   curaddr + sgsize >= map->_dm_bounce_thresh)
+                       return (EINVAL);
+
+
                error = _bus_dmamap_load_busaddr(t, map, curaddr, sgsize);
                if (error)
                        return error;



Home | Main Index | Thread Index | Old Index