Message ID | 20210812171856.1867667-1-anthony.l.nguyen@intel.com |
---|---|
State | New |
Headers | show |
Series | [net,1/1] ixgbe: Add locking to prevent panic when setting sriov_numvfs to zero | expand |
On Thu, 12 Aug 2021 10:18:56 -0700 Tony Nguyen wrote: > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > index 214a38de3f41..0a1a8756f1fd 100644 > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > @@ -206,8 +206,12 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter) > unsigned int num_vfs = adapter->num_vfs, vf; > int rss; > > + while (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter->state)) > + usleep_range(1000, 2000); > + > /* set num VFs to 0 to prevent access to vfinfo */ > adapter->num_vfs = 0; > + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); > > /* put the reference to all of the vf devices */ > for (vf = 0; vf < num_vfs; ++vf) { > @@ -1307,6 +1311,9 @@ void ixgbe_msg_task(struct ixgbe_adapter *adapter) > struct ixgbe_hw *hw = &adapter->hw; > u32 vf; > > + if (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter->state)) > + return; > + > for (vf = 0; vf < adapter->num_vfs; vf++) { > /* process any reset requests */ > if (!ixgbe_check_for_rst(hw, vf)) > @@ -1320,6 +1327,7 @@ void ixgbe_msg_task(struct ixgbe_adapter *adapter) > if (!ixgbe_check_for_ack(hw, vf)) > ixgbe_rcv_ack_from_vf(adapter, vf); > } > + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); Like I've already said two or three times. No flag based locking.
On Fri, 2021-08-13 at 17:20 -0700, Jakub Kicinski wrote: > On Thu, 12 Aug 2021 10:18:56 -0700 Tony Nguyen wrote: > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > > b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > > index 214a38de3f41..0a1a8756f1fd 100644 > > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c > > @@ -206,8 +206,12 @@ int ixgbe_disable_sriov(struct ixgbe_adapter > > *adapter) > > unsigned int num_vfs = adapter->num_vfs, vf; > > int rss; > > > > + while (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter- > > >state)) > > + usleep_range(1000, 2000); > > + > > /* set num VFs to 0 to prevent access to vfinfo */ > > adapter->num_vfs = 0; > > + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); > > > > /* put the reference to all of the vf devices */ > > for (vf = 0; vf < num_vfs; ++vf) { > > @@ -1307,6 +1311,9 @@ void ixgbe_msg_task(struct ixgbe_adapter > > *adapter) > > struct ixgbe_hw *hw = &adapter->hw; > > u32 vf; > > > > + if (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter->state)) > > + return; > > + > > for (vf = 0; vf < adapter->num_vfs; vf++) { > > /* process any reset requests */ > > if (!ixgbe_check_for_rst(hw, vf)) > > @@ -1320,6 +1327,7 @@ void ixgbe_msg_task(struct ixgbe_adapter > > *adapter) > > if (!ixgbe_check_for_ack(hw, vf)) > > ixgbe_rcv_ack_from_vf(adapter, vf); > > } > > + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); > > Like I've already said two or three times. No flag based locking. Ken, Did you want to make this change or did you want Intel to do it? Thanks, Tony
On 8/16/21 12:52 PM, Nguyen, Anthony L wrote: > On Fri, 2021-08-13 at 17:20 -0700, Jakub Kicinski wrote: >> On Thu, 12 Aug 2021 10:18:56 -0700 Tony Nguyen wrote: >>> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c >>> b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c >>> index 214a38de3f41..0a1a8756f1fd 100644 >>> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c >>> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c >>> @@ -206,8 +206,12 @@ int ixgbe_disable_sriov(struct ixgbe_adapter >>> *adapter) >>> unsigned int num_vfs = adapter->num_vfs, vf; >>> int rss; >>> >>> + while (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter- >>>> state)) >>> + usleep_range(1000, 2000); >>> + >>> /* set num VFs to 0 to prevent access to vfinfo */ >>> adapter->num_vfs = 0; >>> + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); >>> >>> /* put the reference to all of the vf devices */ >>> for (vf = 0; vf < num_vfs; ++vf) { >>> @@ -1307,6 +1311,9 @@ void ixgbe_msg_task(struct ixgbe_adapter >>> *adapter) >>> struct ixgbe_hw *hw = &adapter->hw; >>> u32 vf; >>> >>> + if (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter->state)) >>> + return; >>> + >>> for (vf = 0; vf < adapter->num_vfs; vf++) { >>> /* process any reset requests */ >>> if (!ixgbe_check_for_rst(hw, vf)) >>> @@ -1320,6 +1327,7 @@ void ixgbe_msg_task(struct ixgbe_adapter >>> *adapter) >>> if (!ixgbe_check_for_ack(hw, vf)) >>> ixgbe_rcv_ack_from_vf(adapter, vf); >>> } >>> + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); >> >> Like I've already said two or three times. No flag based locking. > > Ken, > > Did you want to make this change or did you want Intel to do it? Hi Tony, It would be great if Intel could make the change for the locking. Thanks, Ken
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index a604552fa634..696bb2a61ea7 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -807,6 +807,7 @@ enum ixgbe_state_t { __IXGBE_PTP_RUNNING, __IXGBE_PTP_TX_IN_PROGRESS, __IXGBE_RESET_REQUESTED, + __IXGBE_DISABLING_VFS, }; struct ixgbe_cb { diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c index 214a38de3f41..0a1a8756f1fd 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -206,8 +206,12 @@ int ixgbe_disable_sriov(struct ixgbe_adapter *adapter) unsigned int num_vfs = adapter->num_vfs, vf; int rss; + while (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter->state)) + usleep_range(1000, 2000); + /* set num VFs to 0 to prevent access to vfinfo */ adapter->num_vfs = 0; + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); /* put the reference to all of the vf devices */ for (vf = 0; vf < num_vfs; ++vf) { @@ -1307,6 +1311,9 @@ void ixgbe_msg_task(struct ixgbe_adapter *adapter) struct ixgbe_hw *hw = &adapter->hw; u32 vf; + if (test_and_set_bit(__IXGBE_DISABLING_VFS, &adapter->state)) + return; + for (vf = 0; vf < adapter->num_vfs; vf++) { /* process any reset requests */ if (!ixgbe_check_for_rst(hw, vf)) @@ -1320,6 +1327,7 @@ void ixgbe_msg_task(struct ixgbe_adapter *adapter) if (!ixgbe_check_for_ack(hw, vf)) ixgbe_rcv_ack_from_vf(adapter, vf); } + clear_bit(__IXGBE_DISABLING_VFS, &adapter->state); } void ixgbe_disable_tx_rx(struct ixgbe_adapter *adapter)