DPDK patches and discussions
 help / color / mirror / Atom feed
From: Didier Pallard <didier.pallard@6wind.com>
To: thomas.monjalon@6wind.com
Subject: [dpdk-dev] [RFC PATCH 1/2] e1000: release software locked semaphores on initialization
Date: Wed, 19 Feb 2014 12:59:21 +0100	[thread overview]
Message-ID: <1392811162-28527-1-git-send-email-didier.pallard@6wind.com> (raw)

It may happen that DPDK application gets killed while having
acquired locks on the ethernet hardware, causing these locks to
be never released. On next restart of the application, DPDK
skip those ports because it can not acquire the lock,
this may cause some ports (or even complete board if SMBI is locked)
to be inaccessible from DPDK application until reboot of the
hardware.

This patch release locks that are supposed to be locked due to
an improper exit of the application.

8254x series do not have SWFW sempahores.
82571 implementation already has some kind of lock reset at the end of
e1000_init_mac_params_82571 function. Since I have no mean to test this
implementation, code is not modified for this hardware.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
---
 lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c |   29 +++++++++++++++++++++
 lib/librte_pmd_e1000/e1000/e1000_82575.c       |   33 ++++++++++++++++++++++++
 lib/librte_pmd_e1000/e1000/e1000_i210.c        |    3 +--
 lib/librte_pmd_e1000/e1000/e1000_i210.h        |    1 +
 4 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c b/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c
index 60d7c2a..952e8de 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c
+++ b/lib/librte_pmd_e1000/e1000/e1000_80003es2lan.c
@@ -195,6 +195,7 @@ STATIC s32 e1000_init_nvm_params_80003es2lan(struct e1000_hw *hw)
 STATIC s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
 {
 	struct e1000_mac_info *mac = &hw->mac;
+	u16 mask;
 
 	DEBUGFUNC("e1000_init_mac_params_80003es2lan");
 
@@ -267,6 +268,34 @@ STATIC s32 e1000_init_mac_params_80003es2lan(struct e1000_hw *hw)
 	/* set lan id for port to determine which phy lock to use */
 	hw->mac.ops.set_lan_id(hw);
 
+	/* Ensure that all locks are released before first NVM or PHY access */
+
+	/*
+	 * Phy lock should not fail in this early stage. If this is the case,
+	 * it is due to an improper exit of the application.
+	 * So force the release of the faulty lock.
+	 */
+	if (e1000_acquire_phy_80003es2lan(hw) < 0) {
+		if (e1000_get_hw_semaphore_generic(hw) < 0) {
+			DEBUGOUT("SMBI lock released");
+		}
+		e1000_put_hw_semaphore_generic(hw);
+		DEBUGOUT1("SWFW phy%d lock released", hw->bus.func);
+	}
+	e1000_release_phy_80003es2lan(hw);
+
+	/*
+	 * Those one are more tricky since they are common to all ports; but
+	 * swfw_sync retries last long enough (250ms) to be almost sure that if
+	 * lock can not be taken it is due to an improper lock of the
+	 * semaphore.
+	 */
+	mask = E1000_SWFW_EEP_SM | E1000_SWFW_CSR_SM;
+	if (hw->mac.ops.acquire_swfw_sync(hw, mask) < 0) {
+		DEBUGOUT("SWFW common locks released");
+	}
+	hw->mac.ops.release_swfw_sync(hw, mask);
+
 	return E1000_SUCCESS;
 }
 
diff --git a/lib/librte_pmd_e1000/e1000/e1000_82575.c b/lib/librte_pmd_e1000/e1000/e1000_82575.c
index fd15b7b..99c4a1f 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_82575.c
+++ b/lib/librte_pmd_e1000/e1000/e1000_82575.c
@@ -507,6 +507,39 @@ STATIC s32 e1000_init_mac_params_82575(struct e1000_hw *hw)
 	/* set lan id for port to determine which phy lock to use */
 	hw->mac.ops.set_lan_id(hw);
 
+	/* Ensure that all locks are released before first NVM or PHY access */
+
+	/*
+	 * Phy lock should not fail in this early stage. If this is the case,
+	 * it is due to an improper exit of the application.
+	 * So force the release of the faulty lock.
+	 */
+	if (e1000_acquire_phy_82575(hw) < 0) {
+		if (mac->type >= e1000_i210) {
+			if (e1000_get_hw_semaphore_i210(hw) < 0) {
+				DEBUGOUT("SMBI lock released");
+			}
+		} else {
+			if (e1000_get_hw_semaphore_generic(hw) < 0) {
+				DEBUGOUT("SMBI lock released");
+			}
+		}
+		e1000_put_hw_semaphore_generic(hw);
+		DEBUGOUT1("SWFW phy%d lock released", hw->bus.func);
+	}
+	e1000_release_phy_82575(hw);
+
+	/*
+	 * This one is more tricky since it is common to all ports; but
+	 * swfw_sync retries last long enough (1s) to be almost sure that if
+	 * lock can not be taken it is due to an improper lock of the
+	 * semaphore.
+	 */
+	if (hw->mac.ops.acquire_swfw_sync(hw, E1000_SWFW_EEP_SM) < 0) {
+		DEBUGOUT("SWFW common locks released");
+	}
+	hw->mac.ops.release_swfw_sync(hw, E1000_SWFW_EEP_SM);
+
 	return E1000_SUCCESS;
 }
 
diff --git a/lib/librte_pmd_e1000/e1000/e1000_i210.c b/lib/librte_pmd_e1000/e1000/e1000_i210.c
index 722877a..122fe70 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_i210.c
+++ b/lib/librte_pmd_e1000/e1000/e1000_i210.c
@@ -36,7 +36,6 @@ POSSIBILITY OF SUCH DAMAGE.
 
 STATIC s32 e1000_acquire_nvm_i210(struct e1000_hw *hw);
 STATIC void e1000_release_nvm_i210(struct e1000_hw *hw);
-STATIC s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw);
 STATIC s32 e1000_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words,
 				u16 *data);
 STATIC s32 e1000_pool_flash_update_done_i210(struct e1000_hw *hw);
@@ -158,7 +157,7 @@ void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
  *
  *  Acquire the HW semaphore to access the PHY or NVM
  **/
-STATIC s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw)
+s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw)
 {
 	u32 swsm;
 	s32 timeout = hw->nvm.word_size + 1;
diff --git a/lib/librte_pmd_e1000/e1000/e1000_i210.h b/lib/librte_pmd_e1000/e1000/e1000_i210.h
index 44de54b..a9e8a64 100644
--- a/lib/librte_pmd_e1000/e1000/e1000_i210.h
+++ b/lib/librte_pmd_e1000/e1000/e1000_i210.h
@@ -44,6 +44,7 @@ s32 e1000_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset,
 			     u16 words, u16 *data);
 s32 e1000_read_invm_version(struct e1000_hw *hw,
 			    struct e1000_fw_version *invm_ver);
+s32 e1000_get_hw_semaphore_i210(struct e1000_hw *hw);
 s32 e1000_acquire_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
 void e1000_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask);
 s32 e1000_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr,
-- 
1.7.10.4

             reply	other threads:[~2014-02-19 12:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 11:59 Didier Pallard [this message]
2014-02-19 11:59 ` [dpdk-dev] [RFC PATCH 2/2] ixgbe: " Didier Pallard
2014-02-19 12:41   ` Ananyev, Konstantin
2014-02-19 16:52     ` Thomas Monjalon
2014-02-19 17:51       ` Ananyev, Konstantin
2014-02-21 16:30         ` Ananyev, Konstantin
2014-02-24 14:19           ` didier.pallard
2014-02-24 15:34             ` Ananyev, Konstantin
2014-02-25  0:57             ` Ananyev, Konstantin
2014-02-26 10:52               ` didier.pallard
2014-04-08 13:29                 ` [dpdk-dev] [PATCH v3 1/2] " Didier Pallard
2014-04-08 13:29                   ` [dpdk-dev] [PATCH v3 2/2] igb: " Didier Pallard
2014-04-09 15:58                     ` Ananyev, Konstantin
2014-04-09 16:39                       ` Thomas Monjalon
2014-04-09 15:49                   ` [dpdk-dev] [PATCH v3 1/2] ixgbe: " Ananyev, Konstantin
2014-04-09 16:37                     ` Thomas Monjalon

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=1392811162-28527-1-git-send-email-didier.pallard@6wind.com \
    --to=didier.pallard@6wind.com \
    --cc=thomas.monjalon@6wind.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;
as well as URLs for NNTP newsgroup(s).