From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by dpdk.org (Postfix) with ESMTP id B004468B5 for ; Tue, 8 Apr 2014 15:28:36 +0200 (CEST) Received: by mail-wg0-f45.google.com with SMTP id l18so940104wgh.28 for ; Tue, 08 Apr 2014 06:30:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=EyGGC/Kq32f4vRX6EFrwwlaFiMFe33wnoj2+1e6CTyI=; b=JruJ+f0Ju9FQAvr7qVE0nVxps0RLBbo8PVxW/Qeykq8Sr7O0GTdD3a6L+v2wGthbuO Pe3xDb+axuEvtPvExF/6tIPgrm2uOsrEVXhUrD31cnBdssXY6MwTPpbLKEnAtKwjwFuf 92jjMhLYjqSqOdFkKVXlOQMwvECekKn6SZZVzkzmGT687OfumHIhuqbh/ly7Lsv7/Bei KyOJFsEbdjxKJ1PAn3x10xrSGf6HieJw5yiatBYeRZol1KQHMtLIoww1EIz/Z6rddsBu DThRYmLFDIf9YoufA+LF/C6cz7LDjsYD1s/u2I0VuwKyBTUcu3A9Ew4OlxgAu+yJ7DAv wDEA== X-Gm-Message-State: ALoCoQl8Mcc/xz3P+y0uRoQCwNxN++s9UaugtJr9n1vy51P3Zgwkg+UyxKlYJ4JAeixYyxChUu2e X-Received: by 10.194.63.236 with SMTP id j12mr3888170wjs.5.1396963813164; Tue, 08 Apr 2014 06:30:13 -0700 (PDT) Received: from pala.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id gr2sm3286189wjc.12.2014.04.08.06.30.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Apr 2014 06:30:12 -0700 (PDT) From: Didier Pallard To: dev@dpdk.org Date: Tue, 8 Apr 2014 15:29:58 +0200 Message-Id: <1396963798-13123-2-git-send-email-didier.pallard@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1396963798-13123-1-git-send-email-didier.pallard@6wind.com> References: <530DC788.8020706@6wind.com> <1396963798-13123-1-git-send-email-didier.pallard@6wind.com> Subject: [dpdk-dev] [PATCH v3 2/2] igb: 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: Tue, 08 Apr 2014 13:28:37 -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. Signed-off-by: Didier Pallard --- 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