All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Andrew Bowers <andrewx.bowers@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 07/17] ice: Fix probe/open race condition
Date: Thu, 21 May 2020 23:55:57 -0700	[thread overview]
Message-ID: <20200522065607.1680050-8-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20200522065607.1680050-1-jeffrey.t.kirsher@intel.com>

From: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>

As soon as the driver registers the PF netdev, userspace utilities
like NetworkManager try to bring up the associated interface. When
this happens, the driver may not have finished initializing fully,
resulting in a bunch of errors in the interface up flow.

The driver already has a mechanism to indicate if it's not up yet;
by setting the __ICE_DOWN bit in pf->state, but this bit gets
cleared too early in the current flow. So clear this bit only when
the driver is fully up. Also check for the same bit in the ice_open
flow, and return -EBUSY if the bit is set.

Also in ice_open, replace references of vsi->back with a local
variable.

Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_main.c | 24 +++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 8c792ecc6550..de81d9049b97 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2137,10 +2137,8 @@ static irqreturn_t ice_misc_intr(int __always_unused irq, void *data)
 	}
 	ret = IRQ_HANDLED;
 
-	if (!test_bit(__ICE_DOWN, pf->state)) {
-		ice_service_task_schedule(pf);
-		ice_irq_dynamic_ena(hw, NULL, NULL);
-	}
+	ice_service_task_schedule(pf);
+	ice_irq_dynamic_ena(hw, NULL, NULL);
 
 	return ret;
 }
@@ -3312,9 +3310,6 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 		goto err_init_interrupt_unroll;
 	}
 
-	/* Driver is mostly up */
-	clear_bit(__ICE_DOWN, pf->state);
-
 	/* In case of MSIX we are going to setup the misc vector right here
 	 * to handle admin queue events etc. In case of legacy and MSI
 	 * the misc functionality and queue processing is combined in
@@ -3370,9 +3365,9 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 
 	ice_verify_cacheline_size(pf);
 
-	/* If no DDP driven features have to be setup, return here */
+	/* If no DDP driven features have to be setup, we are done with probe */
 	if (ice_is_safe_mode(pf))
-		return 0;
+		goto probe_done;
 
 	/* initialize DDP driven features */
 
@@ -3387,6 +3382,9 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	/* print PCI link speed and width */
 	pcie_print_link_status(pf->pdev);
 
+probe_done:
+	/* ready to go, so clear down state bit */
+	clear_bit(__ICE_DOWN, pf->state);
 	return 0;
 
 err_alloc_sw_unroll:
@@ -5261,14 +5259,20 @@ int ice_open(struct net_device *netdev)
 {
 	struct ice_netdev_priv *np = netdev_priv(netdev);
 	struct ice_vsi *vsi = np->vsi;
+	struct ice_pf *pf = vsi->back;
 	struct ice_port_info *pi;
 	int err;
 
-	if (test_bit(__ICE_NEEDS_RESTART, vsi->back->state)) {
+	if (test_bit(__ICE_NEEDS_RESTART, pf->state)) {
 		netdev_err(netdev, "driver needs to be unloaded and reloaded\n");
 		return -EIO;
 	}
 
+	if (test_bit(__ICE_DOWN, pf->state)) {
+		netdev_err(netdev, "device is not ready yet\n");
+		return -EBUSY;
+	}
+
 	netif_carrier_off(netdev);
 
 	pi = vsi->port_info;
-- 
2.26.2


  parent reply	other threads:[~2020-05-22  6:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22  6:55 [net-next 00/17][pull request] 100GbE Intel Wired LAN Driver Updates 2020-05-21 Jeff Kirsher
2020-05-22  6:55 ` [net-next 01/17] ice: report netlist version in .info_get Jeff Kirsher
2020-05-22  6:55 ` [net-next 02/17] ice: Add support for tunnel offloads Jeff Kirsher
2020-05-22  6:55 ` [net-next 03/17] ice: Add VF promiscuous support Jeff Kirsher
2020-05-22  6:55 ` [net-next 04/17] ice: Don't reset and rebuild for Tx timeout on PFC enabled queue Jeff Kirsher
2020-05-22  6:55 ` [net-next 05/17] ice: Fix check for contiguous TCs Jeff Kirsher
2020-05-22  6:55 ` [net-next 06/17] ice: only drop link once when setting pauseparams Jeff Kirsher
2020-05-22  6:55 ` Jeff Kirsher [this message]
2020-05-22  6:55 ` [net-next 08/17] ice: Provide more meaningful error message Jeff Kirsher
2020-05-22  6:55 ` [net-next 09/17] ice: Fix casting issues Jeff Kirsher
2020-05-22  6:56 ` [net-next 10/17] ice: cleanup vf_id signedness Jeff Kirsher
2020-05-22  6:56 ` [net-next 11/17] ice: Fix resource leak on early exit from function Jeff Kirsher
2020-05-26  0:23   ` Sasha Levin
2020-05-22  6:56 ` [net-next 12/17] ice: refactor filter functions Jeff Kirsher
2020-05-22  6:56 ` [net-next 13/17] ice: Fix check for removing/adding mac filters Jeff Kirsher
2020-05-22  6:56 ` [net-next 14/17] ice: remove unnecessary expression that is always true Jeff Kirsher
2020-05-22  6:56 ` [net-next 15/17] ice: remove unnecessary check Jeff Kirsher
2020-05-22  6:56 ` [net-next 16/17] ice: remove unnecessary backslash Jeff Kirsher
2020-05-22  6:56 ` [net-next 17/17] ice: Rename build_ctob to ice_build_ctob Jeff Kirsher
2020-05-22 18:14 ` [net-next 00/17][pull request] 100GbE Intel Wired LAN Driver Updates 2020-05-21 Jakub Kicinski
2020-05-22 21:05 ` 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=20200522065607.1680050-8-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=andrewx.bowers@intel.com \
    --cc=anirudh.venkataramanan@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.