aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex
diff options
context:
space:
mode:
authorShengzhen Li <szli@marvell.com>2015-03-13 08:07:54 -0400
committerKalle Valo <kvalo@codeaurora.org>2015-03-16 12:12:25 -0400
commitb2713f67f7a4c3226772c5ac581c7f37d7c473f1 (patch)
treec17b7a7e0beaf3804be5b19cbcbaf2554a072f41 /drivers/net/wireless/mwifiex
parentea44f4d04c9356dc844af5312a376b6528cec7c5 (diff)
mwifiex: avoid queue_work while work is ongoing
Current code does not check whether main_work_queue or rx_work_queue is running when preparing to do queue_work, this code fix add check before calling queue_work, reducing unnecessary queue_work switch. This change instead sets more_task flag to ensure we run main_process superloop once again. Signed-off-by: Shengzhen Li <szli@marvell.com> Signed-off-by: Zhaoyang Liu <liuzy@marvell.com> Reviewed-by: Cathy Luo <cluo@marvell.com> Reviewed-by: Amitkumar Karwar <akarwar@marvell.com> Reviewed-by: Avinash Patil <patila@marvell.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/net/wireless/mwifiex')
-rw-r--r--drivers/net/wireless/mwifiex/main.c38
-rw-r--r--drivers/net/wireless/mwifiex/main.h1
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c2
-rw-r--r--drivers/net/wireless/mwifiex/usb.c4
4 files changed, 36 insertions, 9 deletions
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 9c11eb882a0e..d96d60a7ae7c 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -131,6 +131,34 @@ static int mwifiex_unregister(struct mwifiex_adapter *adapter)
131 return 0; 131 return 0;
132} 132}
133 133
134void mwifiex_queue_main_work(struct mwifiex_adapter *adapter)
135{
136 unsigned long flags;
137
138 spin_lock_irqsave(&adapter->main_proc_lock, flags);
139 if (adapter->mwifiex_processing) {
140 adapter->more_task_flag = true;
141 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
142 } else {
143 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
144 queue_work(adapter->workqueue, &adapter->main_work);
145 }
146}
147EXPORT_SYMBOL_GPL(mwifiex_queue_main_work);
148
149static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter)
150{
151 unsigned long flags;
152
153 spin_lock_irqsave(&adapter->rx_proc_lock, flags);
154 if (adapter->rx_processing) {
155 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
156 } else {
157 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
158 queue_work(adapter->rx_workqueue, &adapter->rx_work);
159 }
160}
161
134static int mwifiex_process_rx(struct mwifiex_adapter *adapter) 162static int mwifiex_process_rx(struct mwifiex_adapter *adapter)
135{ 163{
136 unsigned long flags; 164 unsigned long flags;
@@ -154,7 +182,7 @@ static int mwifiex_process_rx(struct mwifiex_adapter *adapter)
154 if (adapter->if_ops.submit_rem_rx_urbs) 182 if (adapter->if_ops.submit_rem_rx_urbs)
155 adapter->if_ops.submit_rem_rx_urbs(adapter); 183 adapter->if_ops.submit_rem_rx_urbs(adapter);
156 adapter->delay_main_work = false; 184 adapter->delay_main_work = false;
157 queue_work(adapter->workqueue, &adapter->main_work); 185 mwifiex_queue_main_work(adapter);
158 } 186 }
159 mwifiex_handle_rx_packet(adapter, skb); 187 mwifiex_handle_rx_packet(adapter, skb);
160 } 188 }
@@ -214,9 +242,7 @@ process_start:
214 if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING && 242 if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING &&
215 adapter->iface_type != MWIFIEX_USB) { 243 adapter->iface_type != MWIFIEX_USB) {
216 adapter->delay_main_work = true; 244 adapter->delay_main_work = true;
217 if (!adapter->rx_processing) 245 mwifiex_queue_rx_work(adapter);
218 queue_work(adapter->rx_workqueue,
219 &adapter->rx_work);
220 break; 246 break;
221 } 247 }
222 248
@@ -229,7 +255,7 @@ process_start:
229 } 255 }
230 256
231 if (adapter->rx_work_enabled && adapter->data_received) 257 if (adapter->rx_work_enabled && adapter->data_received)
232 queue_work(adapter->rx_workqueue, &adapter->rx_work); 258 mwifiex_queue_rx_work(adapter);
233 259
234 /* Need to wake up the card ? */ 260 /* Need to wake up the card ? */
235 if ((adapter->ps_state == PS_STATE_SLEEP) && 261 if ((adapter->ps_state == PS_STATE_SLEEP) &&
@@ -606,7 +632,7 @@ int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb)
606 atomic_inc(&priv->adapter->tx_pending); 632 atomic_inc(&priv->adapter->tx_pending);
607 mwifiex_wmm_add_buf_txqueue(priv, skb); 633 mwifiex_wmm_add_buf_txqueue(priv, skb);
608 634
609 queue_work(priv->adapter->workqueue, &priv->adapter->main_work); 635 mwifiex_queue_main_work(priv->adapter);
610 636
611 return 0; 637 return 0;
612} 638}
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index d609d16cf18c..a319abe84423 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -1424,6 +1424,7 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
1424 1424
1425void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter); 1425void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter);
1426void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags); 1426void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags);
1427void mwifiex_queue_main_work(struct mwifiex_adapter *adapter);
1427 1428
1428#ifdef CONFIG_DEBUG_FS 1429#ifdef CONFIG_DEBUG_FS
1429void mwifiex_debugfs_init(void); 1430void mwifiex_debugfs_init(void);
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index fc59c1db3615..b31c9a70ffaa 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -2101,7 +2101,7 @@ static irqreturn_t mwifiex_pcie_interrupt(int irq, void *context)
2101 goto exit; 2101 goto exit;
2102 2102
2103 mwifiex_interrupt_status(adapter); 2103 mwifiex_interrupt_status(adapter);
2104 queue_work(adapter->workqueue, &adapter->main_work); 2104 mwifiex_queue_main_work(adapter);
2105 2105
2106exit: 2106exit:
2107 return IRQ_HANDLED; 2107 return IRQ_HANDLED;
diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c
index 8beb38c578d0..fd8027f200a0 100644
--- a/drivers/net/wireless/mwifiex/usb.c
+++ b/drivers/net/wireless/mwifiex/usb.c
@@ -193,7 +193,7 @@ static void mwifiex_usb_rx_complete(struct urb *urb)
193 dev_dbg(adapter->dev, "info: recv_length=%d, status=%d\n", 193 dev_dbg(adapter->dev, "info: recv_length=%d, status=%d\n",
194 recv_length, status); 194 recv_length, status);
195 if (status == -EINPROGRESS) { 195 if (status == -EINPROGRESS) {
196 queue_work(adapter->workqueue, &adapter->main_work); 196 mwifiex_queue_main_work(adapter);
197 197
198 /* urb for data_ep is re-submitted now; 198 /* urb for data_ep is re-submitted now;
199 * urb for cmd_ep will be re-submitted in callback 199 * urb for cmd_ep will be re-submitted in callback
@@ -262,7 +262,7 @@ static void mwifiex_usb_tx_complete(struct urb *urb)
262 urb->status ? -1 : 0); 262 urb->status ? -1 : 0);
263 } 263 }
264 264
265 queue_work(adapter->workqueue, &adapter->main_work); 265 mwifiex_queue_main_work(adapter);
266 266
267 return; 267 return;
268} 268}