Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net-next] ibmvnic: Harden device Command Response Queue handshake
@ 2020-08-31 16:59 Thomas Falcon
  2020-09-01 20:15 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Falcon @ 2020-08-31 16:59 UTC (permalink / raw)
  To: netdev; +Cc: drt, sukadev, ljp, cforno12, Thomas Falcon

In some cases, the device or firmware may be busy when the
driver attempts to perform the CRQ initialization handshake.
If the partner is busy, the hypervisor will return the H_CLOSED
return code. The aim of this patch is that, if the device is not
ready, to query the device a number of times, with a small wait
time in between queries. If all initialization requests fail,
the driver will remain in a dormant state, awaiting a signal
from the device that it is ready for operation.

Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 86a83e5..9943586 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -3566,14 +3566,31 @@ static int ibmvnic_send_crq(struct ibmvnic_adapter *adapter,
 
 static int ibmvnic_send_crq_init(struct ibmvnic_adapter *adapter)
 {
+	struct device *dev = &adapter->vdev->dev;
 	union ibmvnic_crq crq;
+	int retries = 100;
+	int rc;
 
 	memset(&crq, 0, sizeof(crq));
 	crq.generic.first = IBMVNIC_CRQ_INIT_CMD;
 	crq.generic.cmd = IBMVNIC_CRQ_INIT;
 	netdev_dbg(adapter->netdev, "Sending CRQ init\n");
 
-	return ibmvnic_send_crq(adapter, &crq);
+	do {
+		rc = ibmvnic_send_crq(adapter, &crq);
+		if (rc != H_CLOSED)
+			break;
+		retries--;
+		msleep(50);
+
+	} while (retries > 0);
+
+	if (rc) {
+		dev_err(dev, "Failed to send init request, rc = %d\n", rc);
+		return rc;
+	}
+
+	return 0;
 }
 
 static int send_version_xchg(struct ibmvnic_adapter *adapter)
-- 
1.8.3.1


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

* Re: [PATCH net-next] ibmvnic: Harden device Command Response Queue handshake
  2020-08-31 16:59 [PATCH net-next] ibmvnic: Harden device Command Response Queue handshake Thomas Falcon
@ 2020-09-01 20:15 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-09-01 20:15 UTC (permalink / raw)
  To: tlfalcon; +Cc: netdev, drt, sukadev, ljp, cforno12

From: Thomas Falcon <tlfalcon@linux.ibm.com>
Date: Mon, 31 Aug 2020 11:59:57 -0500

> In some cases, the device or firmware may be busy when the
> driver attempts to perform the CRQ initialization handshake.
> If the partner is busy, the hypervisor will return the H_CLOSED
> return code. The aim of this patch is that, if the device is not
> ready, to query the device a number of times, with a small wait
> time in between queries. If all initialization requests fail,
> the driver will remain in a dormant state, awaiting a signal
> from the device that it is ready for operation.
> 
> Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>

Applied to net-next, thank you.

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

end of thread, other threads:[~2020-09-01 20:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-31 16:59 [PATCH net-next] ibmvnic: Harden device Command Response Queue handshake Thomas Falcon
2020-09-01 20:15 ` David Miller

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).