Module Name:    src
Committed By:   msaitoh
Date:           Mon Sep  7 05:50:58 UTC 2020

Modified Files:
        src/sys/dev/pci/ixgbe: if_fdir.c if_sriov.c ixgbe.c ixv.c

Log Message:
- 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().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/pci/ixgbe/if_fdir.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/ixgbe/if_sriov.c
cvs rdiff -u -r1.256 -r1.257 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.153 -r1.154 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/if_fdir.c
diff -u src/sys/dev/pci/ixgbe/if_fdir.c:1.2 src/sys/dev/pci/ixgbe/if_fdir.c:1.3
--- src/sys/dev/pci/ixgbe/if_fdir.c:1.2	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/if_fdir.c	Mon Sep  7 05:50:58 2020
@@ -55,6 +55,8 @@ ixgbe_reinit_fdir(void *context)
 	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 */

Index: src/sys/dev/pci/ixgbe/if_sriov.c
diff -u src/sys/dev/pci/ixgbe/if_sriov.c:1.7 src/sys/dev/pci/ixgbe/if_sriov.c:1.8
--- src/sys/dev/pci/ixgbe/if_sriov.c:1.7	Thu Jun 25 07:53:01 2020
+++ src/sys/dev/pci/ixgbe/if_sriov.c	Mon Sep  7 05:50:58 2020
@@ -643,6 +643,8 @@ ixgbe_handle_mbx(void *context, int pend
 	struct ixgbe_vf *vf;
 	int i;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
+
 	hw = &adapter->hw;
 
 	for (i = 0; i < adapter->num_vfs; i++) {

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.256 src/sys/dev/pci/ixgbe/ixgbe.c:1.257
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.256	Mon Sep  7 04:15:12 2020
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Mon Sep  7 05:50:58 2020
@@ -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 void	ixgbe_media_status(struct if
 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 @@ err_out:
 	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 @@ map_err:
 } /* 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 @@ ixgbe_free_workqueue(struct adapter *ada
 		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_detach(device_t dev, int flags)
 	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 @@ ixgbe_detach(device_t dev, int flags)
 
 	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 @@ ixgbe_handle_mod(void *context)
 	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 @@ ixgbe_handle_msf(void *context)
 	u32		autoneg;
 	bool		negotiate;
 
+	KASSERT(mutex_owned(&adapter->core_mtx));
+
 	++adapter->msf_workev.ev_count;
 
 	autoneg = hw->phy.autoneg_advertised;
@@ -4773,6 +4775,8 @@ ixgbe_handle_phy(void *context)
 	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 @@ ixgbe_allocate_msix(struct adapter *adap
 
 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 @@ ixgbe_handle_link(void *context)
 	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);

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.153 src/sys/dev/pci/ixgbe/ixv.c:1.154
--- src/sys/dev/pci/ixgbe/ixv.c:1.153	Mon Aug 31 14:12:50 2020
+++ src/sys/dev/pci/ixgbe/ixv.c	Mon Sep  7 05:50:58 2020
@@ -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 void	ixv_media_status(struct ifne
 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 @@ ixv_detach(device_t dev, int flags)
 
 	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 @@ map_err:
 } /* 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 @@ ixv_free_workqueue(struct adapter *adapt
 		workqueue_destroy(adapter->timer_wq);
 		adapter->timer_wq = NULL;
 	}
-} /* ixv_free_workqueue */
+} /* ixv_free_deferred_handlers */
 
 /************************************************************************
  * ixv_free_pci_resources
@@ -3413,7 +3413,7 @@ ixv_allocate_msix(struct adapter *adapte
 	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 */

Reply via email to