From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by dpdk.org (Postfix) with ESMTP id EBEAA5913 for ; Wed, 19 Feb 2014 13:10:49 +0100 (CET) Received: by mail-wi0-f170.google.com with SMTP id hi5so4450107wib.5 for ; Wed, 19 Feb 2014 04:12:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:resent-from:resent-to:resent-date :resent-message-id:delivered-to:from:to:subject:date:message-id; bh=J9T9pZq5KiTiAjVprMpu5IrstBtyumyZZnli66uY9Es=; b=ImvXAR3AgQqSmXH8hPAY/EfcdPQHhJewqDUhqcGxncY0VAn2NQrZkKWDkdBt3MqJY2 rw3/pA8ANzW5GvMCvkTk1wVOf3AhjU6eJ3asjW7YGzXKUxiKb374ExfTXGID5OCUDyyJ +llE8NMRsxQyvS6UFijFfsyG5x5weZOLD497Shj4zTWjOAUi8A26hCPwd33QRNY/LJLz Vxz2etzMSoerogwHmPJMyP6YgNwy+eGGIghfNe2pKVdFhSieJIFIBvhIkdgeFD7qRGY+ cyNhk/uPuc53LOcjtKzE7Hg2Xofl5/aegQa0FPSQH5a6KZM7MMlOLyo7oXrrxeXUbFSt lz9A== X-Gm-Message-State: ALoCoQlOoSmiZPD1+giddF5NvlBluqB23uAukT2dmeoyauOB45hk2Cl48uWgjCjunKzQs+jhIAsm X-Received: by 10.194.142.204 with SMTP id ry12mr617015wjb.93.1392811934303; Wed, 19 Feb 2014 04:12:14 -0800 (PST) Received: from angus.localnet (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id xt1sm2460wjb.17.2014.02.19.04.12.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2014 04:12:13 -0800 (PST) Resent-From: Thomas Monjalon Resent-To: dev@dpdk.org Resent-Date: Wed, 19 Feb 2014 13:12:11 +0100 Resent-Message-ID: <201402191312.11073.didier.pallard@6wind.com> Received: by 10.76.82.162 with SMTP id j2csp6764oay; Wed, 19 Feb 2014 03:59:32 -0800 (PST) X-Received: by 10.180.12.14 with SMTP id u14mr1187080wib.0.1392811172240; Wed, 19 Feb 2014 03:59:32 -0800 (PST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by mx.google.com with ESMTPS id gm5si17800832wjc.6.2014.02.19.03.59.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Feb 2014 03:59:32 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.43 is neither permitted nor denied by best guess record for domain of didier.pallard@6wind.com) client-ip=74.125.82.43; Received: by mail-wg0-f43.google.com with SMTP id a1so241991wgh.10 for ; Wed, 19 Feb 2014 03:59:31 -0800 (PST) X-Received: by 10.180.19.130 with SMTP id f2mr1151948wie.6.1392811171641; Wed, 19 Feb 2014 03:59:31 -0800 (PST) Received: from pala.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id fm3sm51219809wib.8.2014.02.19.03.59.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2014 03:59:30 -0800 (PST) From: Didier Pallard To: thomas.monjalon@6wind.com Date: Wed, 19 Feb 2014 12:59:21 +0100 Message-Id: <1392811162-28527-1-git-send-email-didier.pallard@6wind.com> X-Mailer: git-send-email 1.7.10.4 X-Length: 8727 X-UID: 25248 Subject: [dpdk-dev] [RFC PATCH 1/2] e1000: release software locked semaphores on initialization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Feb 2014 12:10:50 -0000 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 --- 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