Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp91616lql; Fri, 12 Apr 2024 05:00:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdB1gsMDtnE2GSb4LrOdlO0TeJ9XbZdPZpMu/avuto7FKpTm77BnbefBYkdTrgJUDxS8XAmwdQemwmnZxTyFSr6SdcMSeEgsOfFsyGFg== X-Google-Smtp-Source: AGHT+IFhkEI68ixZMmzEXJ9/LcA1tisTseyQDu8Jvy7XSLQwzcKy39rZ9t258MF4jaz+AQ6M5xGo X-Received: by 2002:a50:8712:0:b0:56c:5a49:736 with SMTP id i18-20020a508712000000b0056c5a490736mr1773932edb.9.1712923208261; Fri, 12 Apr 2024 05:00:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712923208; cv=pass; d=google.com; s=arc-20160816; b=qYVNGEIKHBLcr2d/q7rt1hN4NhO2o7zjaUC/8kqqlnNGlQLxbXHIct0M8P/BOzK8V1 yax56fL90oJS+mvNWUXvwFAJdyYzCUHXoNcdfoHVpsDbjQLveQ/szjAt/CNOdgWnno9l VZdINQ+2L8ugR2rRju/BweKOcPGje+1BHdXryydIp9AUJliOXBBL/MbSSnUvqBjWKPPl V67fpYNRrDSS1G9h7/QcsTakeRJtN11I1ef/EVTPVga1yL3kHaJFrQJofa4UFaAn6Q6y OPx2VnxVApY4T72b+m/GFqztJxhpvW+/0uOXCzlBrevRGH/wWOT4+53mMhN1yz+fDPfH WicA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=0USjo4bNW/A3N8I2qNWzk1SyYuFEwzHvzOojFmMaAms=; fh=HUg66QM+WrcYjhrjAZO9Io78soUV0XNx50nXI3Hf4XU=; b=hDseUW3Hihl8yBd07ZGEvWQ3ViSpcnnA5Qc8LY3M0lXxrv3qc2bbJ2DIJmm16zy4vb mWpcmOLi3O6m2Vlmw859CIvE6HgXBDGWZOl/VJQKMoM0XQh/nPgCBPeEE1P6/uXUaKQu dggviQRi+2D1p/IB3GKMCducGvI6WzzQXJJjNaoGQmGfY6izOrhgaHuZUf/krL9mhP3W KDalPDvWSYMMInd1V0zye+L6SSxJqDpM+TryKGmsaCxWp+soUk5Tnf6ZO0lL0qqyBcRG a+V2NSIk3nPHAZTeUm7Na2/oS1IYOSStcO5fKDVX98gLEnD/ZAuYVyo81iCgKhkD5AOs f1qQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-6252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6252-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id i29-20020a50d75d000000b00568bc639c51si1700196edj.1.2024.04.12.05.00.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 05:00:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-6252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-6252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-6252-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DEBC91F22782 for ; Fri, 12 Apr 2024 12:00:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3706655783; Fri, 12 Apr 2024 11:59:53 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E2AF54BEA for ; Fri, 12 Apr 2024 11:59:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712923193; cv=none; b=JazVrmcS6+WVfIm8uY+5r6ocwFFanMjwUR+fzDLNk7glZp3kz2VtX7euAHcRFySV8Ie2fcZauwvJfcvHybyxAn921jWnTJUeV72DwD3r1GIlWM6+XfxiiQBAiVOXK9Qc1VYQ/veUwhEA8l3KJakI1V/RAYaoNU4YzQprGCkU2dM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712923193; c=relaxed/simple; bh=e/0oW4GAwWNRWd9lVsjLhuG86gb/CUm8qZ8LIhgFNdw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XlnPbpc+HE9F1auPcP15j6ayqhrc9/mVUsttHUTXPJzINWbLRJas1j5SprPZGMdA3vRj7y0si2CZi+beyA+MXVPU03Yh5u1o7wt+fB5qpahQTQ/fNNRJjCu7NDcuo7GR3931l6U/9uAf4K19/7dLGaUjOHH3TszGmRfwqJ1JLGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 43CBxnwtF2094321, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36505.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 43CBxnwtF2094321 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Apr 2024 19:59:49 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36505.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 19:59:50 +0800 Received: from [127.0.1.1] (172.16.17.25) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 19:59:49 +0800 From: Ping-Ke Shih To: CC: Subject: [PATCH 8/8] wifi: rtw89: regd: handle policy of 6 GHz SP according to BIOS Date: Fri, 12 Apr 2024 19:57:29 +0800 Message-ID: <20240412115729.8316-9-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240412115729.8316-1-pkshih@realtek.com> References: <20240412115729.8316-1-pkshih@realtek.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXH36505.realtek.com.tw, 9 X-KSE-AntiSpam-Interceptor-Info: fallback X-KSE-Antivirus-Interceptor-Info: fallback X-KSE-AntiSpam-Interceptor-Info: fallback From: Zong-Zhe Yang According to BIOS configuration of Realtek ACPI DSM function 7, RTW89_ACPI_DSM_FUNC_6GHZ_SP_SUP, we handle the regd policy of 6 GHz SP. If BIOS indicates to override driver settings, we only allow the countries, which are enabled by BIOS, to use 6 GHz SP power. Other countries will be applied to select default power when recalculating 6 GHz regulatory power selection. Signed-off-by: Zong-Zhe Yang Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtw89/core.h | 1 + drivers/net/wireless/realtek/rtw89/regd.c | 59 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/net/wireless/realtek/rtw89/core.h b/drivers/net/wireless/realtek/rtw89/core.h index 7cd6b3179713..1fb960af0a85 100644 --- a/drivers/net/wireless/realtek/rtw89/core.h +++ b/drivers/net/wireless/realtek/rtw89/core.h @@ -4760,6 +4760,7 @@ struct rtw89_regulatory_info { enum rtw89_reg_6ghz_power reg_6ghz_power; DECLARE_BITMAP(block_unii4, RTW89_REGD_MAX_COUNTRY_NUM); DECLARE_BITMAP(block_6ghz, RTW89_REGD_MAX_COUNTRY_NUM); + DECLARE_BITMAP(block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM); }; enum rtw89_ifs_clm_application { diff --git a/drivers/net/wireless/realtek/rtw89/regd.c b/drivers/net/wireless/realtek/rtw89/regd.c index 47384615e18c..1a133914f673 100644 --- a/drivers/net/wireless/realtek/rtw89/regd.c +++ b/drivers/net/wireless/realtek/rtw89/regd.c @@ -468,6 +468,51 @@ static void rtw89_regd_setup_policy_6ghz(struct rtw89_dev *rtwdev) kfree(ptr); } +static void rtw89_regd_setup_policy_6ghz_sp(struct rtw89_dev *rtwdev) +{ + struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; + const struct rtw89_acpi_policy_6ghz_sp *ptr; + struct rtw89_acpi_dsm_result res = {}; + bool enable_by_us; + int ret; + int i; + + ret = rtw89_acpi_evaluate_dsm(rtwdev, RTW89_ACPI_DSM_FUNC_6GHZ_SP_SUP, &res); + if (ret) { + rtw89_debug(rtwdev, RTW89_DBG_REGD, + "acpi: cannot eval policy 6ghz-sp: %d\n", ret); + return; + } + + ptr = res.u.policy_6ghz_sp; + + switch (ptr->override) { + default: + rtw89_debug(rtwdev, RTW89_DBG_REGD, + "%s: unknown override case: %d\n", __func__, + ptr->override); + fallthrough; + case 0: + goto out; + case 1: + break; + } + + bitmap_fill(regulatory->block_6ghz_sp, RTW89_REGD_MAX_COUNTRY_NUM); + + enable_by_us = u8_get_bits(ptr->conf, RTW89_ACPI_CONF_6GHZ_SP_US); + + for (i = 0; i < ARRAY_SIZE(rtw89_regd_map); i++) { + const struct rtw89_regd *tmp = &rtw89_regd_map[i]; + + if (enable_by_us && memcmp(tmp->alpha2, "US", 2) == 0) + clear_bit(i, regulatory->block_6ghz_sp); + } + +out: + kfree(ptr); +} + static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy) { const struct rtw89_chip_info *chip = rtwdev->chip; @@ -510,6 +555,7 @@ static void rtw89_regd_setup_6ghz(struct rtw89_dev *rtwdev, struct wiphy *wiphy) if (regd_allow_6ghz) { rtw89_regd_setup_policy_6ghz(rtwdev); + rtw89_regd_setup_policy_6ghz_sp(rtwdev); return; } @@ -671,10 +717,12 @@ void rtw89_regd_notifier(struct wiphy *wiphy, struct regulatory_request *request static void __rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev) { struct rtw89_regulatory_info *regulatory = &rtwdev->regulatory; + const struct rtw89_regd *regd = regulatory->regd; enum rtw89_reg_6ghz_power sel; const struct rtw89_chan *chan; struct rtw89_vif *rtwvif; int count = 0; + u8 index; rtw89_for_each_rtwvif(rtwdev, rtwvif) { chan = rtw89_chan_get(rtwdev, rtwvif->sub_entity_idx); @@ -691,6 +739,17 @@ static void __rtw89_reg_6ghz_power_recalc(struct rtw89_dev *rtwdev) if (count != 1) sel = RTW89_REG_6GHZ_POWER_DFLT; + if (sel == RTW89_REG_6GHZ_POWER_STD) { + index = rtw89_regd_get_index(regd); + if (index == RTW89_REGD_MAX_COUNTRY_NUM || + test_bit(index, regulatory->block_6ghz_sp)) { + rtw89_debug(rtwdev, RTW89_DBG_REGD, + "%c%c 6 GHz SP is blocked by policy\n", + regd->alpha2[0], regd->alpha2[1]); + sel = RTW89_REG_6GHZ_POWER_DFLT; + } + } + if (regulatory->reg_6ghz_power == sel) return; -- 2.25.1