Netdev List
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: netdev@vger.kernel.org
Cc: brking@linux.vnet.ibm.com, jallen@linux.vnet.ibm.com,
	muvic@linux.vnet.ibm.com, tlfalcon@linux.vnet.ibm.com
Subject: [PATCH v3 net-next 07/11] ibmvnic: Wait for any pending scrqs entries at driver close
Date: Tue, 02 May 2017 14:52:53 -0400	[thread overview]
Message-ID: <20170502185253.28214.11101.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com> (raw)
In-Reply-To: <20170502185006.28214.89072.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com>

When closing the ibmvnic driver we need to wait for any pending
sub crq entries to ensure they are handled.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   47 +++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 0400ae7..4da7080 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -743,23 +743,6 @@ static int ibmvnic_open(struct net_device *netdev)
 	return rc;
 }
 
-static void disable_sub_crqs(struct ibmvnic_adapter *adapter)
-{
-	int i;
-
-	if (adapter->tx_scrq) {
-		for (i = 0; i < adapter->req_tx_queues; i++)
-			if (adapter->tx_scrq[i])
-				disable_irq(adapter->tx_scrq[i]->irq);
-	}
-
-	if (adapter->rx_scrq) {
-		for (i = 0; i < adapter->req_rx_queues; i++)
-			if (adapter->rx_scrq[i])
-				disable_irq(adapter->rx_scrq[i]->irq);
-	}
-}
-
 static void clean_tx_pools(struct ibmvnic_adapter *adapter)
 {
 	struct ibmvnic_tx_pool *tx_pool;
@@ -797,15 +780,39 @@ static int __ibmvnic_close(struct net_device *netdev)
 	adapter->state = VNIC_CLOSING;
 	netif_tx_stop_all_queues(netdev);
 
-	clean_tx_pools(adapter);
-	disable_sub_crqs(adapter);
-
 	if (adapter->napi) {
 		for (i = 0; i < adapter->req_rx_queues; i++)
 			napi_disable(&adapter->napi[i]);
 	}
 
+	clean_tx_pools(adapter);
+
+	if (adapter->tx_scrq) {
+		for (i = 0; i < adapter->req_tx_queues; i++)
+			if (adapter->tx_scrq[i]->irq)
+				disable_irq(adapter->tx_scrq[i]->irq);
+	}
+
 	rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN);
+	if (rc)
+		return rc;
+
+	if (adapter->rx_scrq) {
+		for (i = 0; i < adapter->req_rx_queues; i++) {
+			int retries = 10;
+
+			while (pending_scrq(adapter, adapter->rx_scrq[i])) {
+				retries--;
+				mdelay(100);
+
+				if (retries == 0)
+					break;
+			}
+	
+			if (adapter->rx_scrq[i]->irq)
+				disable_irq(adapter->rx_scrq[i]->irq);
+		}
+	}
 
 	adapter->state = VNIC_CLOSED;
 	return rc;

  parent reply	other threads:[~2017-05-02 15:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-02 18:52 [PATCH v3 net-next 00/11] ibmvnic: Updated reset handler and code fixes Nathan Fontenot
2017-05-02 18:52 ` [PATCH v3 net-next 01/11] ibmvnic: Move resource initialization to its own routine Nathan Fontenot
2017-05-02 18:52 ` [PATCH v3 net-next 02/11] ibmvnic: Replace is_closed with state field Nathan Fontenot
2017-05-02 18:52 ` [PATCH v3 net-next 03/11] ibmvnic: Updated reset handling Nathan Fontenot
2017-05-02 18:52 ` [PATCH v3 net-next 04/11] ibmvnic: Delete napi's when releasing driver resources Nathan Fontenot
2017-05-02 18:52 ` [PATCH v3 net-next 05/11] ibmvnic: Whitespace correction in release_rx_pools Nathan Fontenot
2017-05-02 18:52 ` [PATCH v3 net-next 06/11] ibmvnic: Clean up tx pools when closing Nathan Fontenot
2017-05-02 18:52 ` Nathan Fontenot [this message]
2017-05-02 18:52 ` [PATCH v3 net-next 08/11] ibmvnic: Check for driver reset first in ibmvnic_xmit Nathan Fontenot
2017-05-02 18:53 ` [PATCH v3 net-next 09/11] ibmvnic: Continue skb processing after skb completion error Nathan Fontenot
2017-05-02 18:53 ` [PATCH v3 net-next 10/11] ibmvnic: Record SKB RX queue during poll Nathan Fontenot
2017-05-02 18:53 ` [PATCH v3 net-next 11/11] ibmvnic: Move queue restarting in ibmvnic_tx_complete Nathan Fontenot
2017-05-02 19:49 ` [PATCH v3 net-next 00/11] ibmvnic: Updated reset handler and code fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170502185253.28214.11101.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=jallen@linux.vnet.ibm.com \
    --cc=muvic@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=tlfalcon@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox