Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/sbus Load DMA buffer before mapping it into kernel s...



details:   https://anonhg.NetBSD.org/src/rev/e4835dbeb231
branches:  trunk
changeset: 485982:e4835dbeb231
user:      pk <pk%NetBSD.org@localhost>
date:      Wed May 10 11:15:32 2000 +0000

description:
Load DMA buffer before mapping it into kernel space.

diffstat:

 sys/dev/sbus/if_le.c       |  24 ++++++++++++------------
 sys/dev/sbus/if_le_ledma.c |  24 ++++++++++++++----------
 2 files changed, 26 insertions(+), 22 deletions(-)

diffs (105 lines):

diff -r e8828b9d6ff6 -r e4835dbeb231 sys/dev/sbus/if_le.c
--- a/sys/dev/sbus/if_le.c      Wed May 10 11:13:35 2000 +0000
+++ b/sys/dev/sbus/if_le.c      Wed May 10 11:15:32 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_le.c,v 1.11 2000/05/09 22:51:34 pk Exp $    */
+/*     $NetBSD: if_le.c,v 1.12 2000/05/10 11:15:32 pk Exp $    */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -244,27 +244,27 @@
                        return;
                }
 
+               /* Load DMA buffer */
+               if ((error = bus_dmamap_load_raw(dmatag, lesc->sc_dmamap,
+                                       &seg, rseg,
+                                       MEMSIZE, BUS_DMA_NOWAIT)) != 0) {
+                       printf("%s: DMA buffer map load error %d\n",
+                               self->dv_xname, error);
+                       bus_dmamem_free(dmatag, &seg, rseg);
+                       return;
+               }
+
                /* Map DMA buffer into kernel space */
                if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
                                       (caddr_t *)&sc->sc_mem,
                                       BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
                        printf("%s: DMA buffer map error %d\n",
                                self->dv_xname, error);
+                       bus_dmamap_unload(dmatag, lesc->sc_dmamap);
                        bus_dmamem_free(lesc->sc_dmatag, &seg, rseg);
                        return;
                }
 
-               /* Load DMA buffer */
-               if ((error = bus_dmamap_load_raw(dmatag, lesc->sc_dmamap,
-                                       &seg, rseg,
-                                       MEMSIZE, BUS_DMA_NOWAIT)) != 0) {
-                       printf("%s: DMA buffer map load error %d\n",
-                               self->dv_xname, error);
-                       bus_dmamem_unmap(dmatag, (caddr_t)sc->sc_mem, MEMSIZE);
-                       bus_dmamem_free(dmatag, &seg, rseg);
-                       return;
-               }
-
                sc->sc_addr = lesc->sc_dmamap->dm_segs[0].ds_addr & 0xffffff;
                sc->sc_memsize = MEMSIZE;
                sc->sc_conf3 = LE_C3_BSWP | LE_C3_ACON | LE_C3_BCON;
diff -r e8828b9d6ff6 -r e4835dbeb231 sys/dev/sbus/if_le_ledma.c
--- a/sys/dev/sbus/if_le_ledma.c        Wed May 10 11:13:35 2000 +0000
+++ b/sys/dev/sbus/if_le_ledma.c        Wed May 10 11:15:32 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_le_ledma.c,v 1.8 2000/05/09 22:51:34 pk Exp $       */
+/*     $NetBSD: if_le_ledma.c,v 1.9 2000/05/10 11:15:32 pk Exp $       */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -374,6 +374,7 @@
        /* Allocate buffer memory */
        sc->sc_memsize = MEMSIZE;
 
+       /* Get a DMA handle */
        if ((error = bus_dmamap_create(dmatag, MEMSIZE, 1, MEMSIZE,
                                        LEDMA_BOUNDARY, BUS_DMA_NOWAIT,
                                        &lesc->sc_dmamap)) != 0) {
@@ -381,6 +382,7 @@
                return;
        }
 
+       /* Allocate DMA buffer */
        if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, NBPG, LEDMA_BOUNDARY,
                                 &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {
                printf("%s @ ledma: DMA buffer alloc error %d\n",
@@ -388,20 +390,22 @@
                return;
        }
 
+       /* Load DMA buffer */
+       if ((error = bus_dmamap_load_raw(dmatag, lesc->sc_dmamap,
+                               &seg, rseg, MEMSIZE, BUS_DMA_NOWAIT)) != 0) {
+               printf("%s: DMA buffer map load error %d\n",
+                       self->dv_xname, error);
+               bus_dmamem_free(dmatag, &seg, rseg);
+               return;
+       }
+
+       /* Map DMA buffer into kernel space */
        if ((error = bus_dmamem_map(dmatag, &seg, rseg, MEMSIZE,
                               (caddr_t *)&sc->sc_mem,
                               BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {
                printf("%s @ ledma: DMA buffer map error %d\n",
                        self->dv_xname, error);
-               bus_dmamem_free(dmatag, &seg, rseg);
-               return;
-       }
-
-       if ((error = bus_dmamap_load_raw(dmatag, lesc->sc_dmamap,
-                               &seg, rseg, MEMSIZE, BUS_DMA_NOWAIT)) != 0) {
-               printf("%s: DMA buffer map load error %d\n",
-                       self->dv_xname, error);
-               bus_dmamem_unmap(dmatag, (caddr_t)sc->sc_mem, MEMSIZE);
+               bus_dmamap_unload(dmatag, lesc->sc_dmamap);
                bus_dmamem_free(dmatag, &seg, rseg);
                return;
        }



Home | Main Index | Thread Index | Old Index