0006-wifi.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. From a3b5cbab95f51e6923be2d6c3dca5482cae46468 Mon Sep 17 00:00:00 2001
  2. From: sebanc <22224731+sebanc@users.noreply.github.com>
  3. Date: Mon, 4 Nov 2019 09:30:57 +0100
  4. Subject: [PATCH 6/7] wifi
  5. ---
  6. .../net/wireless/marvell/mwifiex/cfg80211.c | 26 +++++++
  7. drivers/net/wireless/marvell/mwifiex/pcie.c | 74 ++++++++++---------
  8. .../net/wireless/marvell/mwifiex/sta_cmd.c | 26 +------
  9. 3 files changed, 67 insertions(+), 59 deletions(-)
  10. diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
  11. index d89684168500..108d7ac6a0dd 100644
  12. --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
  13. +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
  14. @@ -25,6 +25,11 @@
  15. static char *reg_alpha2;
  16. module_param(reg_alpha2, charp, 0);
  17. +static bool allow_ps_mode;
  18. +module_param(allow_ps_mode, bool, 0444);
  19. +MODULE_PARM_DESC(allow_ps_mode,
  20. + "allow WiFi power management to be enabled. (default: disallowed)");
  21. +
  22. static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
  23. {
  24. .max = 3, .types = BIT(NL80211_IFTYPE_STATION) |
  25. @@ -439,6 +444,27 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy,
  26. ps_mode = enabled;
  27. + /* Allow ps_mode to be enabled only when allow_ps_mode is set
  28. + * (but always allow ps_mode to be disabled in case it gets enabled
  29. + * for unknown reason and you want to disable it) */
  30. + if (ps_mode && !allow_ps_mode) {
  31. + dev_info(priv->adapter->dev,
  32. + "Request to enable ps_mode received but it's disallowed "
  33. + "by module parameter. Rejecting the request.\n");
  34. +
  35. + /* Return negative value to inform userspace tools that setting
  36. + * power_save to be enabled is not permitted. */
  37. + return -1;
  38. + }
  39. +
  40. + if (ps_mode)
  41. + dev_warn(priv->adapter->dev,
  42. + "WARN: Request to enable ps_mode received. Enabling it. "
  43. + "Disable it if you encounter connection instability.\n");
  44. + else
  45. + dev_info(priv->adapter->dev,
  46. + "Request to disable ps_mode received. Disabling it.\n");
  47. +
  48. return mwifiex_drv_set_power(priv, &ps_mode);
  49. }
  50. diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
  51. index fc1706d0647d..b3380ed75431 100644
  52. --- a/drivers/net/wireless/marvell/mwifiex/pcie.c
  53. +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
  54. @@ -149,35 +149,38 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter)
  55. */
  56. static int mwifiex_pcie_suspend(struct device *dev)
  57. {
  58. + struct pci_dev *pdev = to_pci_dev(dev);
  59. + struct pcie_service_card *card = pci_get_drvdata(pdev);
  60. struct mwifiex_adapter *adapter;
  61. - struct pcie_service_card *card = dev_get_drvdata(dev);
  62. -
  63. + struct mwifiex_private *priv;
  64. + const struct mwifiex_pcie_card_reg *reg;
  65. + u32 fw_status;
  66. + int ret;
  67. /* Might still be loading firmware */
  68. wait_for_completion(&card->fw_done);
  69. adapter = card->adapter;
  70. - if (!adapter) {
  71. - dev_err(dev, "adapter is not valid\n");
  72. + if (!adapter || !adapter->priv_num)
  73. return 0;
  74. - }
  75. - mwifiex_enable_wake(adapter);
  76. + reg = card->pcie.reg;
  77. + if (reg)
  78. + ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status);
  79. + else
  80. + fw_status = -1;
  81. +
  82. + if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) {
  83. + mwifiex_deauthenticate_all(adapter);
  84. - /* Enable the Host Sleep */
  85. - if (!mwifiex_enable_hs(adapter)) {
  86. - mwifiex_dbg(adapter, ERROR,
  87. - "cmd: failed to suspend\n");
  88. - clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
  89. - mwifiex_disable_wake(adapter);
  90. - return -EFAULT;
  91. - }
  92. + priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
  93. - flush_workqueue(adapter->workqueue);
  94. + mwifiex_disable_auto_ds(priv);
  95. - /* Indicate device suspended */
  96. - set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
  97. - clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
  98. + mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN);
  99. + }
  100. +
  101. + mwifiex_remove_card(adapter);
  102. return 0;
  103. }
  104. @@ -192,28 +195,29 @@ static int mwifiex_pcie_suspend(struct device *dev)
  105. */
  106. static int mwifiex_pcie_resume(struct device *dev)
  107. {
  108. - struct mwifiex_adapter *adapter;
  109. - struct pcie_service_card *card = dev_get_drvdata(dev);
  110. + struct pci_dev *pdev = to_pci_dev(dev);
  111. + struct pcie_service_card *card = pci_get_drvdata(pdev);
  112. + int ret;
  113. + pr_debug("info: vendor=0x%4.04X device=0x%4.04X rev=%d\n",
  114. + pdev->vendor, pdev->device, pdev->revision);
  115. - if (!card->adapter) {
  116. - dev_err(dev, "adapter structure is not valid\n");
  117. - return 0;
  118. - }
  119. + init_completion(&card->fw_done);
  120. - adapter = card->adapter;
  121. + card->dev = pdev;
  122. - if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
  123. - mwifiex_dbg(adapter, WARN,
  124. - "Device already resumed\n");
  125. - return 0;
  126. + /* device tree node parsing and platform specific configuration */
  127. + if (pdev->dev.of_node) {
  128. + ret = mwifiex_pcie_probe_of(&pdev->dev);
  129. + if (ret)
  130. + return ret;
  131. }
  132. - clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
  133. -
  134. - mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
  135. - MWIFIEX_ASYNC_CMD);
  136. - mwifiex_disable_wake(adapter);
  137. + if (mwifiex_add_card(card, &card->fw_done, &pcie_ops,
  138. + MWIFIEX_PCIE, &pdev->dev)) {
  139. + pr_err("%s failed\n", __func__);
  140. + return -1;
  141. + }
  142. return 0;
  143. }
  144. @@ -267,6 +271,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
  145. return -1;
  146. }
  147. + pdev->bus->self->bridge_d3 = false;
  148. +
  149. return 0;
  150. }
  151. diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
  152. index 4ed10cf82f9a..977b57c0908f 100644
  153. --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
  154. +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c
  155. @@ -2265,14 +2265,13 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
  156. int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
  157. {
  158. struct mwifiex_adapter *adapter = priv->adapter;
  159. - int ret;
  160. struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
  161. - struct mwifiex_ds_auto_ds auto_ds;
  162. enum state_11d_t state_11d;
  163. struct mwifiex_ds_11n_tx_cfg tx_cfg;
  164. u8 sdio_sp_rx_aggr_enable;
  165. u16 packet_aggr_enable;
  166. int data;
  167. + int ret;
  168. if (first_sta) {
  169. if (priv->adapter->iface_type == MWIFIEX_PCIE) {
  170. @@ -2339,17 +2338,6 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
  171. if (ret)
  172. return -1;
  173. - if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
  174. - /* Enable IEEE PS by default */
  175. - priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
  176. - ret = mwifiex_send_cmd(priv,
  177. - HostCmd_CMD_802_11_PS_MODE_ENH,
  178. - EN_AUTO_PS, BITMAP_STA_PS, NULL,
  179. - true);
  180. - if (ret)
  181. - return -1;
  182. - }
  183. -
  184. if (drcs) {
  185. adapter->drcs_enabled = true;
  186. if (ISSUPP_DRCS_ENABLED(adapter->fw_cap_info))
  187. @@ -2395,18 +2383,6 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
  188. if (ret)
  189. return -1;
  190. - if (!disable_auto_ds && first_sta &&
  191. - priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
  192. - /* Enable auto deep sleep */
  193. - auto_ds.auto_ds = DEEP_SLEEP_ON;
  194. - auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
  195. - ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
  196. - EN_AUTO_PS, BITMAP_AUTO_DS,
  197. - &auto_ds, true);
  198. - if (ret)
  199. - return -1;
  200. - }
  201. -
  202. if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
  203. /* Send cmd to FW to enable/disable 11D function */
  204. state_11d = ENABLE_11D;
  205. --
  206. 2.26.0