Netdev List
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Emil Tantilov <emil.s.tantilov@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, guru.anbalagane@oracle.com,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next v2 12/21] ixgbevf: fix AER error handling
Date: Tue,  3 Jan 2017 13:07:48 -0800	[thread overview]
Message-ID: <20170103210757.38847-13-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20170103210757.38847-1-jeffrey.t.kirsher@intel.com>

From: Emil Tantilov <emil.s.tantilov@intel.com>

Make sure that we free the IRQs in ixgbevf_io_error_detected() when
responding to an PCIe AER error and also restore them when the
interface recovers from it.

Previously it was possible to trigger BUG_ON() check in free_msix_irqs()
in the case where we call ixgbevf_remove() after a failed recovery from
AER error because the interrupts were not freed.

Also moved the down and free functions into ixgbevf_close_suspend()
same as with ixgbe.

Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 43 +++++++++++++----------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 8574f21..a78e490 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -3228,6 +3228,21 @@ int ixgbevf_open(struct net_device *netdev)
 }
 
 /**
+ * ixgbevf_close_suspend - actions necessary to both suspend and close flows
+ * @adapter: the private adapter struct
+ *
+ * This function should contain the necessary work common to both suspending
+ * and closing of the device.
+ */
+static void ixgbevf_close_suspend(struct ixgbevf_adapter *adapter)
+{
+	ixgbevf_down(adapter);
+	ixgbevf_free_irq(adapter);
+	ixgbevf_free_all_tx_resources(adapter);
+	ixgbevf_free_all_rx_resources(adapter);
+}
+
+/**
  * ixgbevf_close - Disables a network interface
  * @netdev: network interface device structure
  *
@@ -3242,14 +3257,8 @@ int ixgbevf_close(struct net_device *netdev)
 {
 	struct ixgbevf_adapter *adapter = netdev_priv(netdev);
 
-	if (!netif_device_present(netdev))
-		return 0;
-
-	ixgbevf_down(adapter);
-	ixgbevf_free_irq(adapter);
-
-	ixgbevf_free_all_tx_resources(adapter);
-	ixgbevf_free_all_rx_resources(adapter);
+	if (netif_device_present(netdev))
+		ixgbevf_close_suspend(adapter);
 
 	return 0;
 }
@@ -3806,13 +3815,10 @@ static int ixgbevf_suspend(struct pci_dev *pdev, pm_message_t state)
 	rtnl_lock();
 	netif_device_detach(netdev);
 
-	if (netif_running(netdev)) {
-		ixgbevf_down(adapter);
-		ixgbevf_free_irq(adapter);
-		ixgbevf_free_all_tx_resources(adapter);
-		ixgbevf_free_all_rx_resources(adapter);
-		ixgbevf_clear_interrupt_scheme(adapter);
-	}
+	if (netif_running(netdev))
+		ixgbevf_close_suspend(adapter);
+
+	ixgbevf_clear_interrupt_scheme(adapter);
 	rtnl_unlock();
 
 #ifdef CONFIG_PM
@@ -4251,7 +4257,7 @@ static pci_ers_result_t ixgbevf_io_error_detected(struct pci_dev *pdev,
 	}
 
 	if (netif_running(netdev))
-		ixgbevf_down(adapter);
+		ixgbevf_close_suspend(adapter);
 
 	if (!test_and_set_bit(__IXGBEVF_DISABLED, &adapter->state))
 		pci_disable_device(pdev);
@@ -4299,12 +4305,13 @@ static pci_ers_result_t ixgbevf_io_slot_reset(struct pci_dev *pdev)
 static void ixgbevf_io_resume(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
-	struct ixgbevf_adapter *adapter = netdev_priv(netdev);
 
+	rtnl_lock();
 	if (netif_running(netdev))
-		ixgbevf_up(adapter);
+		ixgbevf_open(netdev);
 
 	netif_device_attach(netdev);
+	rtnl_unlock();
 }
 
 /* PCI Error Recovery (ERS) */
-- 
2.9.3

  parent reply	other threads:[~2017-01-03 21:08 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03 21:07 [net-next v2 00/21][pull request] 10GbE Intel Wired LAN Driver Updates 2017-01-03 Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 01/21] ixgbe: do not disable FEC from the driver Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 02/21] ixgbe: Report driver version to firmware for x550 devices Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 03/21] ixgbe: Fix check for ixgbe_phy_x550em_ext_t reset Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 04/21] ixgbe: add mask for 64 RSS queues Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 05/21] ixgbe: Add bounds check for x540 LED functions Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 06/21] ixgbe: Reduce I2C retry count on X550 devices Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 07/21] ixgbe: Fix reporting of 100Mb capability Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 08/21] ixgbe: handle close/suspend race with netif_device_detach/present Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 09/21] ixgbevf: handle race between close and suspend on shutdown Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 10/21] ixgbe: test for trust in macvlan adjustments for VF Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 11/21] ixgbe: fix AER error handling Jeff Kirsher
2017-01-03 21:07 ` Jeff Kirsher [this message]
2017-01-03 21:07 ` [net-next v2 13/21] ixgbe: Fix incorrect bitwise operations of PTP Rx timestamp flags Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 14/21] ixgbevf: restore hw_addr on resume or error Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 15/21] ixgbe: Configure advertised speeds correctly for KR/KX backplane Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 16/21] ixgbe: Fix issues with EEPROM access Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 17/21] ixgbe: Remove unused firmware version functions and method Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 18/21] ixgbe: Implement firmware interface to access some PHYs Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 19/21] ixgbe: Implement support for firmware-controlled PHYs Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 20/21] ixgbevf: Add support for VF promiscuous mode Jeff Kirsher
2017-01-03 21:07 ` [net-next v2 21/21] ixgbe: Add PF " Jeff Kirsher
2017-01-03 21:31 ` [net-next v2 00/21][pull request] 10GbE Intel Wired LAN Driver Updates 2017-01-03 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=20170103210757.38847-13-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=emil.s.tantilov@intel.com \
    --cc=guru.anbalagane@oracle.com \
    --cc=jogreene@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox