]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
rtw88: select deep PS mode when module is inserted
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Wed, 2 Oct 2019 02:31:26 +0000 (10:31 +0800)
committerSeth Forshee <seth.forshee@canonical.com>
Fri, 20 Mar 2020 21:31:24 +0000 (16:31 -0500)
BugLink: https://bugs.launchpad.net/bugs/1780590
Add a module parameter to select deep PS mode. And the mode
cannot be changed after the module has been inserted and probed.
If anyone wants to change the deep mode, should change the mode
and probe the device again to setup the changed deep mode.

When the device is probed, driver will check the deep PS mode
with different IC's PS mode suppotability. If none of the
PS mode is matched, the deep PS mode is changed to NONE,
means deep PS is disabled.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
(cherry picked from commit d3be4d115be05b1b4323286bc69de9e577fc9a0f)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/net/wireless/realtek/rtw88/main.c
drivers/net/wireless/realtek/rtw88/main.h
drivers/net/wireless/realtek/rtw88/ps.c
drivers/net/wireless/realtek/rtw88/rtw8822b.c
drivers/net/wireless/realtek/rtw88/rtw8822c.c

index 5a5c46537d33c3daffb784f879c7d5d76127c53e..e47e0f0fbfd06386da7a763881c01989ad1b5ffc 100644 (file)
 #include "efuse.h"
 #include "debug.h"
 
+unsigned int rtw_fw_lps_deep_mode;
+EXPORT_SYMBOL(rtw_fw_lps_deep_mode);
 static bool rtw_fw_support_lps;
 unsigned int rtw_debug_mask;
 EXPORT_SYMBOL(rtw_debug_mask);
 
+module_param_named(lps_deep_mode, rtw_fw_lps_deep_mode, uint, 0644);
 module_param_named(support_lps, rtw_fw_support_lps, bool, 0644);
 module_param_named(debug_mask, rtw_debug_mask, uint, 0644);
 
+MODULE_PARM_DESC(lps_deep_mode, "Deeper PS mode. If 0, deep PS is disabled");
 MODULE_PARM_DESC(support_lps, "Set Y to enable Leisure Power Save support, to turn radio off between beacons");
 MODULE_PARM_DESC(debug_mask, "Debugging mask");
 
@@ -1152,6 +1156,7 @@ EXPORT_SYMBOL(rtw_chip_info_setup);
 
 int rtw_core_init(struct rtw_dev *rtwdev)
 {
+       struct rtw_chip_info *chip = rtwdev->chip;
        struct rtw_coex *coex = &rtwdev->coex;
        int ret;
 
@@ -1183,6 +1188,10 @@ int rtw_core_init(struct rtw_dev *rtwdev)
        rtwdev->sec.total_cam_num = 32;
        rtwdev->hal.current_channel = 1;
        set_bit(RTW_BC_MC_MACID, rtwdev->mac_id_map);
+       if (!(BIT(rtw_fw_lps_deep_mode) & chip->lps_deep_mode_supported))
+               rtwdev->lps_conf.deep_mode = LPS_DEEP_MODE_NONE;
+       else
+               rtwdev->lps_conf.deep_mode = rtw_fw_lps_deep_mode;
 
        mutex_lock(&rtwdev->mutex);
        rtw_add_rsvd_page(rtwdev, RSVD_BEACON, false);
index 6e6b04759ace69ea49c1e2f4d4495d6745fb8a07..a59cbaefde4eb5950b06b436dac46faaeca5f41b 100644 (file)
@@ -27,6 +27,7 @@
 #define RTW_RF_PATH_MAX                        4
 #define HW_FEATURE_LEN                 13
 
+extern unsigned int rtw_fw_lps_deep_mode;
 extern unsigned int rtw_debug_mask;
 extern const struct ieee80211_ops rtw_ops;
 extern struct rtw_chip_info rtw8822b_hw_spec;
@@ -528,6 +529,11 @@ enum rtw_lps_mode {
        RTW_MODE_WMM_PS = 2,
 };
 
+enum rtw_lps_deep_mode {
+       LPS_DEEP_MODE_NONE      = 0,
+       LPS_DEEP_MODE_LCLK      = 1,
+};
+
 enum rtw_pwr_state {
        RTW_RF_OFF      = 0x0,
        RTW_RF_ON       = 0x4,
@@ -536,6 +542,7 @@ enum rtw_pwr_state {
 
 struct rtw_lps_conf {
        enum rtw_lps_mode mode;
+       enum rtw_lps_deep_mode deep_mode;
        enum rtw_pwr_state state;
        u8 awake_interval;
        u8 rlbm;
@@ -844,6 +851,7 @@ struct rtw_chip_info {
 
        bool ht_supported;
        bool vht_supported;
+       u8 lps_deep_mode_supported;
 
        /* init values */
        u8 sys_func_en;
index 1661cc2e5fe38bca801962ad5bcb8f410219dad4..02e104ac7b9e75afc590c38d84b575ca9799000e 100644 (file)
@@ -132,6 +132,9 @@ static void rtw_leave_lps_core(struct rtw_dev *rtwdev)
 
 static void __rtw_enter_lps_deep(struct rtw_dev *rtwdev)
 {
+       if (rtwdev->lps_conf.deep_mode == LPS_DEEP_MODE_NONE)
+               return;
+
        if (!test_bit(RTW_FLAG_LEISURE_PS, rtwdev->flags)) {
                rtw_dbg(rtwdev, RTW_DBG_PS,
                        "Should enter LPS before entering deep PS\n");
index 63abda3b0ebfc448dfb1850e7cd17533192d53f0..2b6cd7cf763b39eec28fc2e96ad9035adc8f7f1f 100644 (file)
@@ -1977,6 +1977,7 @@ struct rtw_chip_info rtw8822b_hw_spec = {
        .dig_min = 0x1c,
        .ht_supported = true,
        .vht_supported = true,
+       .lps_deep_mode_supported = BIT(LPS_DEEP_MODE_LCLK),
        .sys_func_en = 0xDC,
        .pwr_on_seq = card_enable_flow_8822b,
        .pwr_off_seq = card_disable_flow_8822b,
index a52180c1ca0fb155bf677b3590c21b399d31005c..368a47fcc4013a02579b6847c75d454f07b955a7 100644 (file)
@@ -3747,6 +3747,7 @@ struct rtw_chip_info rtw8822c_hw_spec = {
        .dig_min = 0x20,
        .ht_supported = true,
        .vht_supported = true,
+       .lps_deep_mode_supported = BIT(LPS_DEEP_MODE_LCLK),
        .sys_func_en = 0xD8,
        .pwr_on_seq = card_enable_flow_8822c,
        .pwr_off_seq = card_disable_flow_8822c,