summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/intel/e1000e/mac.c
diff options
context:
space:
mode:
authorBenjamin Poirier <bpoirier@suse.com>2018-03-06 04:55:53 +0300
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-03-12 22:05:39 +0300
commite2710dbf0dc1e37d85368e2404049dadda848d5a (patch)
treef1b121b8473f89e4c6abfa94fe6e443f165a47f5 /drivers/net/ethernet/intel/e1000e/mac.c
parent3016e0a0c91246e55418825ba9aae271be267522 (diff)
downloadlinux-e2710dbf0dc1e37d85368e2404049dadda848d5a.tar.xz
e1000e: Fix link check race condition
Alex reported the following race condition: /* link goes up... interrupt... schedule watchdog */ \ e1000_watchdog_task \ e1000e_has_link \ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link \ e1000e_phy_has_link_generic(..., &link) link = true /* link goes down... interrupt */ \ e1000_msix_other hw->mac.get_link_status = true /* link is up */ mac->get_link_status = false link_active = true /* link_active is true, wrongly, and stays so because * get_link_status is false */ Avoid this problem by making sure that we don't set get_link_status = false after having checked the link. It seems this problem has been present since the introduction of e1000e. Link: https://lkml.org/lkml/2018/1/29/338 Reported-by: Alexander Duyck <alexander.duyck@gmail.com> Signed-off-by: Benjamin Poirier <bpoirier@suse.com> Acked-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/e1000e/mac.c')
-rw-r--r--drivers/net/ethernet/intel/e1000e/mac.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
index b322011ec282..5bdc3a2d4fd7 100644
--- a/drivers/net/ethernet/intel/e1000e/mac.c
+++ b/drivers/net/ethernet/intel/e1000e/mac.c
@@ -424,19 +424,15 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
*/
if (!mac->get_link_status)
return 0;
+ mac->get_link_status = false;
/* First we want to see if the MII Status Register reports
* link. If so, then we want to get the current speed/duplex
* of the PHY.
*/
ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link);
- if (ret_val)
- return ret_val;
-
- if (!link)
- return 0; /* No link detected */
-
- mac->get_link_status = false;
+ if (ret_val || !link)
+ goto out;
/* Check if there was DownShift, must be checked
* immediately after link-up
@@ -465,6 +461,10 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
e_dbg("Error configuring flow control\n");
return ret_val;
+
+out:
+ mac->get_link_status = true;
+ return ret_val;
}
/**