Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci/ixgbe Fix race about writing adapter->link_activ...
details: https://anonhg.NetBSD.org/src/rev/f8ce5aeaa864
branches: trunk
changeset: 321519:f8ce5aeaa864
user: knakahara <knakahara%NetBSD.org@localhost>
date: Tue Mar 20 09:46:25 2018 +0000
description:
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 msaitoh@n.o and me.
diffstat:
sys/dev/pci/ixgbe/ixgbe.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diffs (34 lines):
diff -r 901bdb7cc985 -r f8ce5aeaa864 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Mon Mar 19 17:29:08 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Tue Mar 20 09:46:25 2018 +0000
@@ -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 @@
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 @@
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 */
/************************************************************************
Home |
Main Index |
Thread Index |
Old Index