]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ice: Fix hang when ethtool disables FW LLDP
authorDave Ertman <david.m.ertman@intel.com>
Tue, 16 Apr 2019 17:24:29 +0000 (10:24 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 23 May 2019 17:51:53 +0000 (10:51 -0700)
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: Dave Ertman <david.m.ertman@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_dcb_lib.c
drivers/net/ethernet/intel/ice/ice_dcb_lib.h
drivers/net/ethernet/intel/ice/ice_ethtool.c
drivers/net/ethernet/intel/ice/ice_main.c

index e2e921506edca7f016cd816263264389e1c05131..8d849ef5cb0cb9af45dc41bc4acd4f531ad0536c 100644 (file)
@@ -133,8 +133,10 @@ static void ice_pf_dcb_recfg(struct ice_pf *pf)
  * ice_pf_dcb_cfg - Apply new DCB configuration
  * @pf: pointer to the PF struct
  * @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_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)
        /* avoid race conditions by holding the lock while disabling and
         * re-enabling the VSI
         */
-       rtnl_lock();
+       if (!locked)
+               rtnl_lock();
        ice_pf_dis_all_vsi(pf, true);
 
        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)
 
 out:
        ice_pf_ena_all_vsi(pf, true);
-       rtnl_unlock();
+       if (!locked)
+               rtnl_unlock();
        devm_kfree(&pf->pdev->dev, old_cfg);
        return ret;
 }
@@ -271,15 +275,16 @@ dcb_error:
        prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW;
        prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
        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);
 }
 
 /**
  * ice_dcb_init_cfg - set the initial DCB config in SW
  * @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_port_info *pi;
@@ -294,7 +299,7 @@ static int ice_dcb_init_cfg(struct ice_pf *pf)
        memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg));
 
        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;
 
        devm_kfree(&pf->pdev->dev, newcfg);
@@ -305,8 +310,9 @@ static int ice_dcb_init_cfg(struct ice_pf *pf)
 /**
  * ice_dcb_sw_default_config - Apply a default DCB config
  * @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_dcbx_cfg *dcbcfg;
@@ -338,7 +344,7 @@ static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf)
        dcbcfg->app[0].priority = 3;
        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);
        if (ret)
                return ret;
@@ -349,8 +355,9 @@ static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf)
 /**
  * ice_init_pf_dcb - initialize DCB for a PF
  * @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 ice_port_info *port_info;
@@ -386,7 +393,7 @@ int ice_init_pf_dcb(struct ice_pf *pf)
        }
 
        if (sw_default) {
-               err = ice_dcb_sw_dflt_cfg(pf);
+               err = ice_dcb_sw_dflt_cfg(pf, locked);
                if (err) {
                        dev_err(&pf->pdev->dev,
                                "Failed to set local DCB config %d\n", err);
@@ -405,7 +412,7 @@ int ice_init_pf_dcb(struct ice_pf *pf)
 
        set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
 
-       err = ice_dcb_init_cfg(pf);
+       err = ice_dcb_init_cfg(pf, locked);
        if (err)
                goto dcb_init_err;
 
@@ -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);
                if (!err)
-                       ice_pf_dcb_cfg(pf, dcbcfg);
+                       ice_pf_dcb_cfg(pf, dcbcfg, false);
 
                devm_kfree(&pf->pdev->dev, dcbcfg);
 
index ca7b76faa03ca2ec9b48dd17550f84e06b73680e..819081053ff51f1d12edd443ef579abb9dfb77e5 100644 (file)
@@ -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_num_tc(struct ice_dcbx_cfg *dcbcfg);
 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);
 int
 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)
        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");
        return -EOPNOTSUPP;
index 76122a28da7e04a6cfc9f7a7cddeae7c318585c3..c1511393846f08aa49213974ddb8ab6e4d4f9778 100644 (file)
@@ -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
                         * not a concern of ethtool
                         */
-                       status = ice_init_pf_dcb(pf);
+                       status = ice_init_pf_dcb(pf, true);
                        if (status)
                                dev_warn(&pf->pdev->dev, "Fail to init DCB\n");
                } else {
@@ -497,7 +497,7 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)
                                dev_dbg(&pf->pdev->dev,
                                        "Fail to reg for MIB change\n");
 
-                       status = ice_init_pf_dcb(pf);
+                       status = ice_init_pf_dcb(pf, true);
                        if (status)
                                dev_dbg(&pf->pdev->dev, "Fail to init DCB\n");
                }
index cbe8c5f2d953f9367b2e476e4e852ef8c83cc7c7..65def27733134af6a8de7a51885290bf043b7d48 100644 (file)
@@ -2302,7 +2302,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 
        ice_init_pf(pf);
 
-       err = ice_init_pf_dcb(pf);
+       err = ice_init_pf_dcb(pf, false);
        if (err) {
                clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
                clear_bit(ICE_FLAG_DCB_ENA, pf->flags);