Patchwork [30/33] sfc: Treat probe as unsuccessful if it scheduled a reset

login
register
mail settings
Submitter Ben Hutchings
Date Dec. 12, 2008, 1 p.m.
Message ID <20081212130011.GD10372@solarflare.com>
Download mbox | patch
Permalink /patch/13734/
State Accepted
Delegated to: David Miller
Headers show

Comments

Ben Hutchings - Dec. 12, 2008, 1 p.m.
From: Steve Hodgson <shodgson@solarflare.com>

efx_pci_probe_main() can return success despite a reset being scheduled.
Catch this and retry or abort probe depending on the reset type.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
---
 drivers/net/sfc/efx.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
David Miller - Dec. 13, 2008, 6:08 a.m.
From: Ben Hutchings <bhutchings@solarflare.com>
Date: Fri, 12 Dec 2008 13:00:12 +0000

> From: Steve Hodgson <shodgson@solarflare.com>
> 
> efx_pci_probe_main() can return success despite a reset being scheduled.
> Catch this and retry or abort probe depending on the reset type.
> 
> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index c094845..0d57c6d 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -2115,8 +2115,6 @@  static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
 	 * we're in STATE_INIT. */
 	for (i = 0; i < 5; i++) {
 		rc = efx_pci_probe_main(efx);
-		if (rc == 0)
-			break;
 
 		/* Serialise against efx_reset(). No more resets will be
 		 * scheduled since efx_stop_all() has been called, and we
@@ -2124,6 +2122,17 @@  static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
 		 * the rtnetlink or driverlink layers. */
 		cancel_work_sync(&efx->reset_work);
 
+		if (rc == 0) {
+			if (efx->reset_pending != RESET_TYPE_NONE) {
+				/* If there was a scheduled reset during
+				 * probe, the NIC is probably hosed anyway */
+				efx_pci_remove_main(efx);
+				rc = -EIO;
+			} else {
+				break;
+			}
+		}
+
 		/* Retry if a recoverably reset event has been scheduled */
 		if ((efx->reset_pending != RESET_TYPE_INVISIBLE) &&
 		    (efx->reset_pending != RESET_TYPE_ALL))