From patchwork Wed Apr 6 02:26:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8757681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3E9609F336 for ; Wed, 6 Apr 2016 02:34:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4CC30202A1 for ; Wed, 6 Apr 2016 02:34:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6419320295 for ; Wed, 6 Apr 2016 02:34:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1andGl-0003lI-6C; Wed, 06 Apr 2016 02:32:35 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1andD5-0007kh-LS for linux-arm-kernel@lists.infradead.org; Wed, 06 Apr 2016 02:28:49 +0000 Received: by mail-pa0-x229.google.com with SMTP id fe3so22790854pab.1 for ; Tue, 05 Apr 2016 19:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jlZH6TrSOl6sDQw2HazMwdL4Bt5lgUlpAR9QHagGWrY=; b=hDqPsGHHYDhilj6qdTTJDn2zd+JiHSGmodOXcbvpjIEG1zsqBsTZkXgiqlYWKEp1b1 pR5cw8Ao41Ch3CGJjOIRTpQJXVSggGBMd4i+ALfnzcIt7VWVWjSRKcPmNPoGpBPwzJ7h xPkQjOJd2xKI7dAjJTBh1mHn0UxExhZNu75Mqid6cqYHxGntD3zVBqhuGR0kSb3xzUHc Zkxuj4FLSV1kv4r+Jr92sImyLiPewP8qy6XohgxwZBCUnaxZtshgSF7EqJio59zS9XbX 153xnb+9x7hnI22gZ+VjF6kEuPS+x44zhJQa5SaDAEJ832jbYnYjeNIt48h068J/Ms3d 9viA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jlZH6TrSOl6sDQw2HazMwdL4Bt5lgUlpAR9QHagGWrY=; b=SzL0cHWPnTwJtXKsd1Rj4SkZy/lT+higN+UUU3wTbQtlSyCSi7/PJCFEUaGyp5Y6WR 2V4QThK6fle7Jg+bwdOs3gHRDFHKhdmvfK6E8NZuIPVtfyZ0deX3L00IpNmbhkbnijNx 1/+B+RxMF1SF+KIXAFnR7SdLnV7qhB+euUVYTlRbcfMH2TPTlIBH608MlsqjbAmd+K55 PeA+dDfH4EMSPiUUoocC/uL25GPFfxQyDN9W+jY7OX+7bU/kVOP/ydF8OgviGIQ1E2zG LbiGu1ibj6ak1x4ww2bPCCi5/0OWhrjfoTqcJSQzrMHrWPwMeOFCVpsj1FLP6hpMyYbB b6hw== X-Gm-Message-State: AD7BkJLfxR2G46JNSxrw1vVyPsg8dRCu1lzTD8CKlAgTPF/eXg4IPXfFnIU5fhubSLYCyA== X-Received: by 10.66.147.103 with SMTP id tj7mr67291803pab.72.1459909712094; Tue, 05 Apr 2016 19:28:32 -0700 (PDT) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id l14sm528682pfi.23.2016.04.05.19.28.30 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2016 19:28:31 -0700 (PDT) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, fugang.duan@nxp.com, lznuaa@gmail.com Subject: [PATCH net-next V3 14/16] net: fec: create subroutine reset_tx_queue Date: Tue, 5 Apr 2016 19:26:00 -0700 Message-Id: <1459909562-22865-15-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459909562-22865-1-git-send-email-troy.kisky@boundarydevices.com> References: <1459909562-22865-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_192847_894260_6360C330 X-CRM114-Status: GOOD ( 14.02 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, stillcompiling@gmail.com, arnd@arndb.de, sergei.shtylyov@cogentembedded.com, Troy Kisky , gerg@uclinux.org, fabio.estevam@nxp.com, johannes@sipsolutions.net, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Create subroutine reset_tx_queue to have one place to release any queued tx skbs. Signed-off-by: Troy Kisky --- v3: change commit message --- drivers/net/ethernet/freescale/fec_main.c | 50 +++++++++++++++---------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 445443d..a38acf2 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -752,12 +752,33 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev) return NETDEV_TX_OK; } +static void reset_tx_queue(struct fec_enet_private *fep, + struct fec_enet_priv_tx_q *txq) +{ + struct bufdesc *bdp = txq->bd.base; + unsigned int i; + + txq->bd.cur = bdp; + for (i = 0; i < txq->bd.ring_size; i++) { + /* Initialize the BD for every fragment in the page. */ + if (txq->tx_skbuff[i]) { + dev_kfree_skb_any(txq->tx_skbuff[i]); + txq->tx_skbuff[i] = NULL; + } + bdp->cbd_bufaddr = cpu_to_fec32(0); + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? + BD_SC_WRAP : 0); + bdp = fec_enet_get_nextdesc(bdp, &txq->bd); + } + bdp = fec_enet_get_prevdesc(bdp, &txq->bd); + txq->dirty_tx = bdp; +} + /* Init RX & TX buffer descriptors */ static void fec_enet_bd_init(struct net_device *dev) { struct fec_enet_private *fep = netdev_priv(dev); - struct fec_enet_priv_tx_q *txq; struct fec_enet_priv_rx_q *rxq; struct bufdesc *bdp; unsigned int i; @@ -780,26 +801,8 @@ static void fec_enet_bd_init(struct net_device *dev) rxq->bd.cur = rxq->bd.base; } - for (q = 0; q < fep->num_tx_queues; q++) { - /* ...and the same for transmit */ - txq = fep->tx_queue[q]; - bdp = txq->bd.base; - txq->bd.cur = bdp; - - for (i = 0; i < txq->bd.ring_size; i++) { - /* Initialize the BD for every fragment in the page. */ - if (txq->tx_skbuff[i]) { - dev_kfree_skb_any(txq->tx_skbuff[i]); - txq->tx_skbuff[i] = NULL; - } - bdp->cbd_bufaddr = cpu_to_fec32(0); - bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? - BD_SC_WRAP : 0); - bdp = fec_enet_get_nextdesc(bdp, &txq->bd); - } - bdp = fec_enet_get_prevdesc(bdp, &txq->bd); - txq->dirty_tx = bdp; - } + for (q = 0; q < fep->num_tx_queues; q++) + reset_tx_queue(fep, fep->tx_queue[q]); } static void fec_enet_active_rxring(struct net_device *ndev) @@ -2648,13 +2651,10 @@ static void fec_enet_free_buffers(struct net_device *ndev) for (q = 0; q < fep->num_tx_queues; q++) { txq = fep->tx_queue[q]; - bdp = txq->bd.base; + reset_tx_queue(fep, txq); for (i = 0; i < txq->bd.ring_size; i++) { kfree(txq->tx_bounce[i]); txq->tx_bounce[i] = NULL; - skb = txq->tx_skbuff[i]; - txq->tx_skbuff[i] = NULL; - dev_kfree_skb(skb); } } }