Skip to content

Commit

Permalink
mwl8787: add a completion for firmware load callback
Browse files Browse the repository at this point in the history
If the firmware loader callback is queued before suspend
but invoked on resume, we will try to set up the card even
though some things like the mmc controller may not be there
anymore.  This can cause a crash or warnings like the one
below.  Wait for the callback before leaving remove().

Fixes:
[  112.506713] ------------[ cut here ]------------
[  112.514282] WARNING: at lib/kobject.c:196 kobject_add_internal+0x1c4/0x230()
[  112.523956] kobject_add_internal failed for phy1 with -EEXIST, don't try to register things with the same name in the same directory.
[  112.536621] Modules linked in: arc4 mwl8787_sdio mac80211 cfg80211
[  112.541351] CPU: 0 PID: 4 Comm: kworker/0:0 Tainted: G        W    3.10.0 #38
[  112.550781] Workqueue: events request_firmware_work_func
[  112.551239] [<c001b4b4>] (unwind_backtrace+0x0/0x130) from [<c0017b7c>] (show_stack+0x10/0x14)
[  112.565490] [<c0017b7c>] (show_stack+0x10/0x14) from [<c0043890>] (warn_slowpath_common+0x4c/0x68)
[  112.575012] [<c0043890>] (warn_slowpath_common+0x4c/0x68) from [<c0043940>] (warn_slowpath_fmt+0x30/0x40)
[  112.585144] [<c0043940>] (warn_slowpath_fmt+0x30/0x40) from [<c02b7ad4>] (kobject_add_internal+0x1c4/0x230)
[  112.595458] [<c02b7ad4>] (kobject_add_internal+0x1c4/0x230) from [<c02b7d6c>] (kobject_add+0x50/0x98)
[  112.605194] [<c02b7d6c>] (kobject_add+0x50/0x98) from [<c03254f8>] (device_add+0xcc/0x5c4)
[  112.614105] [<c03254f8>] (device_add+0xcc/0x5c4) from [<bf000920>] (wiphy_register+0x408/0x67c [cfg80211])
[  112.624572] [<bf000920>] (wiphy_register+0x408/0x67c [cfg80211]) from [<bf08e55c>] (ieee80211_register_hw+0x3c4/0x810 [mac80211])
[  112.637084] [<bf08e55c>] (ieee80211_register_hw+0x3c4/0x810 [mac80211]) from [<bf144df0>] (mwl8787_register+0x10/0x38 [mwl8787_sdio])
[  112.649810] [<bf144df0>] (mwl8787_register+0x10/0x38 [mwl8787_sdio]) from [<bf146fd8>] (mwl8787_fw_cb+0x64/0x84 [mwl8787_sdio])
[  112.661926] [<bf146fd8>] (mwl8787_fw_cb+0x64/0x84 [mwl8787_sdio]) from [<c0335da8>] (request_firmware_work_func+0x40/0x64)
[  112.673645] [<c0335da8>] (request_firmware_work_func+0x40/0x64) from [<c005f4b0>] (process_one_work+0x1ac/0x4c8)
[  112.684417] [<c005f4b0>] (process_one_work+0x1ac/0x4c8) from [<c005fc0c>] (worker_thread+0x144/0x3ac)
[  112.694152] [<c005fc0c>] (worker_thread+0x144/0x3ac) from [<c0065b6c>] (kthread+0xa4/0xb0)
[  112.702880] [<c0065b6c>] (kthread+0xa4/0xb0) from [<c0013c28>] (ret_from_fork+0x14/0x2c)
[  112.704925] ---[ end trace 92baea39fd3e9318 ]---

Signed-off-by: Bob Copeland <me@bobcopeland.com>
  • Loading branch information
bcopeland committed Oct 2, 2013
1 parent 5827561 commit 18b0db7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/net/wireless/mwl8787/mwl8787.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct mwl8787_priv
void *bus_priv;
int bus_headroom;

struct completion fw_done; /* completed when firmware loaded */
struct completion init_wait;

enum mwl8787_hw_status hw_status;
Expand Down
11 changes: 10 additions & 1 deletion drivers/net/wireless/mwl8787/sdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,8 @@ static void mwl8787_fw_cb(const struct firmware *fw, void *context)
disable:
/* FIXME unbind device */
release_firmware(fw);
return;

complete(&priv->fw_done);
}

static int mwl8787_sdio_probe(struct sdio_func *func,
Expand Down Expand Up @@ -1224,6 +1225,7 @@ static int mwl8787_sdio_probe(struct sdio_func *func,
if (ret)
goto disable;

init_completion(&priv->fw_done);
ret = request_firmware_nowait(THIS_MODULE, 1, MWL8787_FW_NAME,
priv->dev, GFP_KERNEL, priv,
mwl8787_fw_cb);
Expand All @@ -1246,6 +1248,13 @@ static void mwl8787_sdio_remove(struct sdio_func *func)
{
struct mwl8787_priv *priv = sdio_get_drvdata(func);

/*
* must wait for firmware to be done to avoid mwl8787_fw_cb()
* getting called after remove(), which will crash when sdio
* bus is accessed.
*/
wait_for_completion(&priv->fw_done);

if (priv->registered)
mwl8787_unregister(priv);

Expand Down

0 comments on commit 18b0db7

Please sign in to comment.