Commit 1a1fb970 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville
Browse files

mwifiex: wakeup main thread to handle command queued



We miss to wakeup main thread after adding command to cmd pending
queue at follwing places. These commands are handled later when
main thread is woken up for handling an interrupt for sleep event
from firmware. This adds worst case delay of 50msec.

1) We don't wakeup main thread when asynchronous command is added
to cmd pending queue. Move queue_work() call from
mwifiex_wait_queue_complete() to mwifiex_send_cmd_async() to wakeup
main thread for sync as well as async commands.

2) Scan operation is triggered due to following reasons
   a) request from user (ex. "iw scan" command)
   b) Scan performed by driver internally.
   In first case main thread is woken up when first scan command is
queued in cmd pending queue (we don't need to wakeup main thread for
subsequent scan commands, because they are queued in scan command
response handler), but it is not done for second case. queue_work()
is moved inside mwifiex_scan_networks() to handle both the cases.
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarAvinash Patil <patila@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 46997917
...@@ -1422,7 +1422,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, ...@@ -1422,7 +1422,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
priv->user_scan_cfg->chan_list[i].scan_time = 0; priv->user_scan_cfg->chan_list[i].scan_time = 0;
} }
if (mwifiex_set_user_scan_ioctl(priv, priv->user_scan_cfg)) if (mwifiex_scan_networks(priv, priv->user_scan_cfg))
return -EFAULT; return -EFAULT;
if (request->ie && request->ie_len) { if (request->ie && request->ie_len) {
......
...@@ -578,6 +578,7 @@ int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no, ...@@ -578,6 +578,7 @@ int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
} else { } else {
adapter->cmd_queued = cmd_node; adapter->cmd_queued = cmd_node;
mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, true); mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, true);
queue_work(adapter->workqueue, &adapter->main_work);
} }
return ret; return ret;
......
...@@ -949,8 +949,8 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, ...@@ -949,8 +949,8 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
struct mwifiex_rate_cfg *rate); struct mwifiex_rate_cfg *rate);
int mwifiex_request_scan(struct mwifiex_private *priv, int mwifiex_request_scan(struct mwifiex_private *priv,
struct cfg80211_ssid *req_ssid); struct cfg80211_ssid *req_ssid);
int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, int mwifiex_scan_networks(struct mwifiex_private *priv,
struct mwifiex_user_scan_cfg *scan_req); const struct mwifiex_user_scan_cfg *user_scan_in);
int mwifiex_set_radio(struct mwifiex_private *priv, u8 option); int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel); int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel);
......
...@@ -1296,8 +1296,8 @@ mwifiex_radio_type_to_band(u8 radio_type) ...@@ -1296,8 +1296,8 @@ mwifiex_radio_type_to_band(u8 radio_type)
* order to send the appropriate scan commands to firmware to populate or * order to send the appropriate scan commands to firmware to populate or
* update the internal driver scan table. * update the internal driver scan table.
*/ */
static int mwifiex_scan_networks(struct mwifiex_private *priv, int mwifiex_scan_networks(struct mwifiex_private *priv,
const struct mwifiex_user_scan_cfg *user_scan_in) const struct mwifiex_user_scan_cfg *user_scan_in)
{ {
int ret = 0; int ret = 0;
struct mwifiex_adapter *adapter = priv->adapter; struct mwifiex_adapter *adapter = priv->adapter;
...@@ -1362,6 +1362,7 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv, ...@@ -1362,6 +1362,7 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv,
adapter->cmd_queued = cmd_node; adapter->cmd_queued = cmd_node;
mwifiex_insert_cmd_to_pending_q(adapter, cmd_node, mwifiex_insert_cmd_to_pending_q(adapter, cmd_node,
true); true);
queue_work(adapter->workqueue, &adapter->main_work);
} else { } else {
spin_unlock_irqrestore(&adapter->scan_pending_q_lock, spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
flags); flags);
...@@ -1377,26 +1378,6 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv, ...@@ -1377,26 +1378,6 @@ static int mwifiex_scan_networks(struct mwifiex_private *priv,
return ret; return ret;
} }
/*
* Sends IOCTL request to start a scan with user configurations.
*
* This function allocates the IOCTL request buffer, fills it
* with requisite parameters and calls the IOCTL handler.
*
* Upon completion, it also generates a wireless event to notify
* applications.
*/
int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
struct mwifiex_user_scan_cfg *scan_req)
{
int status;
status = mwifiex_scan_networks(priv, scan_req);
queue_work(priv->adapter->workqueue, &priv->adapter->main_work);
return status;
}
/* /*
* This function prepares a scan command to be sent to the firmware. * This function prepares a scan command to be sent to the firmware.
* *
......
...@@ -66,9 +66,6 @@ int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter) ...@@ -66,9 +66,6 @@ int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
dev_dbg(adapter->dev, "cmd pending\n"); dev_dbg(adapter->dev, "cmd pending\n");
atomic_inc(&adapter->cmd_pending); atomic_inc(&adapter->cmd_pending);
/* Status pending, wake up main process */
queue_work(adapter->workqueue, &adapter->main_work);
/* Wait for completion */ /* Wait for completion */
wait_event_interruptible(adapter->cmd_wait_q.wait, wait_event_interruptible(adapter->cmd_wait_q.wait,
*(cmd_queued->condition)); *(cmd_queued->condition));
......
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