diff mbox series

[1/7] wifi: rtw89: chan: refine MCC re-plan flow when unassign chanctx

Message ID 20240727080650.12195-2-pkshih@realtek.com (mailing list archive)
State Accepted
Delegated to: Ping-Ke Shih
Headers show
Series wifi: rtw89: refine use of vif/chanctx and MCC | expand

Commit Message

Ping-Ke Shih July 27, 2024, 8:06 a.m. UTC
From: Zong-Zhe Yang <kevin_yang@realtek.com>

Originally during unassign-chanctx, MCC (multi-channel concurrency) is
re-planed before set-channel if need. But, we might calculate MCC stuffs
based on old channel info. And, the following set-channel might be racing
with FW MCC state mechanism. So, we refine this flow. Now, if MCC re-plan
is needed here, it will be done after set-channel.

Besides, to be more rigorous, we now ensure entity isn't paused before we
deal with MCC things here.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/chan.c | 37 +++++++++++++++--------
 1 file changed, 25 insertions(+), 12 deletions(-)

Comments

Ping-Ke Shih Aug. 2, 2024, 1:48 a.m. UTC | #1
Ping-Ke Shih <pkshih@realtek.com> wrote:

> From: Zong-Zhe Yang <kevin_yang@realtek.com>
> 
> Originally during unassign-chanctx, MCC (multi-channel concurrency) is
> re-planed before set-channel if need. But, we might calculate MCC stuffs
> based on old channel info. And, the following set-channel might be racing
> with FW MCC state mechanism. So, we refine this flow. Now, if MCC re-plan
> is needed here, it will be done after set-channel.
> 
> Besides, to be more rigorous, we now ensure entity isn't paused before we
> deal with MCC things here.
> 
> Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>

7 patch(es) applied to rtw-next branch of rtw.git, thanks.

62c5a91b25f0 wifi: rtw89: chan: refine MCC re-plan flow when unassign chanctx
39b9271095b2 wifi: rtw89: mcc: stop at a role holding chanctx
583e998e2024 wifi: rtw89: rename sub_entity to chanctx
75d853d4ae45 wifi: rtw89: pass rtwvif to RFK channel
ed5f66a28120 wifi: rtw89: pass rtwvif to RFK scan
db0dbe26f48a wifi: rtw89: fw: correct chan access in assoc_cmac_tbl_g7 and update_beacon_be
11b227901ffa wifi: rtw89: pass chanctx_idx to rtw89_btc_{path_}phymap()

---
https://github.com/pkshih/rtw.git
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw89/chan.c b/drivers/net/wireless/realtek/rtw89/chan.c
index 7f90d93dcdc0..3789c98de36a 100644
--- a/drivers/net/wireless/realtek/rtw89/chan.c
+++ b/drivers/net/wireless/realtek/rtw89/chan.c
@@ -2443,9 +2443,10 @@  void rtw89_chanctx_ops_unassign_vif(struct rtw89_dev *rtwdev,
 {
 	struct rtw89_chanctx_cfg *cfg = (struct rtw89_chanctx_cfg *)ctx->drv_priv;
 	struct rtw89_hal *hal = &rtwdev->hal;
-	struct rtw89_entity_weight w = {};
 	enum rtw89_sub_entity_idx roll;
 	enum rtw89_entity_mode cur;
+	enum rtw89_entity_mode new;
+	int ret;
 
 	rtwvif->sub_entity_idx = RTW89_SUB_ENTITY_0;
 	rtwvif->chanctx_assigned = false;
@@ -2469,21 +2470,33 @@  void rtw89_chanctx_ops_unassign_vif(struct rtw89_dev *rtwdev,
 	rtw89_swap_sub_entity(rtwdev, cfg->idx, roll);
 
 out:
-	rtw89_entity_calculate_weight(rtwdev, &w);
+	if (!hal->entity_pause) {
+		cur = rtw89_get_entity_mode(rtwdev);
+		switch (cur) {
+		case RTW89_ENTITY_MODE_MCC:
+			rtw89_mcc_stop(rtwdev);
+			break;
+		default:
+			break;
+		}
+	}
+
+	ret = rtw89_set_channel(rtwdev);
+	if (ret)
+		return;
 
-	cur = rtw89_get_entity_mode(rtwdev);
-	switch (cur) {
+	if (hal->entity_pause)
+		return;
+
+	new = rtw89_get_entity_mode(rtwdev);
+	switch (new) {
 	case RTW89_ENTITY_MODE_MCC:
-		/* If still multi-roles, re-plan MCC for chanctx changes.
-		 * Otherwise, just stop MCC.
-		 */
-		rtw89_mcc_stop(rtwdev);
-		if (w.active_roles == NUM_OF_RTW89_MCC_ROLES)
-			rtw89_mcc_start(rtwdev);
+		/* re-plan MCC for chanctx changes. */
+		ret = rtw89_mcc_start(rtwdev);
+		if (ret)
+			rtw89_warn(rtwdev, "failed to start MCC: %d\n", ret);
 		break;
 	default:
 		break;
 	}
-
-	rtw89_set_channel(rtwdev);
 }