Skip to contentSkip to conversation

mwifiex: queue main work from main process when bailing on races

PATCH In review Daniel Mack 2 participants 5 messages Sep 17, 2013 – Sep 25, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mwifiex: queue main work from main process when bailing on races

Queue main_work in case mwifiex_main_process() bails due to an already processed transaction. This is particularly necessary because mwifiex_main_process() is called from both the SDIO interrupt handler and the workqueue. In case an interrupt occurs while the main process is currently executed from the workqueue, the interrupt is lost, resulting in a command timeout and consequently a card reset.

I'm marking this for stable kernel in version 3.7+, because on our platform, the issue appears since 601216e12c ("mwifiex: process RX packets in SDIO IRQ thread directly") went in.

---
 drivers/net/wireless/mwifiex/main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/mwifiex/main.c +1 -0
index ff4ed96..0700bc2 100644
@@ -235,6 +235,7 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
 	/* Check if already processing */
 	if (adapter->mwifiex_processing) {
 		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
+		queue_work(adapter->workqueue, &adapter->main_work);
 		goto exit_main_proc;
 	} else {
 		adapter->mwifiex_processing = true;
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw

Hi Daniel,

Quoted 11 lines

Queue main_work in case mwifiex_main_process() bails due to an already processed transaction. This is particularly necessary because mwifiex_main_process() is called from both the SDIO interrupt handler and the workqueue. In case an interrupt occurs while the main process is currently executed from the workqueue, the interrupt is lost, resulting in a command timeout and consequently a card reset.

I'm marking this for stable kernel in version 3.7+, because on our platform, the issue appears since 601216e12c ("mwifiex: process RX packets in SDIO IRQ thread directly") went in.

Quoted 5 lines

Thanks,
Bing

Quoted 20 lines
---
 drivers/net/wireless/mwifiex/main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/mwifiex/main.c +1 -0
index ff4ed96..0700bc2 100644
@@ -235,6 +235,7 @@ int mwifiex_main_process(struct mwifiex_adapter
 *adapter)
 	/* Check if already processing */
 	if (adapter->mwifiex_processing) {
 		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
+		queue_work(adapter->workqueue, &adapter->main_work);
 		goto exit_main_proc;
 	} else {

adapter->mwifiex_processing = true;
--
1.8.3.1

#2 lore raw
Quoted 11 lines · Bing Zhao
Quoted 11 lines

Queue main_work in case mwifiex_main_process() bails due to an already processed transaction. This is particularly necessary because mwifiex_main_process() is called from both the SDIO interrupt handler and the workqueue. In case an interrupt occurs while the main process is currently executed from the workqueue, the interrupt is lost, resulting in a command timeout and consequently a card reset.

I'm marking this for stable kernel in version 3.7+, because on our platform, the issue appears since 601216e12c ("mwifiex: process RX packets in SDIO IRQ thread directly") went in.

Quoted 7 lines
Quoted 5 lines

John, could you pick this one?

Many thanks,
Daniel

Quoted 25 lines

Thanks,
Bing

Quoted 20 lines
---
 drivers/net/wireless/mwifiex/main.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/mwifiex/main.c +1 -0
index ff4ed96..0700bc2 100644
@@ -235,6 +235,7 @@ int mwifiex_main_process(struct mwifiex_adapter
 *adapter)
 	/* Check if already processing */
 	if (adapter->mwifiex_processing) {
 		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
+		queue_work(adapter->workqueue, &adapter->main_work);
 		goto exit_main_proc;
 	} else {

adapter->mwifiex_processing = true;
--
1.8.3.1

#3 lore raw

Hi Daniel,

Quoted 3 lines
Quoted 1 line

John, could you pick this one?

We found that this patch causes CPU utilization issue on Chromebooks.
Could you please try attached patch on your platform? Basically this patch reverts your change and add main_proc_lock protection for int_status and IS_CARD_RX_RCVD access to avoid the missing interrupt handling.

Thanks,
Bing

From 43b3fcb3e58b6d10b70c08f5b2259a64a195f1a5 Mon Sep 17 00:00:00 2001
From: Amitkumar Karwar <[email protected]>
Date: Wed, 25 Sep 2013 21:21:29 +0530
Subject: [PATCH] mwifiex: avoid redundant main process queueing

As we use single threaded workqueue, the only possiblity for concurrent mwifiex_main_process() calls is during SDIO interrupts where the routine is directly called.

Recently queue_work() call is added to fix corner case SDIO interrupt lost issue. With this change main process is sometimes unnecessarily queued multiple times which results in increased CPU utilization.

This patch makes sure that currently running main process will always take care of pending interrupts. We don't need to queue an extra main process. This fixes interrupt lost issue.

---
 drivers/net/wireless/mwifiex/main.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mwifiex/main.c +4 -3
index 516b80e..dd6548e 100644
@@ -235,7 +235,6 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
 	/* Check if already processing */
 	if (adapter->mwifiex_processing) {
 		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
-		queue_work(adapter->workqueue, &adapter->main_work);
 		goto exit_main_proc;
 	} else {
 		adapter->mwifiex_processing = true;
@@ -359,10 +358,12 @@ process_start:
 		}
 	} while (true);
 
-	if ((adapter->int_status) || IS_CARD_RX_RCVD(adapter))
+	spin_lock_irqsave(&adapter->main_proc_lock, flags);
+	if ((adapter->int_status) || IS_CARD_RX_RCVD(adapter)) {
+		spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
 		goto process_start;
+	}
 
-	spin_lock_irqsave(&adapter->main_proc_lock, flags);
 	adapter->mwifiex_processing = false;
 	spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
 
Signature · 1 line
1.7.3.4
author Tested-by
#4 lore raw

Hi Bing,

Quoted 9 lines · Bing Zhao
Quoted 3 lines
Quoted 1 line

John, could you pick this one?

We found that this patch causes CPU utilization issue on Chromebooks. Could you please try attached patch on your platform? Basically this patch reverts your change and add main_proc_lock protection for int_status and IS_CARD_RX_RCVD access to avoid the missing interrupt handling.

Ok, that seems to work fine for me as well. Thanks for the update :)

Fell free to add my

if you need it.

Thanks,
Daniel