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/cd7c15d78bcc
branches:  trunk
changeset: 321520:cd7c15d78bcc
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Tue Mar 20 09:50:33 2018 +0000

description:
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 msaitoh@n.o.

diffstat:

 sys/dev/pci/ixgbe/ixv.c |  11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diffs (42 lines):

diff -r f8ce5aeaa864 -r cd7c15d78bcc sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Tue Mar 20 09:46:25 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Tue Mar 20 09:50:33 2018 +0000
@@ -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 @@
        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 @@
 {
        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 @@
 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,



Home | Main Index | Thread Index | Old Index