From owner-p4-projects@FreeBSD.ORG Mon Oct 10 18:36:35 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D3652106567E; Mon, 10 Oct 2011 18:36:34 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 784F9106566B for ; Mon, 10 Oct 2011 18:36:34 +0000 (UTC) (envelope-from jceel@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id 4CBA18FC14 for ; Mon, 10 Oct 2011 18:36:34 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p9AIaYpn052999 for ; Mon, 10 Oct 2011 18:36:34 GMT (envelope-from jceel@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p9AIaYTg052996 for perforce@freebsd.org; Mon, 10 Oct 2011 18:36:34 GMT (envelope-from jceel@freebsd.org) Date: Mon, 10 Oct 2011 18:36:34 GMT Message-Id: <201110101836.p9AIaYTg052996@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jceel@freebsd.org using -f From: Jakub Wojciech Klama To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 200018 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Oct 2011 18:36:35 -0000 http://p4web.freebsd.org/@@200018?ac=10 Change 200018 by jceel@jceel_cyclone on 2011/10/10 18:36:03 Fix locking in lpe_rxintr() - release mutex before calling if_input() and then reacuire it back. Affected files ... .. //depot/projects/soc2011/jceel_lpc/sys/arm/lpc/if_lpe.c#9 edit Differences ... ==== //depot/projects/soc2011/jceel_lpc/sys/arm/lpc/if_lpe.c#9 (text+ko) ==== @@ -84,6 +84,7 @@ }; struct lpe_txdesc { + int lpe_txdesc_first; struct mbuf * lpe_txdesc_mbuf; bus_dmamap_t lpe_txdesc_dmamap; }; @@ -559,6 +560,9 @@ bus_dmamap_sync(sc->lpe_cdata.lpe_tx_ring_tag, sc->lpe_cdata.lpe_tx_ring_map, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); + txd->lpe_txdesc_first = 1; + txd->lpe_txdesc_mbuf = *m_head; + for (i = 0; i < nsegs; i++) { hwd = &sc->lpe_rdata.lpe_tx_ring[prod]; hwd->lhr_data = segs[i].ds_addr; @@ -569,9 +573,6 @@ hwd->lhr_control |= LPE_HWDESC_INTERRUPT; hwd->lhr_control |= LPE_HWDESC_CRC; hwd->lhr_control |= LPE_HWDESC_PAD; - - txd = &sc->lpe_cdata.lpe_tx_desc[prod]; - txd->lpe_txdesc_mbuf = *m_head; } LPE_INC(prod, LPE_TXDESC_NUM); @@ -629,6 +630,8 @@ debugf("status=0x%08x\n", lpe_read_4(sc, LPE_INTSTATUS)); + lpe_lock(sc); + while ((intstatus = lpe_read_4(sc, LPE_INTSTATUS))) { if (intstatus & LPE_INT_RXDONE) lpe_rxintr(sc); @@ -639,7 +642,7 @@ lpe_write_4(sc, LPE_INTCLEAR, 0xffff); } - + lpe_unlock(sc); } static void @@ -667,7 +670,9 @@ m->m_pkthdr.rcvif = ifp; m->m_data += 2; + lpe_unlock(sc); (*ifp->if_input)(ifp, m); + lpe_lock(sc); lpe_init_rxbuf(sc, cons); @@ -700,12 +705,13 @@ bus_dmamap_sync(sc->lpe_cdata.lpe_tx_buf_tag, txd->lpe_txdesc_dmamap, BUS_DMASYNC_POSTWRITE); - if (txd->lpe_txdesc_mbuf != NULL) { + if (txd->lpe_txdesc_first) { bus_dmamap_unload(sc->lpe_cdata.lpe_tx_buf_tag, txd->lpe_txdesc_dmamap); m_freem(txd->lpe_txdesc_mbuf); txd->lpe_txdesc_mbuf = NULL; + txd->lpe_txdesc_first = 0; } LPE_INC(sc->lpe_cdata.lpe_tx_last, LPE_TXDESC_NUM); @@ -946,6 +952,7 @@ txd = &sc->lpe_cdata.lpe_tx_desc[i]; txd->lpe_txdesc_mbuf = NULL; txd->lpe_txdesc_dmamap = NULL; + txd->lpe_txdesc_first = 0; err = bus_dmamap_create(sc->lpe_cdata.lpe_tx_buf_tag, 0, &txd->lpe_txdesc_dmamap);