All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v2 08/18] fm10k: split fm10k_reinit into two functions
Date: Tue,  7 Jun 2016 16:08:52 -0700	[thread overview]
Message-ID: <20160607230902.5457-9-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20160607230902.5457-1-jacob.e.keller@intel.com>

There are several flows in the driver which perform the similar function
of tearing down software and restoring software to recover from certain
errors or PCIe events, including:

  * fm10k_reinit
  * fm10k_suspend/resume
  * fm10k_io_error_detected/fm10k_io_resume

In addition, we want to implement a .reset_notify() handler as well
which will also perform similar function.

Rework how the driver codes reset and resume flows by separating out the
reinit logic into two functions "fm10k_prepare_for_reset" and
"fm10k_handle_reset". This first step will allow us to re-use this
functionality in the similar blocks of code instead of re-coding the
same sequence of events slightly different.

The end result should be more maintainable and correct, fixing several
inconsistencies with the work flow.

The new functions expect to take the rtnl_lock() themselves, and it does
have the unfortunate side effect of having the reinit flow take then
release then take the rtnl_lock. However, this minor downside is
outweighted by the benefits of code reduction and reducing needless
difference between these flows.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/fm10k/fm10k_pci.c | 33 +++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
index 7c9b20c6b6c1..2963b41d01e2 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_pci.c
@@ -136,11 +136,9 @@ static void fm10k_detach_subtask(struct fm10k_intfc *interface)
 	rtnl_unlock();
 }
 
-static void fm10k_reinit(struct fm10k_intfc *interface)
+static void fm10k_prepare_for_reset(struct fm10k_intfc *interface)
 {
 	struct net_device *netdev = interface->netdev;
-	struct fm10k_hw *hw = &interface->hw;
-	int err;
 
 	WARN_ON(in_interrupt());
 
@@ -165,6 +163,17 @@ static void fm10k_reinit(struct fm10k_intfc *interface)
 	/* delay any future reset requests */
 	interface->last_reset = jiffies + (10 * HZ);
 
+	rtnl_unlock();
+}
+
+static int fm10k_handle_reset(struct fm10k_intfc *interface)
+{
+	struct net_device *netdev = interface->netdev;
+	struct fm10k_hw *hw = &interface->hw;
+	int err;
+
+	rtnl_lock();
+
 	/* reset and initialize the hardware so it is in a known state */
 	err = hw->mac.ops.reset_hw(hw);
 	if (err) {
@@ -185,7 +194,7 @@ static void fm10k_reinit(struct fm10k_intfc *interface)
 		goto reinit_err;
 	}
 
-	/* reassociate interrupts */
+	/* re-associate interrupts */
 	err = fm10k_mbx_request_irq(interface);
 	if (err)
 		goto err_mbx_irq;
@@ -219,7 +228,7 @@ static void fm10k_reinit(struct fm10k_intfc *interface)
 
 	clear_bit(__FM10K_RESETTING, &interface->state);
 
-	return;
+	return err;
 err_open:
 	fm10k_mbx_free_irq(interface);
 err_mbx_irq:
@@ -230,6 +239,20 @@ reinit_err:
 	rtnl_unlock();
 
 	clear_bit(__FM10K_RESETTING, &interface->state);
+
+	return err;
+}
+
+static void fm10k_reinit(struct fm10k_intfc *interface)
+{
+	int err;
+
+	fm10k_prepare_for_reset(interface);
+
+	err = fm10k_handle_reset(interface);
+	if (err)
+		dev_err(&interface->pdev->dev,
+			"fm10k_handle_reset failed: %d\n", err);
 }
 
 static void fm10k_reset_subtask(struct fm10k_intfc *interface)
-- 
2.9.0.rc1.405.g81f467e


  parent reply	other threads:[~2016-06-07 23:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07 23:08 [Intel-wired-lan] [PATCH v2 00/18] fm10k fixes for suspend/resume and related Jacob Keller
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 01/18] fm10k: prevent multiple threads updating statistics Jacob Keller
2016-07-11 19:24   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 02/18] fm10k: Reset mailbox global interrupts Jacob Keller
2016-06-23 23:19   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 03/18] fm10k: don't stop reset due to FM10K_ERR_REQUESTS_PENDING Jacob Keller
2016-06-23 23:19   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 04/18] fm10k: perform data path reset even when switch is not ready Jacob Keller
2016-06-23 23:20   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 05/18] fm10k: use actual hardware registers when checking for pending Tx Jacob Keller
2016-06-23 23:22   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 06/18] fm10k: only warn when stop_hw fails with FM10K_ERR_REQUESTS_PENDING Jacob Keller
2016-06-23 23:23   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 07/18] fm10k: wait for queues to drain if stop_hw() fails once Jacob Keller
2016-06-23 23:24   ` Singh, Krishneil K
2016-06-07 23:08 ` Jacob Keller [this message]
2016-06-23 23:25   ` [Intel-wired-lan] [PATCH v2 08/18] fm10k: split fm10k_reinit into two functions Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 09/18] fm10k: implement prepare_suspend and handle_resume Jacob Keller
2016-06-23 23:25   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 10/18] fm10k: use common reset flow when handling io errors from PCI stack Jacob Keller
2016-06-23 23:26   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 11/18] fm10k: implement reset_notify handler for PCIe FLR events Jacob Keller
2016-06-23 23:27   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 12/18] fm10k: use common flow for suspend and resume Jacob Keller
2016-06-23 23:28   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 13/18] fm10k: enable bus master after every reset Jacob Keller
2016-06-23 23:29   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 14/18] fm10k: check if PCIe link is restored Jacob Keller
2016-06-23 23:29   ` Singh, Krishneil K
2016-06-07 23:08 ` [Intel-wired-lan] [PATCH v2 15/18] fm10k: implement request_lport_map pointer Jacob Keller
2016-06-23 23:30   ` Singh, Krishneil K
2016-06-07 23:09 ` [Intel-wired-lan] [PATCH v2 16/18] fm10k: force link to remain down for at least a second on resume events Jacob Keller
2016-06-23 23:31   ` Singh, Krishneil K
2016-06-07 23:09 ` [Intel-wired-lan] [PATCH v2 17/18] fm10k: return proper error code when pci_enable_msix_range fails Jacob Keller
2016-06-23 23:31   ` Singh, Krishneil K
2016-06-07 23:09 ` [Intel-wired-lan] [PATCH v2 18/18] fm10k: bump version number Jacob Keller
2016-06-14 16:47   ` Singh, Krishneil K

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=20160607230902.5457-9-jacob.e.keller@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /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.