Skip to content

Commit b512411

Browse files
kitakar5525qzed
authored andcommitted
Revert "wireless/mwifiex: Fix S0ix / suspend"
This reverts commit c8da40c. Reason for revert: This commit will be split into smaller commits to describe what each commit does. Currently, this commit does the following things within this one commit: a) modify mwifiex_pcie_suspend/mwifiex_pcie_resume functions to achieve S0ix without user unloading mwifiex module manually and also to fix "(sometimes) scanning for APs doesn't work after suspend" b) disable bridge_d3 to fix mwifiex module crashing after suspend c) disable "auto deep sleep" (auto_ds). auto_ds is reportedly causing "suspend/resume fails when not connected to an Access Point." Signed-off-by: Tsuchiya Yuto (kitakar5525) <kitakar@gmail.com> (corresponds to commit dd9a57a from PR #44) Signed-off-by: Tsuchiya Yuto (kitakar5525) <kitakar@gmail.com>
1 parent 374ab57 commit b512411

File tree

2 files changed

+48
-41
lines changed

2 files changed

+48
-41
lines changed

drivers/net/wireless/marvell/mwifiex/pcie.c

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -149,38 +149,35 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter)
149149
*/
150150
static int mwifiex_pcie_suspend(struct device *dev)
151151
{
152-
struct pci_dev *pdev = to_pci_dev(dev);
153-
struct pcie_service_card *card = pci_get_drvdata(pdev);
154152
struct mwifiex_adapter *adapter;
155-
struct mwifiex_private *priv;
156-
const struct mwifiex_pcie_card_reg *reg;
157-
u32 fw_status;
158-
int ret;
153+
struct pcie_service_card *card = dev_get_drvdata(dev);
154+
159155

160156
/* Might still be loading firmware */
161157
wait_for_completion(&card->fw_done);
162158

163159
adapter = card->adapter;
164-
if (!adapter || !adapter->priv_num)
160+
if (!adapter) {
161+
dev_err(dev, "adapter is not valid\n");
165162
return 0;
163+
}
166164

167-
reg = card->pcie.reg;
168-
if (reg)
169-
ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status);
170-
else
171-
fw_status = -1;
172-
173-
if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) {
174-
mwifiex_deauthenticate_all(adapter);
175-
176-
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
177-
178-
mwifiex_disable_auto_ds(priv);
165+
mwifiex_enable_wake(adapter);
179166

180-
mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN);
167+
/* Enable the Host Sleep */
168+
if (!mwifiex_enable_hs(adapter)) {
169+
mwifiex_dbg(adapter, ERROR,
170+
"cmd: failed to suspend\n");
171+
clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
172+
mwifiex_disable_wake(adapter);
173+
return -EFAULT;
181174
}
182175

183-
mwifiex_remove_card(adapter);
176+
flush_workqueue(adapter->workqueue);
177+
178+
/* Indicate device suspended */
179+
set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
180+
clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
184181

185182
return 0;
186183
}
@@ -195,29 +192,28 @@ static int mwifiex_pcie_suspend(struct device *dev)
195192
*/
196193
static int mwifiex_pcie_resume(struct device *dev)
197194
{
198-
struct pci_dev *pdev = to_pci_dev(dev);
199-
struct pcie_service_card *card = pci_get_drvdata(pdev);
200-
int ret;
195+
struct mwifiex_adapter *adapter;
196+
struct pcie_service_card *card = dev_get_drvdata(dev);
201197

202-
pr_debug("info: vendor=0x%4.04X device=0x%4.04X rev=%d\n",
203-
pdev->vendor, pdev->device, pdev->revision);
204198

205-
init_completion(&card->fw_done);
199+
if (!card->adapter) {
200+
dev_err(dev, "adapter structure is not valid\n");
201+
return 0;
202+
}
206203

207-
card->dev = pdev;
204+
adapter = card->adapter;
208205

209-
/* device tree node parsing and platform specific configuration */
210-
if (pdev->dev.of_node) {
211-
ret = mwifiex_pcie_probe_of(&pdev->dev);
212-
if (ret)
213-
return ret;
206+
if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
207+
mwifiex_dbg(adapter, WARN,
208+
"Device already resumed\n");
209+
return 0;
214210
}
215211

216-
if (mwifiex_add_card(card, &card->fw_done, &pcie_ops,
217-
MWIFIEX_PCIE, &pdev->dev)) {
218-
pr_err("%s failed\n", __func__);
219-
return -1;
220-
}
212+
clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
213+
214+
mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
215+
MWIFIEX_ASYNC_CMD);
216+
mwifiex_disable_wake(adapter);
221217

222218
return 0;
223219
}
@@ -271,8 +267,6 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
271267
return -1;
272268
}
273269

274-
pdev->bus->self->bridge_d3 = false;
275-
276270
return 0;
277271
}
278272

drivers/net/wireless/marvell/mwifiex/sta_cmd.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2265,13 +2265,14 @@ int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
22652265
int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
22662266
{
22672267
struct mwifiex_adapter *adapter = priv->adapter;
2268+
int ret;
22682269
struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
2270+
struct mwifiex_ds_auto_ds auto_ds;
22692271
enum state_11d_t state_11d;
22702272
struct mwifiex_ds_11n_tx_cfg tx_cfg;
22712273
u8 sdio_sp_rx_aggr_enable;
22722274
u16 packet_aggr_enable;
22732275
int data;
2274-
int ret;
22752276

22762277
if (first_sta) {
22772278
if (priv->adapter->iface_type == MWIFIEX_PCIE) {
@@ -2383,6 +2384,18 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta, bool init)
23832384
if (ret)
23842385
return -1;
23852386

2387+
if (!disable_auto_ds && first_sta &&
2388+
priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
2389+
/* Enable auto deep sleep */
2390+
auto_ds.auto_ds = DEEP_SLEEP_ON;
2391+
auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
2392+
ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
2393+
EN_AUTO_PS, BITMAP_AUTO_DS,
2394+
&auto_ds, true);
2395+
if (ret)
2396+
return -1;
2397+
}
2398+
23862399
if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
23872400
/* Send cmd to FW to enable/disable 11D function */
23882401
state_11d = ENABLE_11D;

0 commit comments

Comments
 (0)