1 From b19840afc05121293ae59f017cb9924814eb5d77 Mon Sep 17 00:00:00 2001
2 From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
3 Date: Wed, 23 Oct 2024 17:14:12 +0300
4 Subject: [PATCH] wifi: rtw88: coex: Support chips without a scoreboard
6 All the chips currently supported have a "scoreboard": the chip keeps
7 track of certain things related to bluetooth, for example, whether
8 bluetooth is active. The information can be read from register 0xaa.
10 RTL8821AU doesn't have this. Implement bluetooth activity detection in
11 rtw_coex_monitor_bt_enable() based on the bluetooth TX/RX counters.
13 This is mostly important for RTL8811AU, the version of RTL8821AU without
14 bluetooth. Without this change, the driver thinks bluetooth is active
15 and the wifi speeds are low.
17 Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
18 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
19 Link: https://patch.msgid.link/5058f23d-2086-42cd-82ad-eef31a348467@gmail.com
21 drivers/net/wireless/realtek/rtw88/coex.c | 18 ++++++++++++++++++
22 drivers/net/wireless/realtek/rtw88/main.h | 1 +
23 2 files changed, 19 insertions(+)
25 --- a/drivers/net/wireless/realtek/rtw88/coex.c
26 +++ b/drivers/net/wireless/realtek/rtw88/coex.c
27 @@ -494,11 +494,29 @@ static void rtw_coex_monitor_bt_enable(s
28 struct rtw_coex_stat *coex_stat = &coex->stat;
29 struct rtw_coex_dm *coex_dm = &coex->dm;
30 bool bt_disabled = false;
31 + bool bt_active = true;
34 if (chip->scbd_support) {
35 score_board = rtw_coex_read_scbd(rtwdev);
36 bt_disabled = !(score_board & COEX_SCBD_ONOFF);
38 + if (coex_stat->hi_pri_tx == 0 && coex_stat->hi_pri_rx == 0 &&
39 + coex_stat->lo_pri_tx == 0 && coex_stat->lo_pri_rx == 0)
42 + if (coex_stat->hi_pri_tx == 0xffff && coex_stat->hi_pri_rx == 0xffff &&
43 + coex_stat->lo_pri_tx == 0xffff && coex_stat->lo_pri_rx == 0xffff)
47 + coex_stat->bt_disable_cnt = 0;
48 + bt_disabled = false;
50 + coex_stat->bt_disable_cnt++;
51 + if (coex_stat->bt_disable_cnt >= 10)
56 if (coex_stat->bt_disabled != bt_disabled) {
57 --- a/drivers/net/wireless/realtek/rtw88/main.h
58 +++ b/drivers/net/wireless/realtek/rtw88/main.h
59 @@ -1494,6 +1494,7 @@ struct rtw_coex_stat {
65 u16 wl_beacon_interval;