Skip to content

Commit

Permalink
mwifiex: resolve suspend() race with async FW init failure
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Norris <briannorris@chromium.org>
Tested-by: Xinming Hu <huxm@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  • Loading branch information
Brian Norris authored and Kalle Valo committed Nov 19, 2016
1 parent 7ccdf72 commit b42dbb2
Showing 3 changed files with 30 additions and 6 deletions.
12 changes: 10 additions & 2 deletions drivers/net/wireless/marvell/mwifiex/pcie.c
Original file line number Diff line number Diff line change
@@ -118,12 +118,20 @@ static int mwifiex_pcie_suspend(struct device *dev)
struct pci_dev *pdev = to_pci_dev(dev);

card = pci_get_drvdata(pdev);
if (!card || !card->adapter) {
pr_err("Card or adapter structure is not valid\n");
if (!card) {
dev_err(dev, "card structure is not valid\n");
return 0;
}

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

adapter = card->adapter;
if (!adapter) {
dev_err(dev, "adapter is not valid\n");
return 0;
}

mwifiex_enable_wake(adapter);

/* Enable the Host Sleep */
12 changes: 10 additions & 2 deletions drivers/net/wireless/marvell/mwifiex/sdio.c
Original file line number Diff line number Diff line change
@@ -283,16 +283,24 @@ static int mwifiex_sdio_suspend(struct device *dev)
}

card = sdio_get_drvdata(func);
if (!card || !card->adapter) {
pr_err("suspend: invalid card or adapter\n");
if (!card) {
dev_err(dev, "suspend: invalid card\n");
return 0;
}
} else {
pr_err("suspend: sdio_func is not specified\n");
return 0;
}

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

adapter = card->adapter;
if (!adapter) {
dev_err(dev, "adapter is not valid\n");
return 0;
}

mwifiex_enable_wake(adapter);

/* Enable the Host Sleep */
12 changes: 10 additions & 2 deletions drivers/net/wireless/marvell/mwifiex/usb.c
Original file line number Diff line number Diff line change
@@ -503,11 +503,19 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message)
struct usb_tx_data_port *port;
int i, j;

if (!card || !card->adapter) {
pr_err("%s: card or card->adapter is NULL\n", __func__);
if (!card) {
dev_err(&intf->dev, "%s: card is NULL\n", __func__);
return 0;
}

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

adapter = card->adapter;
if (!adapter) {
dev_err(&intf->dev, "card is not valid\n");
return 0;
}

if (unlikely(adapter->is_suspended))
mwifiex_dbg(adapter, WARN,

0 comments on commit b42dbb2

Please sign in to comment.