Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1194155ybn; Wed, 2 Oct 2019 12:14:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJ4iffqSYd+Y3wfa1kQhd5zw4eqwNgrcn1oMdWlPH5SS3+dTvfAnA9uyFVS2ky4n+i1I2X X-Received: by 2002:a17:906:7d0:: with SMTP id m16mr4548633ejc.95.1570043676711; Wed, 02 Oct 2019 12:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570043676; cv=none; d=google.com; s=arc-20160816; b=nmvXsi79USf9Ce7PqBKD/qa03myAWQbQFcLM7IxgI28AHI1TEkA4VuAz1qs2hGpk/S 9cT7TjYTZAqJccohILB8nWns+Hqxqt2Od3gWMvgi2X+5AgYM15Rl+93eWJOzUsIPGNU3 X14AkTA3B7tocHl04CvZVeikzn9XNDA/jzURE5/2gUA1xB9DT7eypxRfKIfEPb18vPnG i7SZ8vd4oApBexQmR6dItixHMViKqsax3meuU2+4oNW3rOaNUMcipT50YRllsF3gshKP 42CPitXrqdYGX7BE2KIzEnK7Kd89fHNNknunUIyuM6AX1/m/cG6/XNgEwGQZKzYJO2IO JIog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=L7JotXcCUDOH/IkZ1OZ6+qmRSWD8A4njm7r22YaR0r4=; b=g8hFArSt7kn076OOGWE6RCMlESSTtEhtTOeByMD7bNZB0YytMELe6PxjaXrClsm0q2 029OB+3JqOlTXxxWlKLyeA0ZibR3VgwX2mfbJZptZAWbRxiyu4x9/y/+Xw+wVHvVCXQv iessCSRCufTB7OPjZu3Zd66kGqXMnY6CI9XoWrwNFGzxy2UUAamvk10RL1Ap8ZiD9H5H CQh88Kk2fsQnPpCBYcYyIG0ydNb9GsdgkwQNz7f9SyLRv/R2NErA1B/tvr9UNlTo5JG8 S3IJsS8Gd/NQcK9ZIAdCHnKXwU/G8TRdQgsKzTI5Xz/4bnbgVTSRGOArDNMFreezH7rD ffIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si10848edr.382.2019.10.02.12.14.12; Wed, 02 Oct 2019 12:14:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729936AbfJBTKy (ORCPT + 99 others); Wed, 2 Oct 2019 15:10:54 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35778 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729298AbfJBTIP (ORCPT ); Wed, 2 Oct 2019 15:08:15 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iFjyu-00036H-L2; Wed, 02 Oct 2019 20:08:12 +0100 Received: from ben by deadeye with local (Exim 4.92.1) (envelope-from ) id 1iFjyp-0003ft-VY; Wed, 02 Oct 2019 20:08:07 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Ivan Vecera" , "Petr Oros" , "David S. Miller" Date: Wed, 02 Oct 2019 20:06:51 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 75/87] be2net: fix link failure after ethtool offline test In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.75-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Petr Oros commit 2e5db6eb3c23e5dc8171eb8f6af7a97ef9fcf3a9 upstream. Certain cards in conjunction with certain switches need a little more time for link setup that results in ethtool link test failure after offline test. Patch adds a loop that waits for a link setup finish. Changes in v2: - added fixes header Fixes: 4276e47e2d1c ("be2net: Add link test to list of ethtool self tests.") Signed-off-by: Petr Oros Reviewed-by: Ivan Vecera Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- .../net/ethernet/emulex/benet/be_ethtool.c | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) --- a/drivers/net/ethernet/emulex/benet/be_ethtool.c +++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c @@ -779,7 +779,7 @@ static void be_self_test(struct net_devi u64 *data) { struct be_adapter *adapter = netdev_priv(netdev); - int status; + int status, cnt; u8 link_status = 0; if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) { @@ -790,6 +790,9 @@ static void be_self_test(struct net_devi memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM); + /* check link status before offline tests */ + link_status = netif_carrier_ok(netdev); + if (test->flags & ETH_TEST_FL_OFFLINE) { if (be_loopback_test(adapter, BE_MAC_LOOPBACK, &data[0]) != 0) test->flags |= ETH_TEST_FL_FAILED; @@ -810,13 +813,26 @@ static void be_self_test(struct net_devi test->flags |= ETH_TEST_FL_FAILED; } - status = be_cmd_link_status_query(adapter, NULL, &link_status, 0); - if (status) { - test->flags |= ETH_TEST_FL_FAILED; - data[4] = -1; - } else if (!link_status) { + /* link status was down prior to test */ + if (!link_status) { test->flags |= ETH_TEST_FL_FAILED; data[4] = 1; + return; + } + + for (cnt = 10; cnt; cnt--) { + status = be_cmd_link_status_query(adapter, NULL, &link_status, + 0); + if (status) { + test->flags |= ETH_TEST_FL_FAILED; + data[4] = -1; + break; + } + + if (link_status) + break; + + msleep_interruptible(500); } }