Skip to contentSkip to conversation

octeontx2-pf: Add missing mutex lock in otx2_get_pauseparam

PATCH Superseded Subbaraya Sundeep 2 participants 3 messages Nov 25, 2023 – Nov 29, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Subbaraya Sundeep

author maintainer
#0 lore raw

PATCH 1/1 octeontx2-pf: Add missing mutex lock in otx2_get_pauseparam

All the mailbox messages sent to AF needs to be guarded by mutex lock. Add the missing lock in otx2_get_pauseparam function.

Fixes 75f36270990c ("octeontx2-pf: Support to enable/disable pause frames via ethtool")
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +5 -1
index 9efcec5..53f6258 100644
@@ -334,9 +334,12 @@ static void otx2_get_pauseparam(struct net_device *netdev,
 	if (is_otx2_lbkvf(pfvf->pdev))
 		return;
 
+	mutex_lock(&pfvf->mbox.lock);
 	req = otx2_mbox_alloc_msg_cgx_cfg_pause_frm(&pfvf->mbox);
-	if (!req)
+	if (!req) {
+		mutex_unlock(&pfvf->mbox.lock);
 		return;
+	}
 
 	if (!otx2_sync_mbox_msg(&pfvf->mbox)) {
 		rsp = (struct cgx_pause_frm_cfg *)
@@ -344,6 +347,7 @@ static void otx2_get_pauseparam(struct net_device *netdev,
 		pause->rx_pause = rsp->rx_pause;
 		pause->tx_pause = rsp->tx_pause;
 	}
+	mutex_unlock(&pfvf->mbox.lock);
 }
 
 static int otx2_set_pauseparam(struct net_device *netdev,
Signature · 1 line
2.7.4
reviewer
#1 lore raw
Quoted 6 lines · Subbaraya Sundeep

All the mailbox messages sent to AF needs to be guarded by mutex lock. Add the missing lock in otx2_get_pauseparam function.

Fixes 75f36270990c ("octeontx2-pf: Support to enable/disable pause frames via ethtool")

Hi,

I am wondering if the call to otx2_nix_config_bp()
in otx2_dcbnl_ieee_setpfc() also needs to be protected by mbox.lock.

And although not strictly related to this patch, while looking over this, I noticed that in otx2_init_hw_resources() it appears that &mbox->lock may be unlocked twice in some error paths.

e.g.

	/* Init Auras and pools used by NIX RQ, for free buffer ptrs */
	err = otx2_rq_aura_pool_init(pf);
	if (err) {
		mutex_unlock(&mbox->lock);
		goto err_free_nix_lf;
	}
	...
err_free_nix_lf:
	mutex_lock(&mbox->lock);
	...

...

author maintainer
#2 lore raw

Hi Simon,

Quoted 16 lines

-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Tuesday, November 28, 2023 10:51 PM
To: Subbaraya Sundeep Bhatta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Sunil Kovvuri Goutham <[email protected]>; Geethasowjanya Akula <[email protected]>; Hariprasad Kelam <[email protected]>
Subject: [EXT] Re: [PATCH net] octeontx2-pf: Add missing mutex lock in otx2_get_pauseparam

----------------------------------------------------------------------

Quoted 3 lines · Subbaraya Sundeep

All the mailbox messages sent to AF needs to be guarded by mutex lock. Add the missing lock in otx2_get_pauseparam function.

Quoted 9 lines
Quoted 3 lines
Fixes 75f36270990c ("octeontx2-pf: Support to enable/disable pause

frames via ethtool")

Hi,

I am wondering if the call to otx2_nix_config_bp() in otx2_dcbnl_ieee_setpfc() also needs to be protected by mbox.lock.

Correct. I will add lock around it and send v2 of this patch.

Quoted 16 lines

And although not strictly related to this patch, while looking over this, I noticed that in otx2_init_hw_resources() it appears that &mbox->lock may be unlocked twice in some error paths.

e.g.

	/* Init Auras and pools used by NIX RQ, for free buffer ptrs */
	err = otx2_rq_aura_pool_init(pf);
	if (err) {
		mutex_unlock(&mbox->lock);
		goto err_free_nix_lf;
	}
	...
err_free_nix_lf:
	mutex_lock(&mbox->lock);
	...
Quoted 1 line

...

Will fix it and send it as another patch.

Thanks,
Sundeep