Commit e223eaec authored by Dave Ertman's avatar Dave Ertman Committed by Jeff Kirsher

ice: Fix hang when ethtool disables FW LLDP

When disabling and enabling VSIs, there are a couple of flows
that recursively acquire the RTNL lock which causes a deadlock.
Fix that.
Signed-off-by: default avatarDave Ertman <david.m.ertman@intel.com>
Signed-off-by: default avatarAnirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent a84db525
...@@ -133,8 +133,10 @@ static void ice_pf_dcb_recfg(struct ice_pf *pf) ...@@ -133,8 +133,10 @@ static void ice_pf_dcb_recfg(struct ice_pf *pf)
* ice_pf_dcb_cfg - Apply new DCB configuration * ice_pf_dcb_cfg - Apply new DCB configuration
* @pf: pointer to the PF struct * @pf: pointer to the PF struct
* @new_cfg: DCBX config to apply * @new_cfg: DCBX config to apply
* @locked: is the RTNL held
*/ */
static int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg) static
int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked)
{ {
struct ice_dcbx_cfg *old_cfg, *curr_cfg; struct ice_dcbx_cfg *old_cfg, *curr_cfg;
struct ice_aqc_port_ets_elem buf = { 0 }; struct ice_aqc_port_ets_elem buf = { 0 };
...@@ -163,7 +165,8 @@ static int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg) ...@@ -163,7 +165,8 @@ static int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg)
/* avoid race conditions by holding the lock while disabling and /* avoid race conditions by holding the lock while disabling and
* re-enabling the VSI * re-enabling the VSI
*/ */
rtnl_lock(); if (!locked)
rtnl_lock();
ice_pf_dis_all_vsi(pf, true); ice_pf_dis_all_vsi(pf, true);
memcpy(curr_cfg, new_cfg, sizeof(*curr_cfg)); memcpy(curr_cfg, new_cfg, sizeof(*curr_cfg));
...@@ -192,7 +195,8 @@ static int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg) ...@@ -192,7 +195,8 @@ static int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg)
out: out:
ice_pf_ena_all_vsi(pf, true); ice_pf_ena_all_vsi(pf, true);
rtnl_unlock(); if (!locked)
rtnl_unlock();
devm_kfree(&pf->pdev->dev, old_cfg); devm_kfree(&pf->pdev->dev, old_cfg);
return ret; return ret;
} }
...@@ -271,15 +275,16 @@ void ice_dcb_rebuild(struct ice_pf *pf) ...@@ -271,15 +275,16 @@ void ice_dcb_rebuild(struct ice_pf *pf)
prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW; prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW;
prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
memcpy(&prev_cfg->etsrec, &prev_cfg->etscfg, sizeof(prev_cfg->etsrec)); memcpy(&prev_cfg->etsrec, &prev_cfg->etscfg, sizeof(prev_cfg->etsrec));
ice_pf_dcb_cfg(pf, prev_cfg); ice_pf_dcb_cfg(pf, prev_cfg, false);
devm_kfree(&pf->pdev->dev, prev_cfg); devm_kfree(&pf->pdev->dev, prev_cfg);
} }
/** /**
* ice_dcb_init_cfg - set the initial DCB config in SW * ice_dcb_init_cfg - set the initial DCB config in SW
* @pf: pf to apply config to * @pf: pf to apply config to
* @locked: Is the RTNL held
*/ */
static int ice_dcb_init_cfg(struct ice_pf *pf) static int ice_dcb_init_cfg(struct ice_pf *pf, bool locked)
{ {
struct ice_dcbx_cfg *newcfg; struct ice_dcbx_cfg *newcfg;
struct ice_port_info *pi; struct ice_port_info *pi;
...@@ -294,7 +299,7 @@ static int ice_dcb_init_cfg(struct ice_pf *pf) ...@@ -294,7 +299,7 @@ static int ice_dcb_init_cfg(struct ice_pf *pf)
memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg)); memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg));
dev_info(&pf->pdev->dev, "Configuring initial DCB values\n"); dev_info(&pf->pdev->dev, "Configuring initial DCB values\n");
if (ice_pf_dcb_cfg(pf, newcfg)) if (ice_pf_dcb_cfg(pf, newcfg, locked))
ret = -EINVAL; ret = -EINVAL;
devm_kfree(&pf->pdev->dev, newcfg); devm_kfree(&pf->pdev->dev, newcfg);
...@@ -305,8 +310,9 @@ static int ice_dcb_init_cfg(struct ice_pf *pf) ...@@ -305,8 +310,9 @@ static int ice_dcb_init_cfg(struct ice_pf *pf)
/** /**
* ice_dcb_sw_default_config - Apply a default DCB config * ice_dcb_sw_default_config - Apply a default DCB config
* @pf: pf to apply config to * @pf: pf to apply config to
* @locked: was this function called with RTNL held
*/ */
static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf) static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool locked)
{ {
struct ice_aqc_port_ets_elem buf = { 0 }; struct ice_aqc_port_ets_elem buf = { 0 };
struct ice_dcbx_cfg *dcbcfg; struct ice_dcbx_cfg *dcbcfg;
...@@ -338,7 +344,7 @@ static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf) ...@@ -338,7 +344,7 @@ static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf)
dcbcfg->app[0].priority = 3; dcbcfg->app[0].priority = 3;
dcbcfg->app[0].prot_id = ICE_APP_PROT_ID_FCOE; dcbcfg->app[0].prot_id = ICE_APP_PROT_ID_FCOE;
ret = ice_pf_dcb_cfg(pf, dcbcfg); ret = ice_pf_dcb_cfg(pf, dcbcfg, locked);
devm_kfree(&pf->pdev->dev, dcbcfg); devm_kfree(&pf->pdev->dev, dcbcfg);
if (ret) if (ret)
return ret; return ret;
...@@ -349,8 +355,9 @@ static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf) ...@@ -349,8 +355,9 @@ static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf)
/** /**
* ice_init_pf_dcb - initialize DCB for a PF * ice_init_pf_dcb - initialize DCB for a PF
* @pf: pf to initiialize DCB for * @pf: pf to initiialize DCB for
* @locked: Was function called with RTNL held
*/ */
int ice_init_pf_dcb(struct ice_pf *pf) int ice_init_pf_dcb(struct ice_pf *pf, bool locked)
{ {
struct device *dev = &pf->pdev->dev; struct device *dev = &pf->pdev->dev;
struct ice_port_info *port_info; struct ice_port_info *port_info;
...@@ -386,7 +393,7 @@ int ice_init_pf_dcb(struct ice_pf *pf) ...@@ -386,7 +393,7 @@ int ice_init_pf_dcb(struct ice_pf *pf)
} }
if (sw_default) { if (sw_default) {
err = ice_dcb_sw_dflt_cfg(pf); err = ice_dcb_sw_dflt_cfg(pf, locked);
if (err) { if (err) {
dev_err(&pf->pdev->dev, dev_err(&pf->pdev->dev,
"Failed to set local DCB config %d\n", err); "Failed to set local DCB config %d\n", err);
...@@ -405,7 +412,7 @@ int ice_init_pf_dcb(struct ice_pf *pf) ...@@ -405,7 +412,7 @@ int ice_init_pf_dcb(struct ice_pf *pf)
set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
err = ice_dcb_init_cfg(pf); err = ice_dcb_init_cfg(pf, locked);
if (err) if (err)
goto dcb_init_err; goto dcb_init_err;
...@@ -515,7 +522,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, ...@@ -515,7 +522,7 @@ ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
err = ice_lldp_to_dcb_cfg(event->msg_buf, dcbcfg); err = ice_lldp_to_dcb_cfg(event->msg_buf, dcbcfg);
if (!err) if (!err)
ice_pf_dcb_cfg(pf, dcbcfg); ice_pf_dcb_cfg(pf, dcbcfg, false);
devm_kfree(&pf->pdev->dev, dcbcfg); devm_kfree(&pf->pdev->dev, dcbcfg);
......
...@@ -14,7 +14,7 @@ void ice_dcb_rebuild(struct ice_pf *pf); ...@@ -14,7 +14,7 @@ void ice_dcb_rebuild(struct ice_pf *pf);
u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg); u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg);
u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg); u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg);
void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi); void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi);
int ice_init_pf_dcb(struct ice_pf *pf); int ice_init_pf_dcb(struct ice_pf *pf, bool locked);
void ice_update_dcb_stats(struct ice_pf *pf); void ice_update_dcb_stats(struct ice_pf *pf);
int int
ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring, ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
...@@ -40,7 +40,8 @@ static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) ...@@ -40,7 +40,8 @@ static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg)
return 1; return 1;
} }
static inline int ice_init_pf_dcb(struct ice_pf *pf) static inline int
ice_init_pf_dcb(struct ice_pf *pf, bool __always_unused locked)
{ {
dev_dbg(&pf->pdev->dev, "DCB not supported\n"); dev_dbg(&pf->pdev->dev, "DCB not supported\n");
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -458,7 +458,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) ...@@ -458,7 +458,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
* will likely not need DCB, so failure to init is * will likely not need DCB, so failure to init is
* not a concern of ethtool * not a concern of ethtool
*/ */
status = ice_init_pf_dcb(pf); status = ice_init_pf_dcb(pf, true);
if (status) if (status)
dev_warn(&pf->pdev->dev, "Fail to init DCB\n"); dev_warn(&pf->pdev->dev, "Fail to init DCB\n");
} else { } else {
...@@ -497,7 +497,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) ...@@ -497,7 +497,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
dev_dbg(&pf->pdev->dev, dev_dbg(&pf->pdev->dev,
"Fail to reg for MIB change\n"); "Fail to reg for MIB change\n");
status = ice_init_pf_dcb(pf); status = ice_init_pf_dcb(pf, true);
if (status) if (status)
dev_dbg(&pf->pdev->dev, "Fail to init DCB\n"); dev_dbg(&pf->pdev->dev, "Fail to init DCB\n");
} }
......
...@@ -2302,7 +2302,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent) ...@@ -2302,7 +2302,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
ice_init_pf(pf); ice_init_pf(pf);
err = ice_init_pf_dcb(pf); err = ice_init_pf_dcb(pf, false);
if (err) { if (err) {
clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
clear_bit(ICE_FLAG_DCB_ENA, pf->flags); clear_bit(ICE_FLAG_DCB_ENA, pf->flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment