From nobody@FreeBSD.org  Wed Dec 28 14:09:42 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4C431106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 28 Dec 2011 14:09:42 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 3B3D08FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 28 Dec 2011 14:09:42 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pBSE9fcv054570
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 28 Dec 2011 14:09:41 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id pBSE9fDs054569;
	Wed, 28 Dec 2011 14:09:41 GMT
	(envelope-from nobody)
Message-Id: <201112281409.pBSE9fDs054569@red.freebsd.org>
Date: Wed, 28 Dec 2011 14:09:41 GMT
From: Aleksandr Rybalko <ray@ddteam.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [mips][arge] arge can't allocate ring buffer on multiple up/down
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         163670
>Category:       kern
>Synopsis:       [mips][arge] arge can't allocate ring buffer on multiple up/down
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-mips
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 28 14:10:11 UTC 2011
>Closed-Date:    Sun Sep 08 14:36:34 UTC 2013
>Last-Modified:  Sun Sep 08 14:36:34 UTC 2013
>Originator:     Aleksandr Rybalko
>Release:        HEAD
>Organization:
ZRouter.org
>Environment:
FreeBSD  10.0-CURRENT FreeBSD 10.0-CURRENT #8 r0:228526M: Wed Dec 28 15:47:33 EET 2011     ray@terran.dlink.ua:D-Link_DIR-615-E4  mips
>Description:
Possible memory leak in sys/mips/atheros/if_arge.c, since ring buffer allocated when iface goes up, but not freed.

When it happen I see:
"arge0: initialization failed: no memory for rx buffers"
on console.
>How-To-Repeat:
doing
ifconfig arge0 up
ifconfig arge0 down
multiple times

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-mips 
Responsible-Changed-By: ray 
Responsible-Changed-When: Wed Dec 28 21:51:03 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=163670 
State-Changed-From-To: open->patched 
State-Changed-By: adrian 
State-Changed-When: Tue Mar 13 06:35:06 UTC 2012 
State-Changed-Why:  
Fixed in HEAD in r232912. 

If people would like it backported, go for it. 



http://www.freebsd.org/cgi/query-pr.cgi?pr=163670 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/163670: commit references a PR
Date: Fri,  6 Sep 2013 12:47:22 +0000 (UTC)

 Author: loos
 Date: Fri Sep  6 12:47:14 2013
 New Revision: 255300
 URL: http://svnweb.freebsd.org/changeset/base/255300
 
 Log:
   Fix the leakage of dma tags on if_arge.  The leak occur when arge_start()
   add some packet(s) to tx ring and arge_stop() is called before receive the
   sent packet interrupt from hardware.  Fix arge_stop() to unload the in use
   dma tags and free the associated mbuf.
   
   PR:		178319, 163670
   Approved by:	adrian (mentor)
 
 Modified:
   head/sys/mips/atheros/if_arge.c
 
 Modified: head/sys/mips/atheros/if_arge.c
 ==============================================================================
 --- head/sys/mips/atheros/if_arge.c	Fri Sep  6 12:45:08 2013	(r255299)
 +++ head/sys/mips/atheros/if_arge.c	Fri Sep  6 12:47:14 2013	(r255300)
 @@ -142,6 +142,7 @@ static int arge_resume(device_t);
  static int arge_rx_ring_init(struct arge_softc *);
  static void arge_rx_ring_free(struct arge_softc *sc);
  static int arge_tx_ring_init(struct arge_softc *);
 +static void arge_tx_ring_free(struct arge_softc *);
  #ifdef DEVICE_POLLING
  static int arge_poll(struct ifnet *, enum poll_cmd, int);
  #endif
 @@ -1278,6 +1279,7 @@ arge_stop(struct arge_softc *sc)
  	/* Flush FIFO and free any existing mbufs */
  	arge_flush_ddr(sc);
  	arge_rx_ring_free(sc);
 +	arge_tx_ring_free(sc);
  }
  
  
 @@ -1708,6 +1710,30 @@ arge_tx_ring_init(struct arge_softc *sc)
  }
  
  /*
 + * Free the Tx ring, unload any pending dma transaction and free the mbuf.
 + */
 +static void
 +arge_tx_ring_free(struct arge_softc *sc)
 +{
 +	struct arge_txdesc	*txd;
 +	int			i;
 +
 +	/* Free the Tx buffers. */
 +	for (i = 0; i < ARGE_TX_RING_COUNT; i++) {
 +		txd = &sc->arge_cdata.arge_txdesc[i];
 +		if (txd->tx_dmamap) {
 +			bus_dmamap_sync(sc->arge_cdata.arge_tx_tag,
 +			    txd->tx_dmamap, BUS_DMASYNC_POSTWRITE);
 +			bus_dmamap_unload(sc->arge_cdata.arge_tx_tag,
 +			    txd->tx_dmamap);
 +		}
 +		if (txd->tx_m)
 +			m_freem(txd->tx_m);
 +		txd->tx_m = NULL;
 +	}
 +}
 +
 +/*
   * Initialize the RX descriptors and allocate mbufs for them. Note that
   * we arrange the descriptors in a closed ring, so that the last descriptor
   * points back to the first.
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: loos 
State-Changed-When: Sun Sep 8 14:36:32 UTC 2013 
State-Changed-Why:  
Fixed in -HEAD (and in 10).  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=163670 
>Unformatted:
