Commit 99d84c1d authored by Luciano Coelho's avatar Luciano Coelho Committed by John W. Linville

wl1271: wait for join command complete event

Poll for join command completion instead of waiting blindly for 10 msecs.
There is a timeout of 100 msecs, if the command doesn't complete by then, we
return an error code.
Signed-off-by: default avatarLuciano Coelho <luciano.coelho@nokia.com>
Reviewed-by: default avatarJuuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9560134f
...@@ -410,7 +410,8 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl) ...@@ -410,7 +410,8 @@ static int wl1271_boot_run_firmware(struct wl1271 *wl)
/* unmask required mbox events */ /* unmask required mbox events */
wl->event_mask = BSS_LOSE_EVENT_ID | wl->event_mask = BSS_LOSE_EVENT_ID |
SCAN_COMPLETE_EVENT_ID | SCAN_COMPLETE_EVENT_ID |
PS_REPORT_EVENT_ID; PS_REPORT_EVENT_ID |
JOIN_EVENT_COMPLETE_ID;
ret = wl1271_event_unmask(wl); ret = wl1271_event_unmask(wl);
if (ret < 0) { if (ret < 0) {
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "wl1271_acx.h" #include "wl1271_acx.h"
#include "wl12xx_80211.h" #include "wl12xx_80211.h"
#include "wl1271_cmd.h" #include "wl1271_cmd.h"
#include "wl1271_event.h"
/* /*
* send command to firmware * send command to firmware
...@@ -248,6 +249,35 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl) ...@@ -248,6 +249,35 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl)
return ret; return ret;
} }
/*
* Poll the mailbox event field until any of the bits in the mask is set or a
* timeout occurs (WL1271_EVENT_TIMEOUT in msecs)
*/
static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask)
{
u32 events_vector, event;
unsigned long timeout;
timeout = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
do {
if (time_after(jiffies, timeout))
return -ETIMEDOUT;
msleep(1);
/* read from both event fields */
wl1271_read(wl, wl->mbox_ptr[0], &events_vector,
sizeof(events_vector), false);
event = events_vector & mask;
wl1271_read(wl, wl->mbox_ptr[1], &events_vector,
sizeof(events_vector), false);
event |= events_vector & mask;
} while (!event);
return 0;
}
int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type) int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
{ {
static bool do_cal = true; static bool do_cal = true;
...@@ -318,11 +348,9 @@ int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type) ...@@ -318,11 +348,9 @@ int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type)
goto out_free; goto out_free;
} }
/* ret = wl1271_cmd_wait_for_event(wl, JOIN_EVENT_COMPLETE_ID);
* ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to if (ret < 0)
* simplify locking we just sleep instead, for now wl1271_error("cmd join event completion error");
*/
msleep(10);
out_free: out_free:
kfree(join); kfree(join);
......
...@@ -123,6 +123,7 @@ enum cmd_templ { ...@@ -123,6 +123,7 @@ enum cmd_templ {
/* unit ms */ /* unit ms */
#define WL1271_COMMAND_TIMEOUT 2000 #define WL1271_COMMAND_TIMEOUT 2000
#define WL1271_CMD_TEMPL_MAX_SIZE 252 #define WL1271_CMD_TEMPL_MAX_SIZE 252
#define WL1271_EVENT_TIMEOUT 100
struct wl1271_cmd_header { struct wl1271_cmd_header {
__le16 id; __le16 id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment