Message ID | 20220225202101.4077712-1-jacob.e.keller@intel.com |
---|---|
State | Superseded |
Headers | show |
Series | [1/2] ice: Fix race conditions between virtchnl handling and VF ndo ops | expand |
> -----Original Message----- > From: Greg KH <gregkh@linuxfoundation.org> > Sent: Monday, February 28, 2022 3:10 AM > To: Keller, Jacob E <jacob.e.keller@intel.com> > Cc: stable@vger.kernel.org; Brett Creeley <brett.creeley@intel.com>; Jankowski, > Konrad0 <konrad0.jankowski@intel.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com> > Subject: Re: [PATCH 1/2] ice: Fix race conditions between virtchnl handling and VF > ndo ops > > On Fri, Feb 25, 2022 at 12:21:00PM -0800, Jacob Keller wrote: > > From: Brett Creeley <brett.creeley@intel.com> > > > > commit e6ba5273d4ede03d075d7a116b8edad1f6115f4d upstream. > > > > [I had to fix the cherry-pick manually as the patch added a line around > > some context that was missing.] > > What stable tree(s) is this for? > Ah, yea this only applied to 5.15 > Thanks, > > greg k-h
> -----Original Message----- > From: Greg KH <gregkh@linuxfoundation.org> > Sent: Saturday, March 05, 2022 5:43 AM > To: Keller, Jacob E <jacob.e.keller@intel.com> > Cc: stable@vger.kernel.org; Jankowski, Konrad0 > <konrad0.jankowski@intel.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com> > Subject: Re: [PATCH 1/2] ice: Fix race conditions between virtchnl handling and VF > ndo ops > > On Mon, Feb 28, 2022 at 08:57:50PM +0000, Keller, Jacob E wrote: > > > > > > > -----Original Message----- > > > From: Greg KH <gregkh@linuxfoundation.org> > > > Sent: Monday, February 28, 2022 3:24 AM > > > To: Keller, Jacob E <jacob.e.keller@intel.com> > > > Cc: stable@vger.kernel.org; Brett Creeley <brett.creeley@intel.com>; > Jankowski, > > > Konrad0 <konrad0.jankowski@intel.com>; Nguyen, Anthony L > > > <anthony.l.nguyen@intel.com> > > > Subject: Re: [PATCH 1/2] ice: Fix race conditions between virtchnl handling > and VF > > > ndo ops > > > > > > On Mon, Feb 28, 2022 at 12:10:20PM +0100, Greg KH wrote: > > > > On Fri, Feb 25, 2022 at 12:21:00PM -0800, Jacob Keller wrote: > > > > > From: Brett Creeley <brett.creeley@intel.com> > > > > > > > > > > commit e6ba5273d4ede03d075d7a116b8edad1f6115f4d upstream. > > > > > > > > > > [I had to fix the cherry-pick manually as the patch added a line around > > > > > some context that was missing.] > > > > > > > > What stable tree(s) is this for?$ > > > > > > Looks like it applied only to 5.15.y. Can you also provide backports > > > for the other older kernels that these are needed for? > > > > > > > Hi Greg! > > > > I sent a series that should apply from v5.8 through 5.12 (excepting one patch > that was already on 5.10 but not the other trees, for some reason). I also sent a > series for 5.13 and one for 5.14. > > > > The code prior to 5.8 still has this bug, going back to the first release with ice, > (4.20), but it is different enough that I had trouble determining what the correct > patch is. Especially for the first patch which is necessary for the later fixes, since it > introduces the lock we need. I'm going to spend a bit more time later this evening > to see if I can sort it out. If not, we may have to live without the fixes on those > trees. > > I've applied the 2 missing changes to the 5.10.y tree. The other ones > are all end-of-life, sorry. > > thanks, > > greg k-h Thanks Greg! -Jake
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c index a78e8f00cf71..a0b8436f50ba 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -646,6 +646,8 @@ void ice_free_vfs(struct ice_pf *pf) set_bit(ICE_VF_STATE_DIS, pf->vf[i].vf_states); ice_free_vf_res(&pf->vf[i]); } + + mutex_destroy(&pf->vf[i].cfg_lock); } if (ice_sriov_free_msix_res(pf)) @@ -1894,6 +1896,8 @@ static void ice_set_dflt_settings_vfs(struct ice_pf *pf) */ ice_vf_ctrl_invalidate_vsi(vf); ice_vf_fdir_init(vf); + + mutex_init(&vf->cfg_lock); } } @@ -4082,6 +4086,8 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, return 0; } + mutex_lock(&vf->cfg_lock); + vf->port_vlan_info = vlanprio; if (vf->port_vlan_info) @@ -4091,6 +4097,7 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, dev_info(dev, "Clearing port VLAN on VF %d\n", vf_id); ice_vc_reset_vf(vf); + mutex_unlock(&vf->cfg_lock); return 0; } @@ -4465,6 +4472,15 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) return; } + /* VF is being configured in another context that triggers a VFR, so no + * need to process this message + */ + if (!mutex_trylock(&vf->cfg_lock)) { + dev_info(dev, "VF %u is being configured in another context that will trigger a VFR, so there is no need to handle this message\n", + vf->vf_id); + return; + } + switch (v_opcode) { case VIRTCHNL_OP_VERSION: err = ice_vc_get_ver_msg(vf, msg); @@ -4553,6 +4569,8 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event) dev_info(dev, "PF failed to honor VF %d, opcode %d, error %d\n", vf_id, v_opcode, err); } + + mutex_unlock(&vf->cfg_lock); } /** @@ -4668,6 +4686,8 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) return -EINVAL; } + mutex_lock(&vf->cfg_lock); + /* VF is notified of its new MAC via the PF's response to the * VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset */ @@ -4686,6 +4706,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) } ice_vc_reset_vf(vf); + mutex_unlock(&vf->cfg_lock); return 0; } @@ -4715,11 +4736,15 @@ int ice_set_vf_trust(struct net_device *netdev, int vf_id, bool trusted) if (trusted == vf->trusted) return 0; + mutex_lock(&vf->cfg_lock); + vf->trusted = trusted; ice_vc_reset_vf(vf); dev_info(ice_pf_to_dev(pf), "VF %u is now %strusted\n", vf_id, trusted ? "" : "un"); + mutex_unlock(&vf->cfg_lock); + return 0; } diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h index 38b4dc82c5c1..a750e9a9d712 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h @@ -74,6 +74,11 @@ struct ice_mdd_vf_events { struct ice_vf { struct ice_pf *pf; + /* Used during virtchnl message handling and NDO ops against the VF + * that will trigger a VFR + */ + struct mutex cfg_lock; + u16 vf_id; /* VF ID in the PF space */ u16 lan_vsi_idx; /* index into PF struct */ u16 ctrl_vsi_idx;