Module Name: src
Committed By: knakahara
Date: Tue Mar 20 09:46:25 UTC 2018
Modified Files:
src/sys/dev/pci/ixgbe: ixgbe.c
Log Message:
Fix race about writing adapter->link_active for ixg(4).
adapter->link_active is updated by ixgbe_update_link_status() only.
The function is called from the following four functions.
- ixgbe_media_status()
- ixgbe_local_timer1()
- ixgbe_stop()
- ixgbe_handle_link()
The functions other than ixgbe_handle_link() call ixgbe_update_link_status()
with holding IXGBE_CORE_LOCK, however ixgbe_handle_link() calls it without
holding IXGBE_CORE_LOCK. That can cause race. So, add IXGBE_CORE_LOCK to
ixgbe_handle_link().
Tested by [email protected] and me.
To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/dev/pci/ixgbe/ixgbe.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.135 src/sys/dev/pci/ixgbe/ixgbe.c:1.136
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.135 Thu Mar 15 06:48:51 2018
+++ src/sys/dev/pci/ixgbe/ixgbe.c Tue Mar 20 09:46:25 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.135 2018/03/15 06:48:51 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.136 2018/03/20 09:46:25 knakahara Exp $ */
/******************************************************************************
@@ -4486,6 +4486,8 @@ ixgbe_update_link_status(struct adapter
device_t dev = adapter->dev;
struct ixgbe_hw *hw = &adapter->hw;
+ KASSERT(mutex_owned(&adapter->core_mtx));
+
if (adapter->link_up) {
if (adapter->link_active == FALSE) {
if (adapter->link_speed == IXGBE_LINK_SPEED_10GB_FULL){
@@ -6338,11 +6340,15 @@ ixgbe_handle_link(void *context)
struct adapter *adapter = context;
struct ixgbe_hw *hw = &adapter->hw;
+ IXGBE_CORE_LOCK(adapter);
+
ixgbe_check_link(hw, &adapter->link_speed, &adapter->link_up, 0);
ixgbe_update_link_status(adapter);
/* Re-enable link interrupts */
IXGBE_WRITE_REG(hw, IXGBE_EIMS, IXGBE_EIMS_LSC);
+
+ IXGBE_CORE_UNLOCK(adapter);
} /* ixgbe_handle_link */
/************************************************************************