Skip to contentSkip to conversation

ice: double lock on adev_mutex

PATCH In review Michal Swiatkowski 2 participants 2 messages Jan 13, 2023 – Jan 19, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ice: double lock on adev_mutex

Call trace:

ice_set_channel() --> mutex_lock(adev_mutex) ice_vsi_recfg_qs()
ice_pf_dcb_recfg()
ice_send_event_to_aux() --> another mutex_lock(adev_mutex)

This call trace is reached when user try to change queues amount using ethtool:

$ ethtool -L enp24s0f0np0 tx 64 rx 32

Avoid double lock by unlocking after checking if RDMA is active.

Fixes a49a2713f00e ("ice: Prevent set_channel from changing queues while RDMA active")

---
v1 --> v2:
* As mutex_unlock happens before other error handling there is no need to have ret variable, remove it

To be squash with:
https://patchwork.ozlabs.org/project/intel-wired-lan/patch/[email protected]/

---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +6 -10
index 263d59929602..936f0e0c553d 100644
@@ -3662,7 +3662,6 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
 	struct ice_pf *pf = vsi->back;
 	int new_rx = 0, new_tx = 0;
 	u32 curr_combined;
-	int ret = 0;
 
 	/* do not support changing channels in Safe Mode */
 	if (ice_is_safe_mode(pf)) {
@@ -3729,23 +3728,20 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
 	mutex_lock(&pf->adev_mutex);
 	if (pf->adev && pf->adev->dev.driver) {
 		netdev_err(dev, "Cannot change channels when RDMA is active\n");
-		ret = -EINVAL;
-		goto adev_unlock;
+		mutex_unlock(&pf->adev_mutex);
+		return -EINVAL;
 	}
+	mutex_unlock(&pf->adev_mutex);
 
 	ice_vsi_recfg_qs(vsi, new_rx, new_tx);
 
-	if (!netif_is_rxfh_configured(dev)) {
-		ret = ice_vsi_set_dflt_rss_lut(vsi, new_rx);
-		goto adev_unlock;
-	}
+	if (!netif_is_rxfh_configured(dev))
+		return ice_vsi_set_dflt_rss_lut(vsi, new_rx);
 
 	/* Update rss_size due to change in Rx queues */
 	vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx);
 
-adev_unlock:
-	mutex_unlock(&pf->adev_mutex);
-	return ret;
+	return 0;
 }
 
 /**
Signature · 6 lines
2.36.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Tested-by on v2 1/1
#1 lore raw
Quoted 30 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Michal Swiatkowski
Sent: Friday, January 13, 2023 11:35 AM
To: [email protected]
Subject: [Intel-wired-lan] [PATCH net v2] ice: double lock on adev_mutex

Call trace:

ice_set_channel() --> mutex_lock(adev_mutex) ice_vsi_recfg_qs()
ice_pf_dcb_recfg()
ice_send_event_to_aux() --> another mutex_lock(adev_mutex)

This call trace is reached when user try to change queues amount using ethtool:

$ ethtool -L enp24s0f0np0 tx 64 rx 32

Avoid double lock by unlocking after checking if RDMA is active.

Fixes a49a2713f00e ("ice: Prevent set_channel from changing queues while

RDMA active")

---
v1 --> v2:
* As mutex_unlock happens before other error handling there is no need to
have ret variable, remove it

Quoted 7 lines

To be squash with:
https://patchwork.ozlabs.org/project/intel-wired-
lan/patch/[email protected]/

---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan