Skip to content

Commit

Permalink
wlcore: add grace period when changing MR -> SR fw
Browse files Browse the repository at this point in the history
This improves user experience when performing p2p_find for instance.

Signed-off-by: Eliad Peller <eliad@wizery.com>
  • Loading branch information
elp committed Jul 29, 2012
1 parent 395625f commit 5016545
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
34 changes: 32 additions & 2 deletions drivers/net/wireless/ti/wlcore/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,7 @@ static void wlcore_op_stop_locked(struct wl1271 *wl)
mutex_unlock(&wl->mutex);

wlcore_synchronize_interrupts(wl);
cancel_delayed_work_sync(&wl->delayed_recovery);
if (!test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags))
cancel_work_sync(&wl->recovery_work);
wl1271_flush_deferred_work(wl);
Expand Down Expand Up @@ -2140,7 +2141,7 @@ enum fw_change_type {
* fw to another) is needed.
*/

static bool wl12xx_need_fw_change(struct wl1271 *wl)
static enum fw_change_type wl12xx_need_fw_change(struct wl1271 *wl)
{
enum wl12xx_fw_type current_fw = wl->fw_type;
u8 vif_count = ieee80211_started_vifs_count(wl->hw);
Expand Down Expand Up @@ -2180,14 +2181,42 @@ static void wl12xx_force_active_psm(struct wl1271 *wl)
static void wl12xx_change_fw_if_needed(struct wl1271 *wl)
{
enum fw_change_type change_type;
int timeout = 0;

cancel_delayed_work(&wl->delayed_recovery);

change_type = wl12xx_need_fw_change(wl);
if (change_type == FW_CHANGE_NONE)
return;

/* give some grace period in MR to SR case */
if (change_type == FW_CHANGE_MR_TO_SR)
timeout = 30000;

wl1271_debug(DEBUG_CMD, "queue delayed recovery in %d msecs", timeout);
ieee80211_queue_delayed_work(wl->hw, &wl->delayed_recovery,
msecs_to_jiffies(timeout));
return change_type == FW_CHANGE_SR_TO_MR;
}

void wl12xx_delayed_recovery_work(struct work_struct *work)
{
struct delayed_work *dwork;
struct wl1271 *wl;
enum fw_change_type change_type;

dwork = container_of(work, struct delayed_work, work);
wl = container_of(dwork, struct wl1271, delayed_recovery);

wl1271_debug(DEBUG_CMD, "delayed recovery");

/* check recovery is still needed. */
change_type = wl12xx_need_fw_change(wl);
if (change_type == FW_CHANGE_NONE)
return;

wl12xx_force_active_psm(wl);
set_bit(WL1271_FLAG_INTENDED_FW_RECOVERY, &wl->flags);
wl1271_debug(DEBUG_CMD, "queue recovery for fw switch");
wl12xx_queue_recovery_work(wl);
}

Expand Down Expand Up @@ -5370,6 +5399,7 @@ struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size)
INIT_WORK(&wl->netstack_work, wl1271_netstack_work);
INIT_WORK(&wl->tx_work, wl1271_tx_work);
INIT_WORK(&wl->recovery_work, wl1271_recovery_work);
INIT_DELAYED_WORK(&wl->delayed_recovery, wl12xx_delayed_recovery_work);
INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work);
INIT_DELAYED_WORK(&wl->tx_watchdog_work, wl12xx_tx_watchdog_work);
INIT_DELAYED_WORK(&wl->connection_loss_work,
Expand Down
8 changes: 8 additions & 0 deletions drivers/net/wireless/ti/wlcore/wlcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,14 @@ struct wl1271 {

/* Hardware recovery work */
struct work_struct recovery_work;

/*
* delayed recovery work - we use a separate work
* in order to prevent big changes. however, me
* may want to reconisder it...
*/
struct delayed_work delayed_recovery;

bool watchdog_recovery;

/* Pointer that holds DMA-friendly block for the mailbox */
Expand Down

0 comments on commit 5016545

Please sign in to comment.