Linux wireless drivers development
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <ku920601@realtek.com>, <kevin_yang@realtek.com>
Subject: [PATCH rtw-next 4/7] wifi: rtw89: coex: fix BT scoreboard update for non-C2H paths
Date: Wed, 23 Sep 2026 15:13:51 +0800	[thread overview]
Message-ID: <20260923071354.50864-5-pkshih@realtek.com> (raw)
In-Reply-To: <20260923071354.50864-1-pkshih@realtek.com>

From: Ching-Te Ku <ku920601@realtek.com>

The scoreboard update function was changed to always read from
scbd_c2h, which is populated only by BTF_EVNT_BT_SCBD C2H events from
the BT firmware. This caused two problems.

First, calling _update_bt_scbd at the NTFY_INIT notification with
scbd_c2h still zero would set bt->enable.now to 0, overwriting the
bt-on assumption that _ntfy_init_coex establishes for all chips. Remove
the NTFY_INIT call to preserve that default.

Second, chips whose BT firmware does not send BTF_EVNT_BT_SCBD events
have scbd_c2h stuck at zero indefinitely, making scoreboard updates
non-functional. Restore a hardware register read path by adding
_read_scbd() and an is_c2h flag to _update_bt_scbd. The
NTFY_RADIO_STATE path passes is_c2h=false to read the hardware
scoreboard register directly, ensuring correct BT state even without
C2H support. Pass BTC_ALL_BT so both BT devices are refreshed on
dual-BT chips.

Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/coex.c | 28 +++++++++++++++++------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index b80e7979a1ae..6b72e2c80d14 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -1010,7 +1010,7 @@ static void _run_coex(struct rtw89_dev *rtwdev,
 		      enum btc_reason_and_action reason);
 static void _write_scbd(struct rtw89_dev *rtwdev, u8 bid, u32 val, bool state);
 static u8 _sned_h2c_w2bscbd(struct rtw89_dev *rtwdev, bool force_exec, u8 bid);
-static void _update_bt_scbd(struct rtw89_dev *rtwdev, u8 bid);
+static void _update_bt_scbd(struct rtw89_dev *rtwdev, u8 bid, bool is_c2h);
 static const char *id_to_h2c(u32 id);
 
 static void _reset_h2c_macro(struct rtw89_btc *btc)
@@ -3902,7 +3902,7 @@ void btc_fw_event(struct rtw89_dev *rtwdev, u8 evt_id, void *data, u32 len)
 				    "[BTC], %s() bt%d:c2h->0x%08x, rb->0x%08x\n",
 				    __func__, i, bt->scbd_c2h, bt->scbd_rb);
 			bt->scbd_c2h = bt->scbd_rb;
-			_update_bt_scbd(rtwdev, i);
+			_update_bt_scbd(rtwdev, i, true);
 			btc->dm.scbd_b2w_update = false;
 		}
 	}
@@ -8116,7 +8116,21 @@ static void _update_bt_ctrl_lps(struct rtw89_dev *rtwdev)
 	}
 }
 
-static void _update_bt_scbd(struct rtw89_dev *rtwdev, u8 bid)
+static u32 _read_scbd(struct rtw89_dev *rtwdev, u8 id)
+{
+	const struct rtw89_chip_info *chip = rtwdev->chip;
+	u32 val;
+
+	if (!chip->scbd)
+		return 0;
+
+	val = rtw89_read32(rtwdev, chip->btc_sb.n[id].get);
+	rtw89_debug(rtwdev, RTW89_DBG_BTC,
+		    "[BTC], read scbd bt%d: 0x%08x\n", id, val);
+	return val;
+}
+
+static void _update_bt_scbd(struct rtw89_dev *rtwdev, u8 bid, bool is_c2h)
 {
 	struct rtw89_btc_bt_link_info *bt_2g, *bt_56g;
 	struct rtw89_btc *btc = &rtwdev->btc;
@@ -8149,7 +8163,7 @@ static void _update_bt_scbd(struct rtw89_dev *rtwdev, u8 bid)
 		if (!(rtwdev->chip->para_ver & BTC_FEAT_DUAL_BT) && id == BTC_BT_2ND)
 			break;
 
-		val = bt->scbd_c2h;
+		val = is_c2h ? bt->scbd_c2h : _read_scbd(rtwdev, id);
 
 		if (val == 0xffffffff) {
 			rtw89_debug(rtwdev, RTW89_DBG_BTC,
@@ -8785,8 +8799,8 @@ void _run_coex(struct rtw89_dev *rtwdev, enum btc_reason_and_action reason)
 
 	_update_run_ctrl_info(rtwdev);
 
-	if (reason == BTC_RSN_NTFY_INIT || reason == BTC_RSN_NTFY_RADIO_STATE)
-		_update_bt_scbd(rtwdev, false);
+	if (reason == BTC_RSN_NTFY_RADIO_STATE)
+		_update_bt_scbd(rtwdev, BTC_ALL_BT, false);
 
 	dm->freerun = false;
 	dm->cnt_dm[BTC_DCNT_RUN]++;
@@ -10131,7 +10145,7 @@ void rtw89_btc_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb,
 		rtw89_debug(rtwdev, RTW89_DBG_BTC,
 			    "[BTC], handle C2H BT%d SCBD with data 0x%08x\n",
 			    bid, bt->scbd_c2h);
-		_update_bt_scbd(rtwdev, bid);
+		_update_bt_scbd(rtwdev, bid, true);
 		_run_coex(rtwdev, BTC_RSN_UPDATE_BT_SCBD);
 		break;
 	case BTF_EVNT_BT_PSD:
-- 
2.25.1


  parent reply	other threads:[~2026-09-23  7:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  7:13 [PATCH rtw-next 0/7] wifi: rtw89: coex: update to support newer firmware especially RTL8852C Ping-Ke Shih
2026-09-23  7:13 ` [PATCH rtw-next 1/7] wifi: rtw89: coex: log FCX report version mismatch without dropping Ping-Ke Shih
2026-09-30  2:14   ` Ping-Ke Shih
2026-09-23  7:13 ` [PATCH rtw-next 2/7] wifi: rtw89: coex: add fbtc_rpt_ctrl v205 report struct and handling Ping-Ke Shih
2026-09-23  7:13 ` [PATCH rtw-next 3/7] wifi: rtw89: coex: Add firmware 0.27.130.1 support for RTL8852C Ping-Ke Shih
2026-09-23  7:13 ` Ping-Ke Shih [this message]
2026-09-23  7:13 ` [PATCH rtw-next 5/7] wifi: rtw89: add instance of IO ops for (un)pack and [um]delay Ping-Ke Shih
2026-09-23  7:13 ` [PATCH rtw-next 6/7] wifi: rtw89: coex: offload 8852C IO writes via firmware CMD pack region Ping-Ke Shih
2026-09-23  7:13 ` [PATCH rtw-next 7/7] wifi: rtw89: coex: batch PTA init with masked IO offload Ping-Ke Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923071354.50864-5-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=kevin_yang@realtek.com \
    --cc=ku920601@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox