Module Name: src
Committed By: knakahara
Date: Tue Mar 20 09:50:33 UTC 2018
Modified Files:
src/sys/dev/pci/ixgbe: ixv.c
Log Message:
Fix race about writing adapter->link_active for ixv(4).
adapter->link_active is updated by ixv_update_link_status() only.
The function is called from the following two functions.
- ixv_media_status()
- ixv_handle_link()
ixv_media_status() calls ixv_update_link_status() with holding
IXGBE_CORE_LOCK, however ixv_handle_link() calls it without
holding IXGBE_CORE_LOCK, the same as ixg(4).
ok by [email protected].
To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/pci/ixgbe/ixv.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/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.88 src/sys/dev/pci/ixgbe/ixv.c:1.89
--- src/sys/dev/pci/ixgbe/ixv.c:1.88 Thu Mar 15 06:48:51 2018
+++ src/sys/dev/pci/ixgbe/ixv.c Tue Mar 20 09:50:33 2018
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.88 2018/03/15 06:48:51 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.89 2018/03/20 09:50:33 knakahara Exp $*/
/******************************************************************************
@@ -1293,6 +1293,8 @@ ixv_update_link_status(struct adapter *a
struct ifnet *ifp = adapter->ifp;
device_t dev = adapter->dev;
+ KASSERT(mutex_owned(&adapter->core_mtx));
+
if (adapter->link_up) {
if (adapter->link_active == FALSE) {
if (bootverbose) {
@@ -3080,9 +3082,13 @@ ixv_handle_link(void *context)
{
struct adapter *adapter = context;
+ IXGBE_CORE_LOCK(adapter);
+
adapter->hw.mac.ops.check_link(&adapter->hw, &adapter->link_speed,
&adapter->link_up, FALSE);
ixv_update_link_status(adapter);
+
+ IXGBE_CORE_UNLOCK(adapter);
} /* ixv_handle_link */
/************************************************************************
@@ -3091,6 +3097,9 @@ ixv_handle_link(void *context)
static void
ixv_check_link(struct adapter *adapter)
{
+
+ KASSERT(mutex_owned(&adapter->core_mtx));
+
adapter->hw.mac.get_link_status = TRUE;
adapter->hw.mac.ops.check_link(&adapter->hw, &adapter->link_speed,