Commit fc3a2fca authored by Ganapathi Bhat's avatar Ganapathi Bhat Committed by Kalle Valo

mwifiex: use atomic bitops to represent adapter status variables

Driver is using boolean variables to maintain vairous status
information of adapter. These status variables are accessed by
multiple threads and there is a possibility of a race. To avoid
this, convert these variables to a set of bitops flags, to be
operated atomically.

Below variables of mwifiex_adapter are converted to bitop flags:
surprise_removed
is_cmd_timedout
is_suspended
is_hs_configured
hs_enabling
Signed-off-by: default avatarGanapathi Bhat <gbhat@marvell.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 5188d545
...@@ -2322,7 +2322,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, ...@@ -2322,7 +2322,8 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev,
if (priv->scan_block) if (priv->scan_block)
priv->scan_block = false; priv->scan_block = false;
if (adapter->surprise_removed || adapter->is_cmd_timedout) { if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags) ||
test_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"%s: Ignore connection.\t" "%s: Ignore connection.\t"
"Card removed or FW in bad state\n", "Card removed or FW in bad state\n",
......
...@@ -372,7 +372,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) ...@@ -372,7 +372,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter)
adapter->ps_state = PS_STATE_SLEEP_CFM; adapter->ps_state = PS_STATE_SLEEP_CFM;
if (!le16_to_cpu(sleep_cfm_buf->resp_ctrl) && if (!le16_to_cpu(sleep_cfm_buf->resp_ctrl) &&
(adapter->is_hs_configured && (test_bit(MWIFIEX_IS_HS_CONFIGURED, &adapter->work_flags) &&
!adapter->sleep_period.period)) { !adapter->sleep_period.period)) {
adapter->pm_wakeup_card_req = true; adapter->pm_wakeup_card_req = true;
mwifiex_hs_activated_event(mwifiex_get_priv mwifiex_hs_activated_event(mwifiex_get_priv
...@@ -564,25 +564,26 @@ int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no, ...@@ -564,25 +564,26 @@ int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
return -1; return -1;
} }
if (adapter->is_suspended) { if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"PREP_CMD: device in suspended state\n"); "PREP_CMD: device in suspended state\n");
return -1; return -1;
} }
if (adapter->hs_enabling && cmd_no != HostCmd_CMD_802_11_HS_CFG_ENH) { if (test_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags) &&
cmd_no != HostCmd_CMD_802_11_HS_CFG_ENH) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"PREP_CMD: host entering sleep state\n"); "PREP_CMD: host entering sleep state\n");
return -1; return -1;
} }
if (adapter->surprise_removed) { if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"PREP_CMD: card is removed\n"); "PREP_CMD: card is removed\n");
return -1; return -1;
} }
if (adapter->is_cmd_timedout) { if (test_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"PREP_CMD: FW is in bad state\n"); "PREP_CMD: FW is in bad state\n");
return -1; return -1;
...@@ -789,7 +790,8 @@ int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter) ...@@ -789,7 +790,8 @@ int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter)
if (priv && (host_cmd->command != if (priv && (host_cmd->command !=
cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH))) { cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH))) {
if (adapter->hs_activated) { if (adapter->hs_activated) {
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags);
mwifiex_hs_activated_event(priv, false); mwifiex_hs_activated_event(priv, false);
} }
} }
...@@ -825,7 +827,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter) ...@@ -825,7 +827,7 @@ int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
return -1; return -1;
} }
adapter->is_cmd_timedout = 0; clear_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags);
resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data; resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data;
if (adapter->curr_cmd->cmd_flag & CMD_F_HOSTCMD) { if (adapter->curr_cmd->cmd_flag & CMD_F_HOSTCMD) {
...@@ -927,7 +929,7 @@ mwifiex_cmd_timeout_func(struct timer_list *t) ...@@ -927,7 +929,7 @@ mwifiex_cmd_timeout_func(struct timer_list *t)
struct mwifiex_adapter *adapter = from_timer(adapter, t, cmd_timer); struct mwifiex_adapter *adapter = from_timer(adapter, t, cmd_timer);
struct cmd_ctrl_node *cmd_node; struct cmd_ctrl_node *cmd_node;
adapter->is_cmd_timedout = 1; set_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags);
if (!adapter->curr_cmd) { if (!adapter->curr_cmd) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"cmd: empty curr_cmd\n"); "cmd: empty curr_cmd\n");
...@@ -953,7 +955,8 @@ mwifiex_cmd_timeout_func(struct timer_list *t) ...@@ -953,7 +955,8 @@ mwifiex_cmd_timeout_func(struct timer_list *t)
mwifiex_dbg(adapter, MSG, mwifiex_dbg(adapter, MSG,
"is_cmd_timedout = %d\n", "is_cmd_timedout = %d\n",
adapter->is_cmd_timedout); test_bit(MWIFIEX_IS_CMD_TIMEDOUT,
&adapter->work_flags));
mwifiex_dbg(adapter, MSG, mwifiex_dbg(adapter, MSG,
"num_tx_timeout = %d\n", "num_tx_timeout = %d\n",
adapter->dbg.num_tx_timeout); adapter->dbg.num_tx_timeout);
...@@ -1135,7 +1138,8 @@ void ...@@ -1135,7 +1138,8 @@ void
mwifiex_hs_activated_event(struct mwifiex_private *priv, u8 activated) mwifiex_hs_activated_event(struct mwifiex_private *priv, u8 activated)
{ {
if (activated) { if (activated) {
if (priv->adapter->is_hs_configured) { if (test_bit(MWIFIEX_IS_HS_CONFIGURED,
&priv->adapter->work_flags)) {
priv->adapter->hs_activated = true; priv->adapter->hs_activated = true;
mwifiex_update_rxreor_flags(priv->adapter, mwifiex_update_rxreor_flags(priv->adapter,
RXREOR_FORCE_NO_DROP); RXREOR_FORCE_NO_DROP);
...@@ -1186,11 +1190,11 @@ int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv, ...@@ -1186,11 +1190,11 @@ int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
phs_cfg->params.hs_config.gap); phs_cfg->params.hs_config.gap);
} }
if (conditions != HS_CFG_CANCEL) { if (conditions != HS_CFG_CANCEL) {
adapter->is_hs_configured = true; set_bit(MWIFIEX_IS_HS_CONFIGURED, &adapter->work_flags);
if (adapter->iface_type == MWIFIEX_USB) if (adapter->iface_type == MWIFIEX_USB)
mwifiex_hs_activated_event(priv, true); mwifiex_hs_activated_event(priv, true);
} else { } else {
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED, &adapter->work_flags);
if (adapter->hs_activated) if (adapter->hs_activated)
mwifiex_hs_activated_event(priv, false); mwifiex_hs_activated_event(priv, false);
} }
...@@ -1212,8 +1216,8 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter) ...@@ -1212,8 +1216,8 @@ mwifiex_process_hs_config(struct mwifiex_adapter *adapter)
adapter->if_ops.wakeup(adapter); adapter->if_ops.wakeup(adapter);
adapter->hs_activated = false; adapter->hs_activated = false;
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED, &adapter->work_flags);
adapter->is_suspended = false; clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
mwifiex_hs_activated_event(mwifiex_get_priv(adapter, mwifiex_hs_activated_event(mwifiex_get_priv(adapter,
MWIFIEX_BSS_ROLE_ANY), MWIFIEX_BSS_ROLE_ANY),
false); false);
...@@ -1273,7 +1277,7 @@ mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *adapter, ...@@ -1273,7 +1277,7 @@ mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *adapter,
return; return;
} }
adapter->pm_wakeup_card_req = true; adapter->pm_wakeup_card_req = true;
if (adapter->is_hs_configured) if (test_bit(MWIFIEX_IS_HS_CONFIGURED, &adapter->work_flags))
mwifiex_hs_activated_event(mwifiex_get_priv mwifiex_hs_activated_event(mwifiex_get_priv
(adapter, MWIFIEX_BSS_ROLE_ANY), (adapter, MWIFIEX_BSS_ROLE_ANY),
true); true);
......
...@@ -813,7 +813,7 @@ mwifiex_hscfg_write(struct file *file, const char __user *ubuf, ...@@ -813,7 +813,7 @@ mwifiex_hscfg_write(struct file *file, const char __user *ubuf,
MWIFIEX_SYNC_CMD, &hscfg); MWIFIEX_SYNC_CMD, &hscfg);
mwifiex_enable_hs(priv->adapter); mwifiex_enable_hs(priv->adapter);
priv->adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &priv->adapter->work_flags);
ret = count; ret = count;
done: done:
kfree(buf); kfree(buf);
......
...@@ -233,7 +233,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) ...@@ -233,7 +233,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
adapter->event_received = false; adapter->event_received = false;
adapter->data_received = false; adapter->data_received = false;
adapter->surprise_removed = false; clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
...@@ -270,7 +270,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) ...@@ -270,7 +270,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter)
adapter->curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K; adapter->curr_tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K;
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED, &adapter->work_flags);
adapter->hs_cfg.conditions = cpu_to_le32(HS_CFG_COND_DEF); adapter->hs_cfg.conditions = cpu_to_le32(HS_CFG_COND_DEF);
adapter->hs_cfg.gpio = HS_CFG_GPIO_DEF; adapter->hs_cfg.gpio = HS_CFG_GPIO_DEF;
adapter->hs_cfg.gap = HS_CFG_GAP_DEF; adapter->hs_cfg.gap = HS_CFG_GAP_DEF;
......
...@@ -404,7 +404,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -404,7 +404,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
!skb_queue_empty(&adapter->tx_data_q)) { !skb_queue_empty(&adapter->tx_data_q)) {
mwifiex_process_tx_queue(adapter); mwifiex_process_tx_queue(adapter);
if (adapter->hs_activated) { if (adapter->hs_activated) {
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags);
mwifiex_hs_activated_event mwifiex_hs_activated_event
(mwifiex_get_priv (mwifiex_get_priv
(adapter, MWIFIEX_BSS_ROLE_ANY), (adapter, MWIFIEX_BSS_ROLE_ANY),
...@@ -420,7 +421,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -420,7 +421,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) {
mwifiex_process_bypass_tx(adapter); mwifiex_process_bypass_tx(adapter);
if (adapter->hs_activated) { if (adapter->hs_activated) {
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags);
mwifiex_hs_activated_event mwifiex_hs_activated_event
(mwifiex_get_priv (mwifiex_get_priv
(adapter, MWIFIEX_BSS_ROLE_ANY), (adapter, MWIFIEX_BSS_ROLE_ANY),
...@@ -435,7 +437,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter) ...@@ -435,7 +437,8 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) {
mwifiex_wmm_process_tx(adapter); mwifiex_wmm_process_tx(adapter);
if (adapter->hs_activated) { if (adapter->hs_activated) {
adapter->is_hs_configured = false; clear_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags);
mwifiex_hs_activated_event mwifiex_hs_activated_event
(mwifiex_get_priv (mwifiex_get_priv
(adapter, MWIFIEX_BSS_ROLE_ANY), (adapter, MWIFIEX_BSS_ROLE_ANY),
...@@ -647,7 +650,7 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context) ...@@ -647,7 +650,7 @@ static int _mwifiex_fw_dpc(const struct firmware *firmware, void *context)
if (adapter->if_ops.unregister_dev) if (adapter->if_ops.unregister_dev)
adapter->if_ops.unregister_dev(adapter); adapter->if_ops.unregister_dev(adapter);
adapter->surprise_removed = true; set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
mwifiex_terminate_workqueue(adapter); mwifiex_terminate_workqueue(adapter);
if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
...@@ -870,7 +873,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -870,7 +873,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
"data: %lu BSS(%d-%d): Data <= kernel\n", "data: %lu BSS(%d-%d): Data <= kernel\n",
jiffies, priv->bss_type, priv->bss_num); jiffies, priv->bss_type, priv->bss_num);
if (priv->adapter->surprise_removed) { if (test_bit(MWIFIEX_SURPRISE_REMOVED, &priv->adapter->work_flags)) {
kfree_skb(skb); kfree_skb(skb);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
return 0; return 0;
...@@ -1372,7 +1375,7 @@ static void mwifiex_rx_work_queue(struct work_struct *work) ...@@ -1372,7 +1375,7 @@ static void mwifiex_rx_work_queue(struct work_struct *work)
struct mwifiex_adapter *adapter = struct mwifiex_adapter *adapter =
container_of(work, struct mwifiex_adapter, rx_work); container_of(work, struct mwifiex_adapter, rx_work);
if (adapter->surprise_removed) if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags))
return; return;
mwifiex_process_rx(adapter); mwifiex_process_rx(adapter);
} }
...@@ -1388,7 +1391,7 @@ static void mwifiex_main_work_queue(struct work_struct *work) ...@@ -1388,7 +1391,7 @@ static void mwifiex_main_work_queue(struct work_struct *work)
struct mwifiex_adapter *adapter = struct mwifiex_adapter *adapter =
container_of(work, struct mwifiex_adapter, main_work); container_of(work, struct mwifiex_adapter, main_work);
if (adapter->surprise_removed) if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags))
return; return;
mwifiex_main_process(adapter); mwifiex_main_process(adapter);
} }
...@@ -1405,7 +1408,7 @@ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) ...@@ -1405,7 +1408,7 @@ static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter)
if (adapter->if_ops.disable_int) if (adapter->if_ops.disable_int)
adapter->if_ops.disable_int(adapter); adapter->if_ops.disable_int(adapter);
adapter->surprise_removed = true; set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
mwifiex_terminate_workqueue(adapter); mwifiex_terminate_workqueue(adapter);
adapter->int_status = 0; adapter->int_status = 0;
...@@ -1493,11 +1496,11 @@ mwifiex_reinit_sw(struct mwifiex_adapter *adapter) ...@@ -1493,11 +1496,11 @@ mwifiex_reinit_sw(struct mwifiex_adapter *adapter)
adapter->if_ops.up_dev(adapter); adapter->if_ops.up_dev(adapter);
adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
adapter->surprise_removed = false; clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
init_waitqueue_head(&adapter->init_wait_q); init_waitqueue_head(&adapter->init_wait_q);
adapter->is_suspended = false; clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
adapter->hs_activated = false; adapter->hs_activated = false;
adapter->is_cmd_timedout = 0; clear_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags);
init_waitqueue_head(&adapter->hs_activate_wait_q); init_waitqueue_head(&adapter->hs_activate_wait_q);
init_waitqueue_head(&adapter->cmd_wait_q.wait); init_waitqueue_head(&adapter->cmd_wait_q.wait);
adapter->cmd_wait_q.status = 0; adapter->cmd_wait_q.status = 0;
...@@ -1552,7 +1555,7 @@ mwifiex_reinit_sw(struct mwifiex_adapter *adapter) ...@@ -1552,7 +1555,7 @@ mwifiex_reinit_sw(struct mwifiex_adapter *adapter)
adapter->if_ops.unregister_dev(adapter); adapter->if_ops.unregister_dev(adapter);
err_kmalloc: err_kmalloc:
adapter->surprise_removed = true; set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
mwifiex_terminate_workqueue(adapter); mwifiex_terminate_workqueue(adapter);
if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
...@@ -1649,9 +1652,9 @@ mwifiex_add_card(void *card, struct completion *fw_done, ...@@ -1649,9 +1652,9 @@ mwifiex_add_card(void *card, struct completion *fw_done,
adapter->fw_done = fw_done; adapter->fw_done = fw_done;
adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
adapter->surprise_removed = false; clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
init_waitqueue_head(&adapter->init_wait_q); init_waitqueue_head(&adapter->init_wait_q);
adapter->is_suspended = false; clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
adapter->hs_activated = false; adapter->hs_activated = false;
init_waitqueue_head(&adapter->hs_activate_wait_q); init_waitqueue_head(&adapter->hs_activate_wait_q);
init_waitqueue_head(&adapter->cmd_wait_q.wait); init_waitqueue_head(&adapter->cmd_wait_q.wait);
...@@ -1699,7 +1702,7 @@ mwifiex_add_card(void *card, struct completion *fw_done, ...@@ -1699,7 +1702,7 @@ mwifiex_add_card(void *card, struct completion *fw_done,
if (adapter->if_ops.unregister_dev) if (adapter->if_ops.unregister_dev)
adapter->if_ops.unregister_dev(adapter); adapter->if_ops.unregister_dev(adapter);
err_registerdev: err_registerdev:
adapter->surprise_removed = true; set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
mwifiex_terminate_workqueue(adapter); mwifiex_terminate_workqueue(adapter);
if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
pr_debug("info: %s: shutdown mwifiex\n", __func__); pr_debug("info: %s: shutdown mwifiex\n", __func__);
......
...@@ -517,6 +517,14 @@ enum mwifiex_iface_work_flags { ...@@ -517,6 +517,14 @@ enum mwifiex_iface_work_flags {
MWIFIEX_IFACE_WORK_CARD_RESET, MWIFIEX_IFACE_WORK_CARD_RESET,
}; };
enum mwifiex_adapter_work_flags {
MWIFIEX_SURPRISE_REMOVED,
MWIFIEX_IS_CMD_TIMEDOUT,
MWIFIEX_IS_SUSPENDED,
MWIFIEX_IS_HS_CONFIGURED,
MWIFIEX_IS_HS_ENABLING,
};
struct mwifiex_band_config { struct mwifiex_band_config {
u8 chan_band:2; u8 chan_band:2;
u8 chan_width:2; u8 chan_width:2;
...@@ -872,7 +880,7 @@ struct mwifiex_adapter { ...@@ -872,7 +880,7 @@ struct mwifiex_adapter {
struct device *dev; struct device *dev;
struct wiphy *wiphy; struct wiphy *wiphy;
u8 perm_addr[ETH_ALEN]; u8 perm_addr[ETH_ALEN];
bool surprise_removed; unsigned long work_flags;
u32 fw_release_number; u32 fw_release_number;
u8 intf_hdr_len; u8 intf_hdr_len;
u16 init_wait_q_woken; u16 init_wait_q_woken;
...@@ -926,7 +934,6 @@ struct mwifiex_adapter { ...@@ -926,7 +934,6 @@ struct mwifiex_adapter {
struct cmd_ctrl_node *curr_cmd; struct cmd_ctrl_node *curr_cmd;
/* spin lock for command */ /* spin lock for command */
spinlock_t mwifiex_cmd_lock; spinlock_t mwifiex_cmd_lock;
u8 is_cmd_timedout;
u16 last_init_cmd; u16 last_init_cmd;
struct timer_list cmd_timer; struct timer_list cmd_timer;
struct list_head cmd_free_q; struct list_head cmd_free_q;
...@@ -976,13 +983,10 @@ struct mwifiex_adapter { ...@@ -976,13 +983,10 @@ struct mwifiex_adapter {
u16 pps_uapsd_mode; u16 pps_uapsd_mode;
u32 pm_wakeup_fw_try; u32 pm_wakeup_fw_try;
struct timer_list wakeup_timer; struct timer_list wakeup_timer;
u8 is_hs_configured;
struct mwifiex_hs_config_param hs_cfg; struct mwifiex_hs_config_param hs_cfg;
u8 hs_activated; u8 hs_activated;
u16 hs_activate_wait_q_woken; u16 hs_activate_wait_q_woken;
wait_queue_head_t hs_activate_wait_q; wait_queue_head_t hs_activate_wait_q;
bool is_suspended;
bool hs_enabling;
u8 event_body[MAX_EVENT_SIZE]; u8 event_body[MAX_EVENT_SIZE];
u32 hw_dot_11n_dev_cap; u32 hw_dot_11n_dev_cap;
u8 hw_dev_mcs_support; u8 hw_dev_mcs_support;
......
...@@ -170,7 +170,7 @@ static int mwifiex_pcie_suspend(struct device *dev) ...@@ -170,7 +170,7 @@ static int mwifiex_pcie_suspend(struct device *dev)
if (!mwifiex_enable_hs(adapter)) { if (!mwifiex_enable_hs(adapter)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"cmd: failed to suspend\n"); "cmd: failed to suspend\n");
adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
mwifiex_disable_wake(adapter); mwifiex_disable_wake(adapter);
return -EFAULT; return -EFAULT;
} }
...@@ -178,8 +178,8 @@ static int mwifiex_pcie_suspend(struct device *dev) ...@@ -178,8 +178,8 @@ static int mwifiex_pcie_suspend(struct device *dev)
flush_workqueue(adapter->workqueue); flush_workqueue(adapter->workqueue);
/* Indicate device suspended */ /* Indicate device suspended */
adapter->is_suspended = true; set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
return 0; return 0;
} }
...@@ -207,13 +207,13 @@ static int mwifiex_pcie_resume(struct device *dev) ...@@ -207,13 +207,13 @@ static int mwifiex_pcie_resume(struct device *dev)
adapter = card->adapter; adapter = card->adapter;
if (!adapter->is_suspended) { if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, WARN, mwifiex_dbg(adapter, WARN,
"Device already resumed\n"); "Device already resumed\n");
return 0; return 0;
} }
adapter->is_suspended = false; clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
MWIFIEX_ASYNC_CMD); MWIFIEX_ASYNC_CMD);
...@@ -2430,7 +2430,7 @@ static irqreturn_t mwifiex_pcie_interrupt(int irq, void *context) ...@@ -2430,7 +2430,7 @@ static irqreturn_t mwifiex_pcie_interrupt(int irq, void *context)
} }
adapter = card->adapter; adapter = card->adapter;
if (adapter->surprise_removed) if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags))
goto exit; goto exit;
if (card->msix_enable) if (card->msix_enable)
......
...@@ -1495,7 +1495,8 @@ int mwifiex_scan_networks(struct mwifiex_private *priv, ...@@ -1495,7 +1495,8 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
return -EBUSY; return -EBUSY;
} }
if (adapter->surprise_removed || adapter->is_cmd_timedout) { if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags) ||
test_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"Ignore scan. Card removed or firmware in bad state\n"); "Ignore scan. Card removed or firmware in bad state\n");
return -EFAULT; return -EFAULT;
......
...@@ -181,13 +181,13 @@ static int mwifiex_sdio_resume(struct device *dev) ...@@ -181,13 +181,13 @@ static int mwifiex_sdio_resume(struct device *dev)
adapter = card->adapter; adapter = card->adapter;
if (!adapter->is_suspended) { if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, WARN, mwifiex_dbg(adapter, WARN,
"device already resumed\n"); "device already resumed\n");
return 0; return 0;
} }
adapter->is_suspended = false; clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
/* Disable Host Sleep */ /* Disable Host Sleep */
mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
...@@ -260,7 +260,7 @@ mwifiex_write_data_sync(struct mwifiex_adapter *adapter, ...@@ -260,7 +260,7 @@ mwifiex_write_data_sync(struct mwifiex_adapter *adapter,
MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len; MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len;
u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK); u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK);
if (adapter->is_suspended) { if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"%s: not allowed while suspended\n", __func__); "%s: not allowed while suspended\n", __func__);
return -1; return -1;
...@@ -450,7 +450,7 @@ static int mwifiex_sdio_suspend(struct device *dev) ...@@ -450,7 +450,7 @@ static int mwifiex_sdio_suspend(struct device *dev)
if (!mwifiex_enable_hs(adapter)) { if (!mwifiex_enable_hs(adapter)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"cmd: failed to suspend\n"); "cmd: failed to suspend\n");
adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
mwifiex_disable_wake(adapter); mwifiex_disable_wake(adapter);
return -EFAULT; return -EFAULT;
} }
...@@ -460,8 +460,8 @@ static int mwifiex_sdio_suspend(struct device *dev) ...@@ -460,8 +460,8 @@ static int mwifiex_sdio_suspend(struct device *dev)
ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
/* Indicate device suspended */ /* Indicate device suspended */
adapter->is_suspended = true; set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
return ret; return ret;
} }
......
...@@ -224,7 +224,8 @@ void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code, ...@@ -224,7 +224,8 @@ void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code,
adapter->tx_lock_flag = false; adapter->tx_lock_flag = false;
adapter->pps_uapsd_mode = false; adapter->pps_uapsd_mode = false;
if (adapter->is_cmd_timedout && adapter->curr_cmd) if (test_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags) &&
adapter->curr_cmd)
return; return;
priv->media_connected = false; priv->media_connected = false;
mwifiex_dbg(adapter, MSG, mwifiex_dbg(adapter, MSG,
......
...@@ -419,7 +419,8 @@ int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action, ...@@ -419,7 +419,8 @@ int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
} }
if (hs_cfg->is_invoke_hostcmd) { if (hs_cfg->is_invoke_hostcmd) {
if (hs_cfg->conditions == HS_CFG_CANCEL) { if (hs_cfg->conditions == HS_CFG_CANCEL) {
if (!adapter->is_hs_configured) if (!test_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags))
/* Already cancelled */ /* Already cancelled */
break; break;
/* Save previous condition */ /* Save previous condition */
...@@ -535,7 +536,7 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter) ...@@ -535,7 +536,7 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
memset(&hscfg, 0, sizeof(hscfg)); memset(&hscfg, 0, sizeof(hscfg));
hscfg.is_invoke_hostcmd = true; hscfg.is_invoke_hostcmd = true;
adapter->hs_enabling = true; set_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
mwifiex_cancel_all_pending_cmd(adapter); mwifiex_cancel_all_pending_cmd(adapter);
if (mwifiex_set_hs_params(mwifiex_get_priv(adapter, if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
...@@ -601,7 +602,8 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv, ...@@ -601,7 +602,8 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
else else
info->wep_status = false; info->wep_status = false;
info->is_hs_configured = adapter->is_hs_configured; info->is_hs_configured = test_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags);
info->is_deep_sleep = adapter->is_deep_sleep; info->is_deep_sleep = adapter->is_deep_sleep;
return 0; return 0;
......
...@@ -143,7 +143,7 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags) ...@@ -143,7 +143,7 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags)
int ret; int ret;
struct mwifiex_txinfo *tx_info = NULL; struct mwifiex_txinfo *tx_info = NULL;
if (adapter->surprise_removed) if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags))
return -1; return -1;
if (!priv->media_connected) if (!priv->media_connected)
......
...@@ -181,7 +181,8 @@ static void mwifiex_usb_rx_complete(struct urb *urb) ...@@ -181,7 +181,8 @@ static void mwifiex_usb_rx_complete(struct urb *urb)
atomic_dec(&card->rx_data_urb_pending); atomic_dec(&card->rx_data_urb_pending);
if (recv_length) { if (recv_length) {
if (urb->status || (adapter->surprise_removed)) { if (urb->status ||
test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"URB status is failed: %d\n", urb->status); "URB status is failed: %d\n", urb->status);
/* Do not free skb in case of command ep */ /* Do not free skb in case of command ep */
...@@ -218,10 +219,10 @@ static void mwifiex_usb_rx_complete(struct urb *urb) ...@@ -218,10 +219,10 @@ static void mwifiex_usb_rx_complete(struct urb *urb)
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
} }
} else if (urb->status) { } else if (urb->status) {
if (!adapter->is_suspended) { if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, FATAL, mwifiex_dbg(adapter, FATAL,
"Card is removed: %d\n", urb->status); "Card is removed: %d\n", urb->status);
adapter->surprise_removed = true; set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags);
} }
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return; return;
...@@ -529,7 +530,7 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -529,7 +530,7 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message)
return 0; return 0;
} }
if (unlikely(adapter->is_suspended)) if (unlikely(test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)))
mwifiex_dbg(adapter, WARN, mwifiex_dbg(adapter, WARN,
"Device already suspended\n"); "Device already suspended\n");
...@@ -537,19 +538,19 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message) ...@@ -537,19 +538,19 @@ static int mwifiex_usb_suspend(struct usb_interface *intf, pm_message_t message)
if (!mwifiex_enable_hs(adapter)) { if (!mwifiex_enable_hs(adapter)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"cmd: failed to suspend\n"); "cmd: failed to suspend\n");
adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
return -EFAULT; return -EFAULT;
} }
/* 'is_suspended' flag indicates device is suspended. /* 'MWIFIEX_IS_SUSPENDED' bit indicates device is suspended.
* It must be set here before the usb_kill_urb() calls. Reason * It must be set here before the usb_kill_urb() calls. Reason
* is in the complete handlers, urb->status(= -ENOENT) and * is in the complete handlers, urb->status(= -ENOENT) and
* this flag is used in combination to distinguish between a * this flag is used in combination to distinguish between a
* 'suspended' state and a 'disconnect' one. * 'suspended' state and a 'disconnect' one.
*/ */
adapter->is_suspended = true; set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
adapter->hs_enabling = false; clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags);
if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb) if (atomic_read(&card->rx_cmd_urb_pending) && card->rx_cmd.urb)
usb_kill_urb(card->rx_cmd.urb); usb_kill_urb(card->rx_cmd.urb);
...@@ -593,7 +594,7 @@ static int mwifiex_usb_resume(struct usb_interface *intf) ...@@ -593,7 +594,7 @@ static int mwifiex_usb_resume(struct usb_interface *intf)
} }
adapter = card->adapter; adapter = card->adapter;
if (unlikely(!adapter->is_suspended)) { if (unlikely(!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags))) {
mwifiex_dbg(adapter, WARN, mwifiex_dbg(adapter, WARN,
"Device already resumed\n"); "Device already resumed\n");
return 0; return 0;
...@@ -602,7 +603,7 @@ static int mwifiex_usb_resume(struct usb_interface *intf) ...@@ -602,7 +603,7 @@ static int mwifiex_usb_resume(struct usb_interface *intf)
/* Indicate device resumed. The netdev queue will be resumed only /* Indicate device resumed. The netdev queue will be resumed only
* after the urbs have been re-submitted * after the urbs have been re-submitted
*/ */
adapter->is_suspended = false; clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags);
if (!atomic_read(&card->rx_data_urb_pending)) if (!atomic_read(&card->rx_data_urb_pending))
for (i = 0; i < MWIFIEX_RX_DATA_URB; i++) for (i = 0; i < MWIFIEX_RX_DATA_URB; i++)
...@@ -1158,13 +1159,13 @@ static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep, ...@@ -1158,13 +1159,13 @@ static int mwifiex_usb_host_to_card(struct mwifiex_adapter *adapter, u8 ep,
unsigned long flags; unsigned long flags;
int idx, ret; int idx, ret;
if (adapter->is_suspended) { if (test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, mwifiex_dbg(adapter, ERROR,
"%s: not allowed while suspended\n", __func__); "%s: not allowed while suspended\n", __func__);
return -1; return -1;
} }
if (adapter->surprise_removed) { if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) {
mwifiex_dbg(adapter, ERROR, "%s: device removed\n", __func__); mwifiex_dbg(adapter, ERROR, "%s: device removed\n", __func__);
return -1; return -1;
} }
......
...@@ -197,9 +197,11 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv, ...@@ -197,9 +197,11 @@ int mwifiex_get_debug_info(struct mwifiex_private *priv,
info->is_deep_sleep = adapter->is_deep_sleep; info->is_deep_sleep = adapter->is_deep_sleep;
info->pm_wakeup_card_req = adapter->pm_wakeup_card_req; info->pm_wakeup_card_req = adapter->pm_wakeup_card_req;
info->pm_wakeup_fw_try = adapter->pm_wakeup_fw_try; info->pm_wakeup_fw_try = adapter->pm_wakeup_fw_try;
info->is_hs_configured = adapter->is_hs_configured; info->is_hs_configured = test_bit(MWIFIEX_IS_HS_CONFIGURED,
&adapter->work_flags);
info->hs_activated = adapter->hs_activated; info->hs_activated = adapter->hs_activated;
info->is_cmd_timedout = adapter->is_cmd_timedout; info->is_cmd_timedout = test_bit(MWIFIEX_IS_CMD_TIMEDOUT,
&adapter->work_flags);
info->num_cmd_host_to_card_failure info->num_cmd_host_to_card_failure
= adapter->dbg.num_cmd_host_to_card_failure; = adapter->dbg.num_cmd_host_to_card_failure;
info->num_cmd_sleep_cfm_host_to_card_failure info->num_cmd_sleep_cfm_host_to_card_failure
......
...@@ -599,7 +599,7 @@ mwifiex_clean_txrx(struct mwifiex_private *priv) ...@@ -599,7 +599,7 @@ mwifiex_clean_txrx(struct mwifiex_private *priv)
memcpy(tos_to_tid, ac_to_tid, sizeof(tos_to_tid)); memcpy(tos_to_tid, ac_to_tid, sizeof(tos_to_tid));
if (priv->adapter->if_ops.clean_pcie_ring && if (priv->adapter->if_ops.clean_pcie_ring &&
!priv->adapter->surprise_removed) !test_bit(MWIFIEX_SURPRISE_REMOVED, &priv->adapter->work_flags))
priv->adapter->if_ops.clean_pcie_ring(priv->adapter); priv->adapter->if_ops.clean_pcie_ring(priv->adapter);
spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags); spin_unlock_irqrestore(&priv->wmm.ra_list_spinlock, flags);
......
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