Received: by 10.223.185.116 with SMTP id b49csp6355822wrg; Wed, 28 Feb 2018 08:05:31 -0800 (PST) X-Google-Smtp-Source: AG47ELsVU6iLDFHYEDgpOnozSdFv3EUA3b1EwaWx1ljvEVs4ZBGevz025/vm4GqzN+XZXjCYEZIn X-Received: by 2002:a17:902:5a44:: with SMTP id f4-v6mr8828148plm.116.1519833930959; Wed, 28 Feb 2018 08:05:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519833930; cv=none; d=google.com; s=arc-20160816; b=latd/KQfLY+cUW8gC9qDE/6YRGmCNsLuJW6l/+C4DbhmKVvWTGkTcyWaz3iC3I4pjy PTEkqCFB9mi0GHAtFIFy/DTgHp32KZSA4ZZFAxcPwsMafrHNfjy4fSO1k07l2C2HqHu2 BCzaY55JlxqJGRpGAQ5p/LjhKqV3Cnxcesm8QUi3AUNRuRAKGwGnXxxiuV9LizBNbWMf mOXoPDQhIvJ1QjHbiQaxD5tOluO8XiXXY7JXzVSq02yeDfItgMK/vKN1vNnBgJbF5mJi OKvPVlUG/NnZEXLkciRSrLo2rHkdyC2Ca0QcEt5fDmd6DeFwLcD5Q5Dqq+ENH1AWSAIL cZWw== 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 :arc-authentication-results; bh=PKncXbW4oPyAet2hhcX5kc4Qfm0M3TLsXRITWj8ZbAU=; b=KMkO2bEDNxDHYs2kRFl+Zqv0Mp+p3PgGDalQHZi1/YvQxccKVb9QHbcgg4XpZcWAII 9Y2lrJpTCD2G3GPW1KSV0INfKhXt6cVzF20/QgtiJiMesFXDpPu3dv8E/IUXdxuA1zv/ dwbPlfZLSjRf5pJ5yjGDszQKOdXTB+Y+3J/oSdZcY/fTLAYAwqBlW4xs1XMsOaipfqAD A5EM6fuYgWFq+ugGSoy8R9JGC/zzFrdRo1H/L5I30UB6hM/1tYKrb9eulybiomz3zOLS SeB+MjIL/fMUgxSi03FB7g8oXD4Q7MyFV7TB9c809Y4d/4HIIJZ1Q2UdkmbTGUqyUr/q Sj6w== 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 d23-v6si1476350pli.384.2018.02.28.08.05.10; Wed, 28 Feb 2018 08:05:30 -0800 (PST) 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 S933877AbeB1QDl (ORCPT + 99 others); Wed, 28 Feb 2018 11:03:41 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34782 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933258AbeB1QDj (ORCPT ); Wed, 28 Feb 2018 11:03:39 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yr-0006XR-93; Wed, 28 Feb 2018 15:22:29 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yi-0000Aw-7J; Wed, 28 Feb 2018 15:22:20 +0000 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, "Lennart Sorensen" , "Jeff Kirsher" , "Aaron Brown" , "Benjamin Poirier" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 157/254] e1000e: Separate signaling for link check/link up In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 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.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Benjamin Poirier commit 19110cfbb34d4af0cdfe14cd243f3b09dc95b013 upstream. Lennart reported the following race condition: \ e1000_watchdog_task \ e1000e_has_link \ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link /* link is up */ mac->get_link_status = false; /* interrupt */ \ e1000_msix_other hw->mac.get_link_status = true; link_active = !hw->mac.get_link_status /* link_active is false, wrongly */ This problem arises because the single flag get_link_status is used to signal two different states: link status needs checking and link status is down. Avoid the problem by using the return value of .check_for_link to signal the link status to e1000e_has_link(). Reported-by: Lennart Sorensen Signed-off-by: Benjamin Poirier Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher Signed-off-by: Ben Hutchings --- drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++++++--- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -410,6 +410,9 @@ void e1000e_clear_hw_cntrs_base(struct e * Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. + * + * Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link + * up). **/ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) { @@ -423,7 +426,7 @@ s32 e1000e_check_for_copper_link(struct * Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) - return 0; + return 1; /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex @@ -461,10 +464,12 @@ s32 e1000e_check_for_copper_link(struct * different link partner. */ ret_val = e1000e_config_fc_after_link_up(hw); - if (ret_val) + if (ret_val) { e_dbg("Error configuring flow control\n"); + return ret_val; + } - return ret_val; + return 1; } /** --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -4844,7 +4844,7 @@ static bool e1000e_has_link(struct e1000 case e1000_media_type_copper: if (hw->mac.get_link_status) { ret_val = hw->mac.ops.check_for_link(hw); - link_active = !hw->mac.get_link_status; + link_active = ret_val > 0; } else { link_active = true; }