DPDK patches and discussions
 help / color / mirror / Atom feed
From: Didier Pallard <didier.pallard@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 2/2] igb: release software locked semaphores on initialization
Date: Tue,  8 Apr 2014 15:29:58 +0200	[thread overview]
Message-ID: <1396963798-13123-2-git-send-email-didier.pallard@6wind.com> (raw)
In-Reply-To: <1396963798-13123-1-git-send-email-didier.pallard@6wind.com>

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.

Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
---

v3: Move code outside from base driver

 lib/librte_pmd_e1000/igb_ethdev.c |   69 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 68 insertions(+), 1 deletion(-)

diff --git a/lib/librte_pmd_e1000/igb_ethdev.c b/lib/librte_pmd_e1000/igb_ethdev.c
index 184e7d6..673b4de 100644
--- a/lib/librte_pmd_e1000/igb_ethdev.c
+++ b/lib/librte_pmd_e1000/igb_ethdev.c
@@ -320,6 +320,61 @@ igb_identify_hardware(struct rte_eth_dev *dev)
 }
 
 static int
+igb_reset_swfw_lock(struct e1000_hw *hw)
+{
+	int ret_val;
+
+	/*
+	 * Do mac ops initialization manually here, since we will need
+	 * some function pointers set by this call.
+	 */
+	ret_val = e1000_init_mac_params(hw);
+	if (ret_val)
+		return ret_val;
+
+	/*
+	 * SMBI 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_get_hw_semaphore_generic(hw) < 0) {
+		DEBUGOUT("SMBI lock released");
+	}
+	e1000_put_hw_semaphore_generic(hw);
+
+	if (hw->mac.ops.acquire_swfw_sync != NULL) {
+		uint16_t mask;
+
+		/*
+		 * 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.
+		 */
+		mask = E1000_SWFW_PHY0_SM << hw->bus.func;
+		if (hw->bus.func > E1000_FUNC_1)
+			mask <<= 2;
+		if (hw->mac.ops.acquire_swfw_sync(hw, mask) < 0) {
+			DEBUGOUT1("SWFW phy%d lock released", hw->bus.func);
+		}
+		hw->mac.ops.release_swfw_sync(hw, mask);
+
+		/*
+		 * 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.
+		 */
+		mask = E1000_SWFW_EEP_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;
+}
+
+static int
 eth_igb_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
 		   struct rte_eth_dev *eth_dev)
 {
@@ -348,13 +403,25 @@ eth_igb_dev_init(__attribute__((unused)) struct eth_driver *eth_drv,
 	hw->hw_addr= (void *)pci_dev->mem_resource[0].addr;
 
 	igb_identify_hardware(eth_dev);
-	if (e1000_setup_init_funcs(hw, TRUE) != E1000_SUCCESS) {
+	if (e1000_setup_init_funcs(hw, FALSE) != E1000_SUCCESS) {
 		error = -EIO;
 		goto err_late;
 	}
 
 	e1000_get_bus_info(hw);
 
+	/* Reset any pending lock */
+	if (igb_reset_swfw_lock(hw) != E1000_SUCCESS) {
+		error = -EIO;
+		goto err_late;
+	}
+
+	/* Finish initialization */
+	if (e1000_setup_init_funcs(hw, TRUE) != E1000_SUCCESS) {
+		error = -EIO;
+		goto err_late;
+	}
+
 	hw->mac.autoneg = 1;
 	hw->phy.autoneg_wait_to_complete = 0;
 	hw->phy.autoneg_advertised = E1000_ALL_SPEED_DUPLEX;
-- 
1.7.10.4

  reply	other threads:[~2014-04-08 13:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-19 11:59 [dpdk-dev] [RFC PATCH 1/2] e1000: " Didier Pallard
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                   ` Didier Pallard [this message]
2014-04-09 15:58                     ` [dpdk-dev] [PATCH v3 2/2] igb: " 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=1396963798-13123-2-git-send-email-didier.pallard@6wind.com \
    --to=didier.pallard@6wind.com \
    --cc=dev@dpdk.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 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).