diff mbox series

[14/20] wifi: rtw88: 8821a: Regularly ask for BT info updates

Message ID bd23d618-3f56-4729-ba23-8c14e9873ef9@gmail.com
State New
Headers show
Series wifi: rtw88: Add support for RTL8821AU and RTL8812AU | expand

Commit Message

Bitterblue Smith Aug. 11, 2024, 9:04 p.m. UTC
The RTL8821AU firmware sends C2H_BT_INFO by itself when bluetooth
headphones are connected, but not when they are disconnected. This leads
to the coexistence code still using the A2DP algorithm long after the
headphones are disconnected, which means the wifi speeds are much lower
than they should be. Work around this by asking for updates every two
seconds if the chip is RTL8821AU.

Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
---
 drivers/net/wireless/realtek/rtw88/coex.c | 2 +-
 drivers/net/wireless/realtek/rtw88/coex.h | 1 +
 drivers/net/wireless/realtek/rtw88/main.c | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)

Comments

Ping-Ke Shih Aug. 15, 2024, 7:26 a.m. UTC | #1
Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> The RTL8821AU firmware sends C2H_BT_INFO by itself when bluetooth
> headphones are connected, but not when they are disconnected. This leads
> to the coexistence code still using the A2DP algorithm long after the
> headphones are disconnected, which means the wifi speeds are much lower
> than they should be. Work around this by asking for updates every two
> seconds if the chip is RTL8821AU.
> 
> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
> ---
>  drivers/net/wireless/realtek/rtw88/coex.c | 2 +-
>  drivers/net/wireless/realtek/rtw88/coex.h | 1 +
>  drivers/net/wireless/realtek/rtw88/main.c | 3 +++
>  3 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c
> index 39fbc5ef82f8..91e21bdfb569 100644
> --- a/drivers/net/wireless/realtek/rtw88/coex.c
> +++ b/drivers/net/wireless/realtek/rtw88/coex.c
> @@ -446,7 +446,7 @@ static void rtw_coex_check_rfk(struct rtw_dev *rtwdev)
>         }
>  }
> 
> -static void rtw_coex_query_bt_info(struct rtw_dev *rtwdev)
> +void rtw_coex_query_bt_info(struct rtw_dev *rtwdev)
>  {
>         struct rtw_coex *coex = &rtwdev->coex;
>         struct rtw_coex_stat *coex_stat = &coex->stat;
> diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h
> index 57cf29da9ea4..b6400e87e78d 100644
> --- a/drivers/net/wireless/realtek/rtw88/coex.h
> +++ b/drivers/net/wireless/realtek/rtw88/coex.h
> @@ -384,6 +384,7 @@ u32 rtw_coex_read_indirect_reg(struct rtw_dev *rtwdev, u16 addr);
>  void rtw_coex_write_indirect_reg(struct rtw_dev *rtwdev, u16 addr,
>                                  u32 mask, u32 val);
>  void rtw_coex_write_scbd(struct rtw_dev *rtwdev, u16 bitpos, bool set);
> +void rtw_coex_query_bt_info(struct rtw_dev *rtwdev);
> 
>  void rtw_coex_bt_relink_work(struct work_struct *work);
>  void rtw_coex_bt_reenable_work(struct work_struct *work);
> diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
> index 62d9abc04a34..699870ca1a9f 100644
> --- a/drivers/net/wireless/realtek/rtw88/main.c
> +++ b/drivers/net/wireless/realtek/rtw88/main.c
> @@ -261,6 +261,9 @@ static void rtw_watch_dog_work(struct work_struct *work)
>         rtw_coex_wl_status_check(rtwdev);
>         rtw_coex_query_bt_hid_list(rtwdev);
> 
> +       if (rtwdev->chip->id == RTW_CHIP_TYPE_8821A && rtwdev->efuse.btcoex)
> +               rtw_coex_query_bt_info(rtwdev);
> +

Move to an individual function such as rtw_coex_active_query_bt_info() (maybe inline function),
and add a little bit comments to describe how we need this. 

>         rtw_phy_dynamic_mechanism(rtwdev);
> 
>         rtw_hci_dynamic_rx_agg(rtwdev,
> --
> 2.46.0
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw88/coex.c b/drivers/net/wireless/realtek/rtw88/coex.c
index 39fbc5ef82f8..91e21bdfb569 100644
--- a/drivers/net/wireless/realtek/rtw88/coex.c
+++ b/drivers/net/wireless/realtek/rtw88/coex.c
@@ -446,7 +446,7 @@  static void rtw_coex_check_rfk(struct rtw_dev *rtwdev)
 	}
 }
 
-static void rtw_coex_query_bt_info(struct rtw_dev *rtwdev)
+void rtw_coex_query_bt_info(struct rtw_dev *rtwdev)
 {
 	struct rtw_coex *coex = &rtwdev->coex;
 	struct rtw_coex_stat *coex_stat = &coex->stat;
diff --git a/drivers/net/wireless/realtek/rtw88/coex.h b/drivers/net/wireless/realtek/rtw88/coex.h
index 57cf29da9ea4..b6400e87e78d 100644
--- a/drivers/net/wireless/realtek/rtw88/coex.h
+++ b/drivers/net/wireless/realtek/rtw88/coex.h
@@ -384,6 +384,7 @@  u32 rtw_coex_read_indirect_reg(struct rtw_dev *rtwdev, u16 addr);
 void rtw_coex_write_indirect_reg(struct rtw_dev *rtwdev, u16 addr,
 				 u32 mask, u32 val);
 void rtw_coex_write_scbd(struct rtw_dev *rtwdev, u16 bitpos, bool set);
+void rtw_coex_query_bt_info(struct rtw_dev *rtwdev);
 
 void rtw_coex_bt_relink_work(struct work_struct *work);
 void rtw_coex_bt_reenable_work(struct work_struct *work);
diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c
index 62d9abc04a34..699870ca1a9f 100644
--- a/drivers/net/wireless/realtek/rtw88/main.c
+++ b/drivers/net/wireless/realtek/rtw88/main.c
@@ -261,6 +261,9 @@  static void rtw_watch_dog_work(struct work_struct *work)
 	rtw_coex_wl_status_check(rtwdev);
 	rtw_coex_query_bt_hid_list(rtwdev);
 
+	if (rtwdev->chip->id == RTW_CHIP_TYPE_8821A && rtwdev->efuse.btcoex)
+		rtw_coex_query_bt_info(rtwdev);
+
 	rtw_phy_dynamic_mechanism(rtwdev);
 
 	rtw_hci_dynamic_rx_agg(rtwdev,