netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] ibmvnic: Fix parameter change request handling
@ 2018-04-11 14:37 Nathan Fontenot
  2018-04-11 14:37 ` [PATCH net 1/2] ibmvnic: Handle all login error conditions Nathan Fontenot
  2018-04-11 14:37 ` [PATCH net 2/2] ibmvnic: Do not notify peers on parameter change resets Nathan Fontenot
  0 siblings, 2 replies; 5+ messages in thread
From: Nathan Fontenot @ 2018-04-11 14:37 UTC (permalink / raw)
  To: netdev; +Cc: jallen, tlfalcon

When updating parameters for the ibmvnic driver there is a possibility
of entering an infinite loop if a return value other that a partial
success is received from sending the login CRQ.

Also, a deadlock can occur on the rtnl lock if netdev_notify_peers()
is called during driver reset for a parameter change reset.

This patch set corrects both of these issues by updating the return
code handling in ibmvnic_login() nand gaurding against calling
netdev_notify_peers() for parameter change requests.

-Nathan
---

Nathan Fontenot (2):
      ibmvnic: Handle all login error conditions
      ibmvnic: Do not notify peers on parameter change resets


 drivers/net/ethernet/ibm/ibmvnic.c |   58 +++++++++++++++++++++++-------------
 drivers/net/ethernet/ibm/ibmvnic.h |    1 -
 2 files changed, 37 insertions(+), 22 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net 1/2] ibmvnic: Handle all login error conditions
  2018-04-11 14:37 [PATCH net 0/2] ibmvnic: Fix parameter change request handling Nathan Fontenot
@ 2018-04-11 14:37 ` Nathan Fontenot
  2018-04-11 15:07   ` David Miller
  2018-04-11 14:37 ` [PATCH net 2/2] ibmvnic: Do not notify peers on parameter change resets Nathan Fontenot
  1 sibling, 1 reply; 5+ messages in thread
From: Nathan Fontenot @ 2018-04-11 14:37 UTC (permalink / raw)
  To: netdev; +Cc: jallen, tlfalcon

There is a bug in handling the possible return codes from sending the
login CRQ. The current code treats any non-success return value,
minus failure to send the crq and a timeout waiting for a login response,
as a need to re-send the login CRQ. This can put the drive in an
inifinite loop of trying to login when getting return values other
that a partial success such as a return code of aborted. For these
scenarios the login will not ever succeed at this point and the
driver would need to be reset again.

To resolve this loop trying to login is updated to only retry the
login if the driver gets a return code of a partial success. Other
return coes are treated as an error and the driver returns an error
from ibmvnic_login().

To avoid infinite looping in the partial success return cases, the
number of retries is capped at the maximum number of supported
queues. This value was chosen because the driver does a renegatiation
of capabilities which sets the number of queus possible and allows
the driver to attempt a login for possible value for the number
of queues supported.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   55 +++++++++++++++++++++++-------------
 drivers/net/ethernet/ibm/ibmvnic.h |    1 -
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index aad5658d79d5..c6d5e9448eef 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -794,46 +794,61 @@ static int ibmvnic_login(struct net_device *netdev)
 {
 	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
 	unsigned long timeout = msecs_to_jiffies(30000);
-	struct device *dev = &adapter->vdev->dev;
+	int retry_count = 0;
 	int rc;
 
 	do {
-		if (adapter->renegotiate) {
-			adapter->renegotiate = false;
+		if (retry_count > IBMVNIC_MAX_QUEUES) {
+			netdev_warn(netdev, "Login attempts exceeded\n");
+			return -1;
+		}
+
+		adapter->init_done_rc = 0;
+		reinit_completion(&adapter->init_done);
+		rc = send_login(adapter);
+		if (rc) {
+			netdev_warn(netdev, "Unable to login\n");
+			return rc;
+		}
+
+		if (!wait_for_completion_timeout(&adapter->init_done,
+						 timeout)) {
+			netdev_warn(netdev, "Login timed out\n");
+			return -1;
+		}
+
+		if (adapter->init_done_rc == PARTIALSUCCESS) {
+			retry_count++;
 			release_sub_crqs(adapter, 1);
 
+			adapter->init_done_rc = 0;
 			reinit_completion(&adapter->init_done);
 			send_cap_queries(adapter);
 			if (!wait_for_completion_timeout(&adapter->init_done,
 							 timeout)) {
-				dev_err(dev, "Capabilities query timeout\n");
+				netdev_warn(netdev,
+					    "Capabilities query timed out\n");
 				return -1;
 			}
+
 			rc = init_sub_crqs(adapter);
 			if (rc) {
-				dev_err(dev,
-					"Initialization of SCRQ's failed\n");
+				netdev_warn(netdev,
+					    "SCRQ initialization failed\n");
 				return -1;
 			}
+
 			rc = init_sub_crq_irqs(adapter);
 			if (rc) {
-				dev_err(dev,
-					"Initialization of SCRQ's irqs failed\n");
+				netdev_warn(netdev,
+					    "SCRQ irq initialization failed\n");
 				return -1;
 			}
-		}
-
-		reinit_completion(&adapter->init_done);
-		rc = send_login(adapter);
-		if (rc) {
-			dev_err(dev, "Unable to attempt device login\n");
-			return rc;
-		} else if (!wait_for_completion_timeout(&adapter->init_done,
-						 timeout)) {
-			dev_err(dev, "Login timeout\n");
+		} else if (adapter->init_done_rc) {
+			netdev_warn(netdev, "Adapter login failed\n");
 			return -1;
 		}
-	} while (adapter->renegotiate);
+	} while (adapter->init_done_rc == PARTIALSUCCESS);
 
 	/* handle pending MAC address changes after successful login */
 	if (adapter->mac_change_pending) {
@@ -3942,7 +3957,7 @@ static int handle_login_rsp(union ibmvnic_crq *login_rsp_crq,
 	 * to resend the login buffer with fewer queues requested.
 	 */
 	if (login_rsp_crq->generic.rc.code) {
-		adapter->renegotiate = true;
+		adapter->init_done_rc = login_rsp_crq->generic.rc.code;
 		complete(&adapter->init_done);
 		return 0;
 	}
diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
index 99c0b58c2c39..22391e8805f6 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.h
+++ b/drivers/net/ethernet/ibm/ibmvnic.h
@@ -1035,7 +1035,6 @@ struct ibmvnic_adapter {
 
 	struct ibmvnic_sub_crq_queue **tx_scrq;
 	struct ibmvnic_sub_crq_queue **rx_scrq;
-	bool renegotiate;
 
 	/* rx structs */
 	struct napi_struct *napi;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net 2/2] ibmvnic: Do not notify peers on parameter change resets
  2018-04-11 14:37 [PATCH net 0/2] ibmvnic: Fix parameter change request handling Nathan Fontenot
  2018-04-11 14:37 ` [PATCH net 1/2] ibmvnic: Handle all login error conditions Nathan Fontenot
@ 2018-04-11 14:37 ` Nathan Fontenot
  1 sibling, 0 replies; 5+ messages in thread
From: Nathan Fontenot @ 2018-04-11 14:37 UTC (permalink / raw)
  To: netdev; +Cc: jallen, tlfalcon

When attempting to change the driver parameters, such as the MTU
value or number of queues, do not call netdev_notify_peers().
Doing so will deadlock on the rtnl_lock.

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

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index c6d5e9448eef..fdca1ea5bbf9 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1843,7 +1843,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,
 	for (i = 0; i < adapter->req_rx_queues; i++)
 		napi_schedule(&adapter->napi[i]);
 
-	if (adapter->reset_reason != VNIC_RESET_FAILOVER)
+	if (adapter->reset_reason != VNIC_RESET_FAILOVER &&
+	    adapter->reset_reason != VNIC_RESET_CHANGE_PARAM)
 		netdev_notify_peers(netdev);
 
 	netif_carrier_on(netdev);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] ibmvnic: Handle all login error conditions
  2018-04-11 14:37 ` [PATCH net 1/2] ibmvnic: Handle all login error conditions Nathan Fontenot
@ 2018-04-11 15:07   ` David Miller
  2018-04-11 15:24     ` Nathan Fontenot
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2018-04-11 15:07 UTC (permalink / raw)
  To: nfont; +Cc: netdev, jallen, tlfalcon

From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
Date: Wed, 11 Apr 2018 09:37:21 -0500

> There is a bug in handling the possible return codes from sending the
> login CRQ. The current code treats any non-success return value,
> minus failure to send the crq and a timeout waiting for a login response,
> as a need to re-send the login CRQ. This can put the drive in an
                                                       ^^^^^

"driver"

> inifinite loop of trying to login when getting return values other
  ^^^^^^^^^

"infinite"

> that a partial success such as a return code of aborted. For these
> scenarios the login will not ever succeed at this point and the
> driver would need to be reset again.
> 
> To resolve this loop trying to login is updated to only retry the
> login if the driver gets a return code of a partial success. Other
> return coes are treated as an error and the driver returns an error
         ^^^^

"codes"

> from ibmvnic_login().
> 
> To avoid infinite looping in the partial success return cases, the
> number of retries is capped at the maximum number of supported
> queues. This value was chosen because the driver does a renegatiation
                                                          ^^^^^^^^^^^^^

"renegotiation"

> of capabilities which sets the number of queus possible and allows
                                           ^^^^^

"queues"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net 1/2] ibmvnic: Handle all login error conditions
  2018-04-11 15:07   ` David Miller
@ 2018-04-11 15:24     ` Nathan Fontenot
  0 siblings, 0 replies; 5+ messages in thread
From: Nathan Fontenot @ 2018-04-11 15:24 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, jallen, tlfalcon

On 04/11/2018 10:07 AM, David Miller wrote:
> From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
> Date: Wed, 11 Apr 2018 09:37:21 -0500
> 
>> There is a bug in handling the possible return codes from sending the
>> login CRQ. The current code treats any non-success return value,
>> minus failure to send the crq and a timeout waiting for a login response,
>> as a need to re-send the login CRQ. This can put the drive in an
>                                                        ^^^^^
> 
> "driver"
> 
>> inifinite loop of trying to login when getting return values other
>   ^^^^^^^^^
> 
> "infinite"
> 
>> that a partial success such as a return code of aborted. For these
>> scenarios the login will not ever succeed at this point and the
>> driver would need to be reset again.
>>
>> To resolve this loop trying to login is updated to only retry the
>> login if the driver gets a return code of a partial success. Other
>> return coes are treated as an error and the driver returns an error
>          ^^^^
> 
> "codes"
> 
>> from ibmvnic_login().
>>
>> To avoid infinite looping in the partial success return cases, the
>> number of retries is capped at the maximum number of supported
>> queues. This value was chosen because the driver does a renegatiation
>                                                           ^^^^^^^^^^^^^
> 
> "renegotiation"
> 
>> of capabilities which sets the number of queus possible and allows
>                                            ^^^^^
> 
> "queues"
> 

Oh man, complete spelling failure. resending.

-Nathan

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-04-11 15:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-11 14:37 [PATCH net 0/2] ibmvnic: Fix parameter change request handling Nathan Fontenot
2018-04-11 14:37 ` [PATCH net 1/2] ibmvnic: Handle all login error conditions Nathan Fontenot
2018-04-11 15:07   ` David Miller
2018-04-11 15:24     ` Nathan Fontenot
2018-04-11 14:37 ` [PATCH net 2/2] ibmvnic: Do not notify peers on parameter change resets Nathan Fontenot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).