wifi: rtw89: coex: summarize Wi-Fi to BT scoreboard and inform BT one time a cycle
authorChing-Te Ku <ku920601@realtek.com>
Tue, 20 Sep 2022 01:09:37 +0000 (09:09 +0800)
committerKalle Valo <kvalo@kernel.org>
Thu, 22 Sep 2022 06:11:45 +0000 (09:11 +0300)
If Wi-Fi driver send Wi-Fi status to BT via scoreboard too frequent in a
short moment, BT will loss some of them because of hardware response time.
To avoid this issue, change the code flow. Summarize the scoreboard changes
and if the value have changed, send the scoreboard to BT only once in
a coexistence processing cycle. It also can help to reduce driver I/O.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220920010939.12173-8-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/coex.c
drivers/net/wireless/realtek/rtw89/core.h

index 85c8e7ffb56c7ab8f0580daa80f07ceed9f01d7c..ef6c5701ebcf521bbda12204b08ab48811a187e4 100644 (file)
@@ -3558,11 +3558,22 @@ static void _set_bt_rx_agc(struct rtw89_dev *rtwdev)
 /* TODO add these functions */
 static void _action_common(struct rtw89_dev *rtwdev)
 {
+       struct rtw89_btc *btc = &rtwdev->btc;
+       struct rtw89_btc_wl_info *wl = &btc->cx.wl;
+
        _set_btg_ctrl(rtwdev);
        _set_wl_tx_limit(rtwdev);
        _set_bt_afh_info(rtwdev);
        _set_bt_rx_agc(rtwdev);
        _set_rf_trx_para(rtwdev);
+
+       if (wl->scbd_change) {
+               rtw89_mac_cfg_sb(rtwdev, wl->scbd);
+               rtw89_debug(rtwdev, RTW89_DBG_BTC, "[BTC], write scbd: 0x%08x\n",
+                           wl->scbd);
+               wl->scbd_change = false;
+               btc->cx.cnt_wl[BTC_WCNT_SCBDUPDATE]++;
+       }
 }
 
 static void _action_by_bt(struct rtw89_dev *rtwdev)
@@ -3885,20 +3896,20 @@ static void _write_scbd(struct rtw89_dev *rtwdev, u32 val, bool state)
        struct rtw89_btc *btc = &rtwdev->btc;
        struct rtw89_btc_wl_info *wl = &btc->cx.wl;
        u32 scbd_val = 0;
+       u8 force_exec = false;
 
        if (!chip->scbd)
                return;
 
        scbd_val = state ? wl->scbd | val : wl->scbd & ~val;
 
-       if (scbd_val == wl->scbd)
-               return;
-       rtw89_mac_cfg_sb(rtwdev, scbd_val);
-       rtw89_debug(rtwdev, RTW89_DBG_BTC, "[BTC], write scbd: 0x%08x\n",
-                   scbd_val);
-       wl->scbd = scbd_val;
+       if (val & BTC_WSCB_ACTIVE || val & BTC_WSCB_ON)
+               force_exec = true;
 
-       btc->cx.cnt_wl[BTC_WCNT_SCBDUPDATE]++;
+       if (scbd_val != wl->scbd || force_exec) {
+               wl->scbd = scbd_val;
+               wl->scbd_change = true;
+       }
 }
 
 static u8
index c4eefa54ed864af4c41fa1923a4e4b67ae6985ff..8af1813cba88488205d0cb6a354611b8c69aa15b 100644 (file)
@@ -1308,6 +1308,7 @@ struct rtw89_btc_wl_info {
        u8 port_id[RTW89_WIFI_ROLE_MLME_MAX];
        u8 rssi_level;
 
+       bool scbd_change;
        u32 scbd;
 };