On Saturday 23 May 2009 15:59:06 Brad wrote:
> Please test the following diff if you have a de(4) Ethernet
> adapter. This should fix the issues with the bus_dma map
> handling. Already tested by matthieu@ on an alpha.. so I'm
> looking for some further testing.

Anyone? I'd really like to remove the Alpha hack and have this
fixed properly.

>
> Index: if_de.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_de.c,v
> retrieving revision 1.101
> diff -u -p -r1.101 if_de.c
> --- if_de.c   28 Nov 2008 02:44:17 -0000      1.101
> +++ if_de.c   27 Apr 2009 05:15:35 -0000
> @@ -227,6 +227,10 @@ void tulip_initring(tulip_softc_t * cons
>      tulip_desc_t *descs, int ndescs);
>  void tulip_shutdown(void *arg);
>
> +bus_dmamap_t tulip_alloc_rxmap(tulip_softc_t *);
> +void tulip_free_rxmap(tulip_softc_t *, bus_dmamap_t);
> +bus_dmamap_t tulip_alloc_txmap(tulip_softc_t *);
> +void tulip_free_txmap(tulip_softc_t *, bus_dmamap_t);
>
>  void
>  tulip_timeout_callback(void *arg)
> @@ -2859,6 +2863,30 @@ tulip_ifmedia_status(struct ifnet * cons
>      req->ifm_active = tulip_media_to_ifmedia[sc->tulip_media];
>  }
>
> +bus_dmamap_t
> +tulip_alloc_rxmap(tulip_softc_t *sc)
> +{
> +     return (sc->tulip_free_rxmaps[--sc->tulip_num_free_rxmaps]);
> +}
> +
> +void
> +tulip_free_rxmap(tulip_softc_t *sc, bus_dmamap_t map)
> +{
> +     sc->tulip_free_rxmaps[sc->tulip_num_free_rxmaps++] = map;
> +}
> +
> +bus_dmamap_t
> +tulip_alloc_txmap(tulip_softc_t *sc)
> +{
> +     return (sc->tulip_free_txmaps[--sc->tulip_num_free_txmaps]);
> +}
> +
> +void
> +tulip_free_txmap(tulip_softc_t *sc, bus_dmamap_t map)
> +{
> +     sc->tulip_free_txmaps[sc->tulip_num_free_txmaps++] = map;
> +}
> +
>  void
>  tulip_addr_filter(tulip_softc_t * const sc)
>  {
> @@ -3048,7 +3076,7 @@ tulip_reset(tulip_softc_t * const sc)
>           break;
>       map = TULIP_GETCTX(m, bus_dmamap_t);
>       bus_dmamap_unload(sc->tulip_dmatag, map);
> -     sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
> +     tulip_free_txmap(sc, map);
>       m_freem(m);
>      }
>
> @@ -3086,7 +3114,7 @@ tulip_reset(tulip_softc_t * const sc)
>           break;
>       map = TULIP_GETCTX(m, bus_dmamap_t);
>       bus_dmamap_unload(sc->tulip_dmatag, map);
> -     sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
> +     tulip_free_rxmap(sc, map);
>       m_freem(m);
>      }
>
> @@ -3242,12 +3270,9 @@ tulip_rx_intr(tulip_softc_t * const sc)
>           IF_DEQUEUE(&sc->tulip_rxq, ms);
>           for (me = ms; total_len > 0; total_len--) {
>               map = TULIP_GETCTX(me, bus_dmamap_t);
> -#ifdef __alpha__
> -             if (map->_dm_window != NULL)
> -#endif
>               TULIP_RXMAP_POSTSYNC(sc, map);
>               bus_dmamap_unload(sc->tulip_dmatag, map);
> -             sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
> +             tulip_free_rxmap(sc, map);
>  #if defined(DIAGNOSTIC)
>               TULIP_SETCTX(me, NULL);
>  #endif
> @@ -3270,7 +3295,7 @@ tulip_rx_intr(tulip_softc_t * const sc)
>           bus_dmamap_sync(sc->tulip_dmatag, map, 0, me->m_len,
>                           BUS_DMASYNC_POSTREAD|BUS_DMASYNC_POSTWRITE);
>           bus_dmamap_unload(sc->tulip_dmatag, map);
> -         sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
> +         tulip_free_rxmap(sc, map);
>  #if defined(DIAGNOSTIC)
>           TULIP_SETCTX(me, NULL);
>  #endif
> @@ -3318,7 +3343,7 @@ tulip_rx_intr(tulip_softc_t * const sc)
>
>           map = TULIP_GETCTX(me, bus_dmamap_t);
>           bus_dmamap_unload(sc->tulip_dmatag, map);
> -         sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
> +         tulip_free_rxmap(sc, map);
>  #if defined(DIAGNOSTIC)
>           TULIP_SETCTX(me, NULL);
>  #endif
> @@ -3399,9 +3424,9 @@ tulip_rx_intr(tulip_softc_t * const sc)
>        */
>       do {
>           tulip_desc_t * const nextout = ri->ri_nextout;
> -         if (sc->tulip_rxmaps_free > 0)
> -             map = sc->tulip_rxmaps[--sc->tulip_rxmaps_free];
> -         else {
> +         if (sc->tulip_num_free_rxmaps > 0) {
> +             map = tulip_alloc_rxmap(sc);
> +         } else {
>               m_freem(ms);
>               sc->tulip_flags |= TULIP_RXBUFSLOW;
>  #if defined(TULIP_DEBUG)
> @@ -3493,11 +3518,8 @@ tulip_tx_intr(tulip_softc_t * const sc)
>               IF_DEQUEUE(&sc->tulip_txq, m);
>               if (m != NULL) {
>                   bus_dmamap_t map = TULIP_GETCTX(m, bus_dmamap_t);
> -#ifdef __alpha__
> -                 if (map->_dm_window != NULL)
> -#endif
>                   TULIP_TXMAP_POSTSYNC(sc, map);
> -                 sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
> +                 tulip_free_txmap(sc, map);
>  #if NBPFILTER > 0
>                   if (sc->tulip_bpf != NULL)
>                       bpf_mtap(sc->tulip_if.if_bpf, m, BPF_DIRECTION_OUT);
> @@ -3844,14 +3866,14 @@ tulip_txput(tulip_softc_t * const sc, st
>      /*
>       * Reclaim some DMA maps from if we are out.
>       */
> -    if (sc->tulip_txmaps_free == 0) {
> +    if (sc->tulip_num_free_txmaps == 0) {
>  #if defined(TULIP_DEBUG)
>       sc->tulip_dbg.dbg_no_txmaps++;
>  #endif
>       freedescs += tulip_tx_intr(sc);
>      }
> -    if (sc->tulip_txmaps_free > 0)
> -     map = sc->tulip_txmaps[sc->tulip_txmaps_free-1];
> +    if (sc->tulip_num_free_txmaps > 0)
> +     map = tulip_alloc_txmap(sc);
>      else {
>       sc->tulip_flags |= TULIP_WANTTXSTART;
>  #if defined(TULIP_DEBUG)
> @@ -3892,6 +3914,7 @@ tulip_txput(tulip_softc_t * const sc, st
>  #if defined(TULIP_DEBUG)
>               sc->tulip_dbg.dbg_txput_finishes[2]++;
>  #endif
> +             tulip_free_txmap(sc, map);
>               goto finish;
>           }
>           error = bus_dmamap_load_mbuf(sc->tulip_dmatag, map, m,
> BUS_DMA_NOWAIT); @@ -3902,6 +3925,7 @@ tulip_txput(tulip_softc_t * const
> sc, st
>  #if defined(TULIP_DEBUG)
>           sc->tulip_dbg.dbg_txput_finishes[3]++;
>  #endif
> +         tulip_free_txmap(sc, map);
>           goto finish;
>       }
>      }
> @@ -3921,6 +3945,7 @@ tulip_txput(tulip_softc_t * const sc, st
>       sc->tulip_dbg.dbg_txput_finishes[4]++;
>  #endif
>       bus_dmamap_unload(sc->tulip_dmatag, map);
> +     tulip_free_txmap(sc, map);
>       goto finish;
>      }
>      for (; map->dm_nsegs - segcnt > 1; segcnt += 2) {
> @@ -3949,7 +3974,6 @@ tulip_txput(tulip_softc_t * const sc, st
>      TULIP_TXMAP_PRESYNC(sc, map);
>      TULIP_SETCTX(m, map);
>      map = NULL;
> -    --sc->tulip_txmaps_free;         /* commit to using the dmamap */
>
>      /*
>       * The descriptors have been filled in.  Now get ready
> @@ -4408,18 +4432,18 @@ tulip_busdma_init(tulip_softc_t * const
>      }
>
>      /*
> -     * Allocate dmamaps for each transmit descriptors
> +     * Allocate dmamaps for each transmit descriptor, and place on the
> +     * free list.
>       */
>      if (error == 0) {
> -     while (error == 0 && sc->tulip_txmaps_free < TULIP_TXDESCS) {
> +     while (error == 0 && sc->tulip_num_free_txmaps < TULIP_TXDESCS) {
>           bus_dmamap_t map;
>           if ((error = TULIP_TXMAP_CREATE(sc, &map)) == 0)
> -             sc->tulip_txmaps[sc->tulip_txmaps_free++] = map;
> +             tulip_free_txmap(sc, map);
>       }
>       if (error) {
> -         while (sc->tulip_txmaps_free > 0)
> -             bus_dmamap_destroy(sc->tulip_dmatag,
> -                                sc->tulip_txmaps[--sc->tulip_txmaps_free]);
> +         while (sc->tulip_num_free_txmaps > 0)
> +             bus_dmamap_destroy(sc->tulip_dmatag, tulip_alloc_txmap(sc));
>       }
>      }
>
> @@ -4433,18 +4457,18 @@ tulip_busdma_init(tulip_softc_t * const
>      }
>
>      /*
> -     * Allocate dmamaps for each receive descriptors
> +     * Allocate dmamaps for each receive descriptor, and place on the
> +     * free list.
>       */
>      if (error == 0) {
> -     while (error == 0 && sc->tulip_rxmaps_free < TULIP_RXDESCS) {
> +     while (error == 0 && sc->tulip_num_free_rxmaps < TULIP_RXDESCS) {
>           bus_dmamap_t map;
>           if ((error = TULIP_RXMAP_CREATE(sc, &map)) == 0)
> -             sc->tulip_rxmaps[sc->tulip_rxmaps_free++] = map;
> +             tulip_free_rxmap(sc, map);
>       }
>       if (error) {
> -         while (sc->tulip_rxmaps_free > 0)
> -             bus_dmamap_destroy(sc->tulip_dmatag,
> -                                sc->tulip_rxmaps[--sc->tulip_rxmaps_free]);
> +         while (sc->tulip_num_free_rxmaps > 0)
> +             bus_dmamap_destroy(sc->tulip_dmatag, tulip_alloc_rxmap(sc));
>       }
>      }
>      return (error);
> Index: if_devar.h
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_devar.h,v
> retrieving revision 1.29
> diff -u -p -r1.29 if_devar.h
> --- if_devar.h        15 Aug 2008 15:49:08 -0000      1.29
> +++ if_devar.h        27 Apr 2009 05:05:48 -0000
> @@ -435,11 +435,11 @@ struct _tulip_softc_t {
>      bus_dma_tag_t tulip_dmatag;              /* bus DMA tag */
>      bus_dmamap_t tulip_setupmap;
>      bus_dmamap_t tulip_txdescmap;
> -    bus_dmamap_t tulip_txmaps[TULIP_TXDESCS];
> -    unsigned tulip_txmaps_free;
> +    bus_dmamap_t tulip_free_txmaps[TULIP_TXDESCS];
> +    unsigned tulip_num_free_txmaps;
>      bus_dmamap_t tulip_rxdescmap;
> -    bus_dmamap_t tulip_rxmaps[TULIP_RXDESCS];
> -    unsigned tulip_rxmaps_free;
> +    bus_dmamap_t tulip_free_rxmaps[TULIP_RXDESCS];
> +    unsigned tulip_num_free_rxmaps;
>      struct arpcom tulip_ac;
>      struct timeout tulip_ftmo, tulip_stmo;
>      tulip_regfile_t tulip_csrs;



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to