There really is no excuse for using dma_alloc(9) if you have the
bus_dmatag_t available.

This re-uses tulip_busdma_allocmem(), which simplifies the code for
allocating the dmamap and such.

Unfortunately I can't test this myself right now.


Index: if_de.c
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/if_de.c,v
retrieving revision 1.122
diff -u -p -r1.122 if_de.c
--- if_de.c     25 Jun 2015 18:35:48 -0000      1.122
+++ if_de.c     25 Jun 2015 19:14:49 -0000
@@ -4085,7 +4085,8 @@ tulip_txput_setup(tulip_softc_t * const 
        sc->tulip_if.if_start = tulip_ifstart;
        return;
     }
-    bcopy(sc->tulip_setupdata, sc->tulip_setupdma, 
sizeof(sc->tulip_setupdata));
+    bcopy(sc->tulip_setupdata, sc->tulip_setupbuf,
+        sizeof(sc->tulip_setupdata));
     /*
      * Clear WANTSETUP and set DOINGSETUP.  Set know that WANTSETUP is
      * set and DOINGSETUP is clear doing an XOR of the two will DTRT.
@@ -4356,19 +4357,12 @@ tulip_busdma_init(tulip_softc_t * const 
 {
     int error = 0;
 
-    sc->tulip_setupdma = dma_alloc(sizeof(sc->tulip_setupdata), PR_WAITOK);
-
     /*
-     * Allocate dmamap for setup descriptor
+     * Allocate space and dmamap for setup descriptor
      */
-    error = bus_dmamap_create(sc->tulip_dmatag, TULIP_SETUP, 2,
-       TULIP_SETUP, 0, BUS_DMA_NOWAIT, &sc->tulip_setupmap);
-    if (error == 0) {
-       error = bus_dmamap_load(sc->tulip_dmatag, sc->tulip_setupmap,
-           sc->tulip_setupdma, TULIP_SETUP, NULL, BUS_DMA_NOWAIT);
-       if (error)
-           bus_dmamap_destroy(sc->tulip_dmatag, sc->tulip_setupmap);
-    }
+    error = tulip_busdma_allocmem(sc, sizeof(sc->tulip_setupdata),
+                                 &sc->tulip_setupmap, &sc->tulip_setupbuf);
+
     /*
      * Allocate space and dmamap for transmit ring
      */
Index: if_devar.h
===================================================================
RCS file: /home/cvs/src/sys/dev/pci/if_devar.h,v
retrieving revision 1.34
diff -u -p -r1.34 if_devar.h
--- if_devar.h  25 Jun 2015 18:35:48 -0000      1.34
+++ if_devar.h  25 Jun 2015 19:07:19 -0000
@@ -601,7 +601,7 @@ struct _tulip_softc_t {
      * filled.
      */
 #define TULIP_SETUP    192
-    u_int32_t *tulip_setupdma;
+    tulip_desc_t *tulip_setupbuf;
     u_int32_t tulip_setupdata[TULIP_SETUP / sizeof(u_int32_t)];
 
     char tulip_boardid[16];            /* buffer for board ID */

Reply via email to