From owner-p4-projects@FreeBSD.ORG Fri Mar 17 22:26:07 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C5D4116A425; Fri, 17 Mar 2006 22:26:07 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8DFE216A423 for ; Fri, 17 Mar 2006 22:26:07 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E493643D64 for ; Fri, 17 Mar 2006 22:26:00 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2HMQ0Cr018008 for ; Fri, 17 Mar 2006 22:26:00 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2HMQ06R018005 for perforce@freebsd.org; Fri, 17 Mar 2006 22:26:00 GMT (envelope-from imp@freebsd.org) Date: Fri, 17 Mar 2006 22:26:00 GMT Message-Id: <200603172226.k2HMQ06R018005@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 93476 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Mar 2006 22:26:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=93476 Change 93476 by imp@imp_Speedy on 2006/03/17 22:25:35 More properly handle writing more packets in atestart_locked. This fixes a race where we could overwrite sent_mbuf[0] before freeing it. Use proper interrupt mask. Single user still works! Affected files ... .. //depot/projects/arm/src/sys/arm/at91/if_ate.c#43 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/if_ate.c#43 (text+ko) ==== @@ -752,8 +752,7 @@ WR4(sc, ETH_HSL, 0); WR4(sc, ETH_CTL, RD4(sc, ETH_CTL) | ETH_CTL_TE | ETH_CTL_RE); - WR4(sc, ETH_IER, /*ETH_ISR_RCOM | ETH_ISR_TCOM | ETH_ISR_RBNA*/ - 0xffffffff); + WR4(sc, ETH_IER, ETH_ISR_RCOM | ETH_ISR_TCOM | ETH_ISR_RBNA); /* * Boot loader fills in MAC address. If that's not the case, then @@ -790,52 +789,50 @@ if (ifp->if_drv_flags & IFF_DRV_OACTIVE) return; -outloop: - /* - * check to see if there's room to put another packet into the - * xmit queue. The EMAC chip has a ping-pong buffer for xmit - * packets. We use OACTIVE to indicate "we can stuff more into - * our buffers (clear) or not (set)." - */ - if (!(RD4(sc, ETH_TSR) & ETH_TSR_BNQ)) { - ifp->if_drv_flags |= IFF_DRV_OACTIVE; - return; - } - IFQ_DRV_DEQUEUE(&ifp->if_snd, m); - if (m == 0) { - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - return; - } - mdefrag = m_defrag(m, M_DONTWAIT); - if (mdefrag == NULL) { - m_freem(m); - return; - } - m = mdefrag; + while (sc->txcur < ATE_MAX_TX_BUFFERS) { + /* + * check to see if there's room to put another packet into the + * xmit queue. The EMAC chip has a ping-pong buffer for xmit + * packets. We use OACTIVE to indicate "we can stuff more into + * our buffers (clear) or not (set)." + */ + if (!(RD4(sc, ETH_TSR) & ETH_TSR_BNQ)) { + ifp->if_drv_flags |= IFF_DRV_OACTIVE; + return; + } + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + if (m == 0) { + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + return; + } + mdefrag = m_defrag(m, M_DONTWAIT); + if (mdefrag == NULL) { + m_freem(m); + return; + } + m = mdefrag; + if (bus_dmamap_load_mbuf_sg(sc->mtag, sc->tx_map[sc->txcur], m, + segs, &nseg, 0) != 0) { + m_freem(m); + continue; + } + bus_dmamap_sync(sc->mtag, sc->tx_map[sc->txcur], + BUS_DMASYNC_PREWRITE); - if (bus_dmamap_load_mbuf_sg(sc->mtag, sc->tx_map[sc->txcur], m, segs, - &nseg, 0) != 0) { - m_freem(m); - goto outloop; - } - bus_dmamap_sync(sc->mtag, sc->tx_map[sc->txcur], BUS_DMASYNC_PREWRITE); - sc->sent_mbuf[sc->txcur] = m; - sc->txcur++; - if (sc->txcur >= ATE_MAX_TX_BUFFERS) - sc->txcur = 0; - - /* - * tell the hardware to xmit the packet. - */ - WR4(sc, ETH_TAR, segs[0].ds_addr); - WR4(sc, ETH_TCR, segs[0].ds_len); + /* + * tell the hardware to xmit the packet. + */ + WR4(sc, ETH_TAR, segs[0].ds_addr); + WR4(sc, ETH_TCR, segs[0].ds_len); - /* - * Tap off here if there is a bpf listener. - */ - BPF_MTAP(ifp, m); + /* + * Tap off here if there is a bpf listener. + */ + BPF_MTAP(ifp, m); - goto outloop; + sc->sent_mbuf[sc->txcur] = m; + sc->txcur++; + } } static void