From patchwork Thu Feb 25 00:36:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8415591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A9BE2C0553 for ; Thu, 25 Feb 2016 00:49:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C6DF02010C for ; Thu, 25 Feb 2016 00:49:06 +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 E0DC020108 for ; Thu, 25 Feb 2016 00:49:05 +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 1aYk5N-0006Bj-2v; Thu, 25 Feb 2016 00:47:17 +0000 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aYjzF-000833-OH for linux-arm-kernel@lists.infradead.org; Thu, 25 Feb 2016 00:40:59 +0000 Received: by mail-pa0-x231.google.com with SMTP id fl4so21829896pad.0 for ; Wed, 24 Feb 2016 16:40:37 -0800 (PST) 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=BDBuNo1x+hR9YSfRWejeHou5w9s7pjNmsMruxxpY0aM=; b=fgebwWwX278vg6NyXih32MLyvoCR8o42RLLKanhZckwBa2f1JpAE5KbrD6caEDwaE1 2edXP/dY48upSZ/NlcC/e2mwlRq7HUz5tL2mGWLsy5BwmVYLq+iqDA4odnTmNdRoX7BA VXngIyrPx8u8ylvBHpqN3Xd5ViMIrIqe4Mp1C8sTynpezqDQAMjzV9YUQGseRzE7cM1V KhQq/pOFRXZK1OOyXV921NAgjHJTu3Mmk9/J2le9Zh/BWGypBtdiV1tFR2x9AJRLk7EV EoGrTkVhGkvdqIHUMcVUrjUvbN6FA5mWDpKLmQSRSQunbGzoWku+LeuhaahRX0h8GWdh DybQ== 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=BDBuNo1x+hR9YSfRWejeHou5w9s7pjNmsMruxxpY0aM=; b=OjBeHrPkXWXhzXPiHwO5IM5bWvM5SOrEW6F232t/kF4/TqGEJJUwBSOSk+iYhcllRj Pqc8momOxmRcHopD5JF75HaBHJohLgh0LMNweTIfxQ43xZMtv2hX4rP1MqDQtXENbYv4 rzavQDvzHdybglwiLb1sQPAUwGfBNDke+4hpnBE/M3E3334MgZeMMYTKK5ndihsenke1 +TPDn3hmEZeNDyJ1Jpk2MFzQKYsdJ8+QqVNN6zfQ9b7ElSiT710sJCFLSM1/6Yes+18t JCnLsQyOZ5KFm1dLegZuBYTLHse8wkrO2Uwb5TNxDiZG8Ap6raDY2/F6xEVHreRMe+SV XJpw== X-Gm-Message-State: AG10YOTBdFtxYv/9e246kdEcCJDRbWmni9JlgCb9R1IYaG27KOVUv2fKImlye9OEU4fAsA== X-Received: by 10.66.62.226 with SMTP id b2mr58932729pas.94.1456360837142; Wed, 24 Feb 2016 16:40:37 -0800 (PST) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id 79sm7561982pfr.22.2016.02.24.16.40.35 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 24 Feb 2016 16:40:36 -0800 (PST) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, B38611@freescale.com Subject: [PATCH net-next V2 14/16] net: fec: create subroutine reset_tx_queue Date: Wed, 24 Feb 2016 17:36:57 -0700 Message-Id: <1456360619-24390-15-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456360619-24390-1-git-send-email-troy.kisky@boundarydevices.com> References: <1456360619-24390-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160224_164058_048430_D3068FB5 X-CRM114-Status: GOOD ( 14.45 ) X-Spam-Score: -2.6 (--) 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: fabio.estevam@freescale.com, andrew@lunn.ch, stillcompiling@gmail.com, linux@arm.linux.org.uk, arnd@arndb.de, sergei.shtylyov@cogentembedded.com, Troy Kisky , laci@boundarydevices.com, johannes@sipsolutions.net, l.stach@pengutronix.de, shawnguo@kernel.org, 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=-4.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 This creates one place to release any queued tx skbs. Signed-off-by: Troy Kisky --- 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 9a3136b..8711196 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) @@ -2652,13 +2655,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); } } }