From 46550395a12b9da686b8b41a2d7e97467a060ded Mon Sep 17 00:00:00 2001 From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com> Date: Thu, 20 Feb 2020 16:51:11 +0900 Subject: [PATCH 1/3] mwifiex: sta_cmd: do not enable ps_mode by default It's known on Surface series devices that ps_mode causes connection instability at least on 5GHz AP. ("connection instability" here means not crash, but networking stop, like ping not responding.) This commit stops enabling ps_mode on driver initialization. --- drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c index 013db4386c396..977b57c0908fb 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c @@ -2338,17 +2338,6 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init) if (ret) return -1; - if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { - /* Enable IEEE PS by default */ - priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; - ret = mwifiex_send_cmd(priv, - HostCmd_CMD_802_11_PS_MODE_ENH, - EN_AUTO_PS, BITMAP_STA_PS, NULL, - true); - if (ret) - return -1; - } - if (drcs) { adapter->drcs_enabled = true; if (ISSUPP_DRCS_ENABLED(adapter->fw_cap_info)) From 305e68667eae9f25ea692bfb1dab7abb237eacbb Mon Sep 17 00:00:00 2001 From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com> Date: Thu, 27 Feb 2020 16:52:04 +0900 Subject: [PATCH 2/3] mwifiex: cfg80211: add allow_ps_mode module parameter Add allow_ps_mode module parameter to allow ps_mode if needed. Disallowed by default. Reason for returning negative value (-1) is to inform userspace tools like iw command that setting power_save to be enabled is not permitted. Examlpe run: $ sudo iw dev mlan0 set power_save on command failed: Operation not permitted (-1) --- .../net/wireless/marvell/mwifiex/cfg80211.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index d896841685008..b6c8389323abd 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -25,6 +25,11 @@ static char *reg_alpha2; module_param(reg_alpha2, charp, 0); +static bool allow_ps_mode; +module_param(allow_ps_mode, bool, 0444); +MODULE_PARM_DESC(allow_ps_mode, + "allow WiFi power management to be enabled. (default: disallowed)"); + static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = { { .max = 3, .types = BIT(NL80211_IFTYPE_STATION) | @@ -439,6 +444,19 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, ps_mode = enabled; + /* Allow ps_mode to be enabled only when allow_ps_mode is set + * (but always allow ps_mode to be disabled in case it gets enabled + * for unknown reason and you want to disable it) */ + if (ps_mode && !allow_ps_mode) { + dev_info(priv->adapter->dev, + "Request to enable ps_mode received but it's disallowed " + "by module parameter. Rejecting the request.\n"); + + /* Return negative value to inform userspace tools that setting + * power_save to be enabled is not permitted. */ + return -1; + } + return mwifiex_drv_set_power(priv, &ps_mode); } From 49f26745fa8b0560de96ced96db2ca1dcca5bd6d Mon Sep 17 00:00:00 2001 From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com> Date: Thu, 27 Feb 2020 18:03:02 +0900 Subject: [PATCH 3/3] mwifiex: cfg80211: print message when changing ps_mode Notify user of ps_mode status change. Especially, print a warning when user enabled ps_mode. --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index b6c8389323abd..108d7ac6a0dd9 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -457,6 +457,14 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy, return -1; } + if (ps_mode) + dev_warn(priv->adapter->dev, + "WARN: Request to enable ps_mode received. Enabling it. " + "Disable it if you encounter connection instability.\n"); + else + dev_info(priv->adapter->dev, + "Request to disable ps_mode received. Disabling it.\n"); + return mwifiex_drv_set_power(priv, &ps_mode); }