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 - Remove extra callout_stop() in ixgbe_det...



details:   https://anonhg.NetBSD.org/src/rev/8adfe260a0f8
branches:  trunk
changeset: 938381:8adfe260a0f8
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Sep 07 05:50:58 2020 +0000

description:
- Remove extra callout_stop() in ixgbe_detach(). Found by knakahara@.
- Rename ix{gbe,v}_free_workqueue() to ix{gbe,v}_free_deferred_handlers().
- Add KASSERT() to functions who are called from ixgbe_handle_admin().

diffstat:

 sys/dev/pci/ixgbe/if_fdir.c  |   2 ++
 sys/dev/pci/ixgbe/if_sriov.c |   2 ++
 sys/dev/pci/ixgbe/ixgbe.c    |  26 ++++++++++++++++----------
 sys/dev/pci/ixgbe/ixv.c      |  12 ++++++------
 4 files changed, 26 insertions(+), 16 deletions(-)

diffs (189 lines):

diff -r 953767930951 -r 8adfe260a0f8 sys/dev/pci/ixgbe/if_fdir.c
--- a/sys/dev/pci/ixgbe/if_fdir.c       Mon Sep 07 05:32:12 2020 +0000
+++ b/sys/dev/pci/ixgbe/if_fdir.c       Mon Sep 07 05:50:58 2020 +0000
@@ -55,6 +55,8 @@
        struct adapter *adapter = context;
        struct ifnet   *ifp = adapter->ifp;
 
+       KASSERT(mutex_owned(&adapter->core_mtx));
+
        if (!(adapter->feat_en & IXGBE_FEATURE_FDIR))
                return;
        if (adapter->fdir_reinit != 1) /* Shouldn't happen */
diff -r 953767930951 -r 8adfe260a0f8 sys/dev/pci/ixgbe/if_sriov.c
--- a/sys/dev/pci/ixgbe/if_sriov.c      Mon Sep 07 05:32:12 2020 +0000
+++ b/sys/dev/pci/ixgbe/if_sriov.c      Mon Sep 07 05:50:58 2020 +0000
@@ -643,6 +643,8 @@
        struct ixgbe_vf *vf;
        int i;
 
+       KASSERT(mutex_owned(&adapter->core_mtx));
+
        hw = &adapter->hw;
 
        for (i = 0; i < adapter->num_vfs; i++) {
diff -r 953767930951 -r 8adfe260a0f8 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Mon Sep 07 05:32:12 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Mon Sep 07 05:50:58 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.256 2020/09/07 04:15:12 msaitoh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.257 2020/09/07 05:50:58 msaitoh Exp $ */
 
 /******************************************************************************
 
@@ -181,7 +181,7 @@
 static int     ixgbe_media_change(struct ifnet *);
 static int     ixgbe_allocate_pci_resources(struct adapter *,
                    const struct pci_attach_args *);
-static void    ixgbe_free_workqueue(struct adapter *);
+static void    ixgbe_free_deferred_handlers(struct adapter *);
 static void    ixgbe_get_slot_info(struct adapter *);
 static int     ixgbe_allocate_msix(struct adapter *,
                    const struct pci_attach_args *);
@@ -1279,7 +1279,7 @@
        ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
        ctrl_ext &= ~IXGBE_CTRL_EXT_DRV_LOAD;
        IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, ctrl_ext);
-       ixgbe_free_workqueue(adapter);
+       ixgbe_free_deferred_handlers(adapter);
        ixgbe_free_pci_resources(adapter);
        if (adapter->mta != NULL)
                free(adapter->mta, M_DEVBUF);
@@ -3518,7 +3518,7 @@
 } /* ixgbe_allocate_pci_resources */
 
 static void
-ixgbe_free_workqueue(struct adapter *adapter)
+ixgbe_free_deferred_handlers(struct adapter *adapter)
 {
        struct ix_queue *que = adapter->queues;
        struct tx_ring *txr = adapter->tx_rings;
@@ -3558,7 +3558,7 @@
                workqueue_destroy(adapter->recovery_mode_timer_wq);
                adapter->recovery_mode_timer_wq = NULL;
        }
-} /* ixgbe_free_workqueue */
+} /* ixgbe_free_deferred_handlers */
 
 /************************************************************************
  * ixgbe_detach - Device removal routine
@@ -3610,10 +3610,8 @@
        ixgbe_setup_low_power_mode(adapter);
 
        callout_halt(&adapter->timer, NULL);
-       if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE) {
-               callout_stop(&adapter->recovery_mode_timer);
+       if (adapter->feat_en & IXGBE_FEATURE_RECOVERY_MODE)
                callout_halt(&adapter->recovery_mode_timer, NULL);
-       }
 
        workqueue_wait(adapter->admin_wq, &adapter->admin_wc);
        atomic_store_relaxed(&adapter->admin_pending, 0);
@@ -3624,7 +3622,7 @@
 
        ether_ifdetach(adapter->ifp);
 
-       ixgbe_free_workqueue(adapter);
+       ixgbe_free_deferred_handlers(adapter);
 
        /* let hardware know driver is unloading */
        ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT);
@@ -4673,6 +4671,8 @@
        u32             err;
        bool            last_unsupported_sfp_recovery;
 
+       KASSERT(mutex_owned(&adapter->core_mtx));
+
        last_sfp_type = hw->phy.sfp_type;
        last_unsupported_sfp_recovery = hw->need_unsupported_sfp_recovery;
        ++adapter->mod_workev.ev_count;
@@ -4754,6 +4754,8 @@
        u32             autoneg;
        bool            negotiate;
 
+       KASSERT(mutex_owned(&adapter->core_mtx));
+
        ++adapter->msf_workev.ev_count;
 
        autoneg = hw->phy.autoneg_advertised;
@@ -4773,6 +4775,8 @@
        struct ixgbe_hw *hw = &adapter->hw;
        int error;
 
+       KASSERT(mutex_owned(&adapter->core_mtx));
+
        ++adapter->phy_workev.ev_count;
        error = hw->phy.ops.handle_lasi(hw);
        if (error == IXGBE_ERR_OVERTEMP)
@@ -6884,7 +6888,7 @@
 
 err_out:
        kcpuset_destroy(affinity);
-       ixgbe_free_workqueue(adapter);
+       ixgbe_free_deferred_handlers(adapter);
        ixgbe_free_pciintr_resources(adapter);
        return (error);
 } /* ixgbe_allocate_msix */
@@ -7008,6 +7012,8 @@
        struct adapter  *adapter = context;
        struct ixgbe_hw *hw = &adapter->hw;
 
+       KASSERT(mutex_owned(&adapter->core_mtx));
+
        ++adapter->link_workev.ev_count;
        ixgbe_check_link(hw, &adapter->link_speed, &adapter->link_up, 0);
        ixgbe_update_link_status(adapter);
diff -r 953767930951 -r 8adfe260a0f8 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Mon Sep 07 05:32:12 2020 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Mon Sep 07 05:50:58 2020 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.153 2020/08/31 14:12:50 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.154 2020/09/07 05:50:58 msaitoh Exp $*/
 
 /******************************************************************************
 
@@ -96,7 +96,7 @@
 static int     ixv_media_change(struct ifnet *);
 static int     ixv_allocate_pci_resources(struct adapter *,
                    const struct pci_attach_args *);
-static void    ixv_free_workqueue(struct adapter *);
+static void    ixv_free_deferred_handlers(struct adapter *);
 static int     ixv_allocate_msix(struct adapter *,
                    const struct pci_attach_args *);
 static int     ixv_configure_interrupts(struct adapter *);
@@ -608,7 +608,7 @@
 
        ether_ifdetach(adapter->ifp);
        callout_halt(&adapter->timer, NULL);
-       ixv_free_workqueue(adapter);
+       ixv_free_deferred_handlers(adapter);
 
        if (adapter->feat_en & IXGBE_FEATURE_NETMAP)
                netmap_detach(adapter->ifp);
@@ -1530,7 +1530,7 @@
 } /* ixv_allocate_pci_resources */
 
 static void
-ixv_free_workqueue(struct adapter *adapter)
+ixv_free_deferred_handlers(struct adapter *adapter)
 {
        struct ix_queue *que = adapter->queues;
        struct tx_ring *txr = adapter->tx_rings;
@@ -1560,7 +1560,7 @@
                workqueue_destroy(adapter->timer_wq);
                adapter->timer_wq = NULL;
        }
-} /* ixv_free_workqueue */
+} /* ixv_free_deferred_handlers */
 
 /************************************************************************
  * ixv_free_pci_resources
@@ -3413,7 +3413,7 @@
        return (0);
 err_out:
        kcpuset_destroy(affinity);
-       ixv_free_workqueue(adapter);
+       ixv_free_deferred_handlers(adapter);
        ixv_free_pci_resources(adapter);
        return (error);
 } /* ixv_allocate_msix */



Home | Main Index | Thread Index | Old Index