Skip to content

Commit 21c6e36

Browse files
jbrandebanguy11
authored andcommitted
ice: tighter control over VSI_DOWN state
The driver had comments to the effect of: This flag should be set before calling this function. While reviewing code it was found that there were several violations of this policy, which could introduce hard to find bugs or races. Fix the violations of the "VSI DOWN state must be set before calling ice_down" and make checking the state into code with a WARN_ON. Signed-off-by: Jesse Brandeburg <[email protected]> Tested-by: Gurucharan G <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent cc14db1 commit 21c6e36

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,8 +1280,10 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
12801280
}
12811281
if (test_bit(ICE_FLAG_LEGACY_RX, change_flags)) {
12821282
/* down and up VSI so that changes of Rx cfg are reflected. */
1283-
ice_down(vsi);
1284-
ice_up(vsi);
1283+
if (!test_and_set_bit(ICE_VSI_DOWN, vsi->state)) {
1284+
ice_down(vsi);
1285+
ice_up(vsi);
1286+
}
12851287
}
12861288
/* don't allow modification of this flag when a single VF is in
12871289
* promiscuous mode because it's not supported

drivers/net/ethernet/intel/ice/ice_main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6229,14 +6229,15 @@ static void ice_napi_disable_all(struct ice_vsi *vsi)
62296229
/**
62306230
* ice_down - Shutdown the connection
62316231
* @vsi: The VSI being stopped
6232+
*
6233+
* Caller of this function is expected to set the vsi->state ICE_DOWN bit
62326234
*/
62336235
int ice_down(struct ice_vsi *vsi)
62346236
{
62356237
int i, tx_err, rx_err, link_err = 0;
62366238

6237-
/* Caller of this function is expected to set the
6238-
* vsi->state ICE_DOWN bit
6239-
*/
6239+
WARN_ON(!test_bit(ICE_VSI_DOWN, vsi->state));
6240+
62406241
if (vsi->netdev && vsi->type == ICE_VSI_PF) {
62416242
netif_carrier_off(vsi->netdev);
62426243
netif_tx_disable(vsi->netdev);

0 commit comments

Comments
 (0)