From 0ac5ead00bf90f3280b8f5c0a0ad12e9800da8ec Mon Sep 17 00:00:00 2001 From: Zong-Zhe Yang Date: Tue, 21 Oct 2025 21:33:59 +0800 Subject: [PATCH] wifi: rtw89: regd: apply ACPI policy even if country code is programmed There are regulatory related policy according to BIOS/ACPI configuration, e.g. distro decides to disable some bands or some channels. Even if chip has a programmed country code, these policy should still be applied within regulatory notifier. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih Link: https://patch.msgid.link/20251021133402.15467-6-pkshih@realtek.com --- drivers/net/wireless/realtek/rtw89/core.h | 2 ++ drivers/net/wireless/realtek/rtw89/regd.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h index 7c74ed3cfaf74..ae98d6866b30a 100644 --- a/drivers/net/wireless/realtek/rtw89/core.h +++ b/drivers/net/wireless/realtek/rtw89/core.h @@ -5449,6 +5449,8 @@ struct rtw89_regd_ctrl { struct rtw89_regulatory_info { struct rtw89_regd_ctrl ctrl; const struct rtw89_regd *regd; + bool programmed; + enum rtw89_reg_6ghz_power reg_6ghz_power; struct rtw89_reg_6ghz_tpe reg_6ghz_tpe; bool txpwr_uk_follow_etsi; diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c index 58582f8d2b74c..209d84909f885 100644 --- a/drivers/net/wireless/realtek/rtw89/regd.c +++ b/drivers/net/wireless/realtek/rtw89/regd.c @@ -723,6 +723,8 @@ int rtw89_regd_init_hint(struct rtw89_dev *rtwdev) chip_regd = rtw89_regd_find_reg_by_name(rtwdev, rtwdev->efuse.country_code); if (!rtw89_regd_is_ww(chip_regd)) { rtwdev->regulatory.regd = chip_regd; + rtwdev->regulatory.programmed = true; + /* Ignore country ie if there is a country domain programmed in chip */ wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE; wiphy->regulatory_flags |= REGULATORY_STRICT_REG; @@ -867,11 +869,6 @@ static void rtw89_regd_notifier_apply(struct rtw89_dev *rtwdev, wiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE; else wiphy->regulatory_flags &= ~REGULATORY_COUNTRY_IE_IGNORE; - - rtw89_regd_apply_policy_unii4(rtwdev, wiphy); - rtw89_regd_apply_policy_6ghz(rtwdev, wiphy); - rtw89_regd_apply_policy_tas(rtwdev); - rtw89_regd_apply_policy_ant_gain(rtwdev); } static @@ -883,19 +880,22 @@ void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request wiphy_lock(wiphy); rtw89_leave_ps_mode(rtwdev); - if (wiphy->regd) { - rtw89_debug(rtwdev, RTW89_DBG_REGD, - "There is a country domain programmed in chip, ignore notifications\n"); - goto exit; - } + if (rtwdev->regulatory.programmed) + goto policy; + rtw89_regd_notifier_apply(rtwdev, wiphy, request); rtw89_debug_regd(rtwdev, rtwdev->regulatory.regd, "get from initiator %d, alpha2", request->initiator); +policy: + rtw89_regd_apply_policy_unii4(rtwdev, wiphy); + rtw89_regd_apply_policy_6ghz(rtwdev, wiphy); + rtw89_regd_apply_policy_tas(rtwdev); + rtw89_regd_apply_policy_ant_gain(rtwdev); + rtw89_core_set_chip_txpwr(rtwdev); -exit: wiphy_unlock(wiphy); } -- 2.47.3