wifi: rtw89: mcc: avoid redundant recalculations if no chance to improve
authorZong-Zhe Yang <kevin_yang@realtek.com>
Sun, 11 May 2025 03:52:17 +0000 (11:52 +0800)
committerPing-Ke Shih <pkshih@realtek.com>
Fri, 16 May 2025 00:45:00 +0000 (08:45 +0800)
MCC will track the changes of beacon offset, and trigger a recalculation
when the difference is larger than the tolerance. It means that a better
pattern is expected after recalculating. However, in the cases which get
a worse beacon offset, there is no chance to improve the pattern even if
recalculating. So, bypass them.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250511035217.10410-7-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/chan.c

index b7593c7465b96a0a4b5b12aefd78f346fa37ccd4..806f42429a2902ee39409db3255433155eaf8306 100644 (file)
@@ -2367,7 +2367,7 @@ static void rtw89_mcc_track(struct rtw89_dev *rtwdev)
        struct rtw89_mcc_info *mcc = &rtwdev->mcc;
        struct rtw89_mcc_config *config = &mcc->config;
        struct rtw89_mcc_pattern *pattern = &config->pattern;
-       s16 tolerance;
+       u16 tolerance;
        u16 bcn_ofst;
        u16 diff;
 
@@ -2375,18 +2375,25 @@ static void rtw89_mcc_track(struct rtw89_dev *rtwdev)
                return;
 
        bcn_ofst = rtw89_mcc_get_bcn_ofst(rtwdev);
+       if (bcn_ofst == config->beacon_offset)
+               return;
+
        if (bcn_ofst > config->beacon_offset) {
                diff = bcn_ofst - config->beacon_offset;
                if (pattern->tob_aux < 0)
                        tolerance = -pattern->tob_aux;
-               else
+               else if (pattern->toa_aux > 0)
                        tolerance = pattern->toa_aux;
+               else
+                       return; /* no chance to improve */
        } else {
                diff = config->beacon_offset - bcn_ofst;
                if (pattern->toa_aux < 0)
                        tolerance = -pattern->toa_aux;
-               else
+               else if (pattern->tob_aux > 0)
                        tolerance = pattern->tob_aux;
+               else
+                       return; /* no chance to improve */
        }
 
        if (diff <= tolerance)