linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3.12] mwifiex: queue main work from main process when bailing on races
@ 2013-09-17 18:25 Daniel Mack
  2013-09-17 19:15 ` Bing Zhao
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mack @ 2013-09-17 18:25 UTC (permalink / raw)
  To: linux-wireless
  Cc: s.neumann, afenkart, bzhao, linville, johannes.berg, Daniel Mack,
	stable

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.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-by: Sven Neumann <s.neumann@raumfeld.com>
Reported-by: Andreas Fenkart <afenkart@gmail.com>
Cc: Bing Zhao <bzhao@marvell.com>
Cc: <stable@vger.kernel.org> [v3.7+]
---
 drivers/net/wireless/mwifiex/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index ff4ed96..0700bc2 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH 3.12] mwifiex: queue main work from main process when bailing on races
  2013-09-17 18:25 [PATCH 3.12] mwifiex: queue main work from main process when bailing on races Daniel Mack
@ 2013-09-17 19:15 ` Bing Zhao
  2013-09-25 14:23   ` Daniel Mack
  0 siblings, 1 reply; 5+ messages in thread
From: Bing Zhao @ 2013-09-17 19:15 UTC (permalink / raw)
  To: Daniel Mack, linux-wireless@vger.kernel.org
  Cc: s.neumann@raumfeld.com, afenkart@gmail.com,
	linville@tuxdriver.com, johannes.berg@intel.com,
	stable@vger.kernel.org

Hi Daniel,

> 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.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> Reported-by: Sven Neumann <s.neumann@raumfeld.com>
> Reported-by: Andreas Fenkart <afenkart@gmail.com>
> Cc: Bing Zhao <bzhao@marvell.com>
> Cc: <stable@vger.kernel.org> [v3.7+]

Acked-by: Bing Zhao <bzhao@marvell.com>

Thanks,
Bing

> ---
>  drivers/net/wireless/mwifiex/main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/wireless/mwifiex/main.c
> b/drivers/net/wireless/mwifiex/main.c
> index ff4ed96..0700bc2 100644
> --- a/drivers/net/wireless/mwifiex/main.c
> +++ b/drivers/net/wireless/mwifiex/main.c
> @@ -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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 3.12] mwifiex: queue main work from main process when bailing on races
  2013-09-17 19:15 ` Bing Zhao
@ 2013-09-25 14:23   ` Daniel Mack
  2013-09-25 16:19     ` Bing Zhao
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mack @ 2013-09-25 14:23 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless@vger.kernel.org, s.neumann@raumfeld.com,
	afenkart@gmail.com, linville@tuxdriver.com,
	johannes.berg@intel.com, stable@vger.kernel.org

On 17.09.2013 21:15, Bing Zhao wrote:
>> 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.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>> Reported-by: Sven Neumann <s.neumann@raumfeld.com>
>> Reported-by: Andreas Fenkart <afenkart@gmail.com>
>> Cc: Bing Zhao <bzhao@marvell.com>
>> Cc: <stable@vger.kernel.org> [v3.7+]
> 
> Acked-by: Bing Zhao <bzhao@marvell.com>

John, could you pick this one?


Many thanks,
Daniel


> 
> Thanks,
> Bing
> 
>> ---
>>  drivers/net/wireless/mwifiex/main.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/net/wireless/mwifiex/main.c
>> b/drivers/net/wireless/mwifiex/main.c
>> index ff4ed96..0700bc2 100644
>> --- a/drivers/net/wireless/mwifiex/main.c
>> +++ b/drivers/net/wireless/mwifiex/main.c
>> @@ -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
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 3.12] mwifiex: queue main work from main process when bailing on races
  2013-09-25 14:23   ` Daniel Mack
@ 2013-09-25 16:19     ` Bing Zhao
  2013-09-25 16:37       ` Daniel Mack
  0 siblings, 1 reply; 5+ messages in thread
From: Bing Zhao @ 2013-09-25 16:19 UTC (permalink / raw)
  To: Daniel Mack, Paul Stewart, Dylan Reid
  Cc: linux-wireless@vger.kernel.org, s.neumann@raumfeld.com,
	afenkart@gmail.com, linville@tuxdriver.com,
	johannes.berg@intel.com, stable@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 403 bytes --]

Hi Daniel,

> > Acked-by: Bing Zhao <bzhao@marvell.com>
> 
> 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
 

[-- Attachment #2: 0001-mwifiex-avoid-redundant-main-process-queueing.patch --]
[-- Type: application/octet-stream, Size: 1965 bytes --]

From 43b3fcb3e58b6d10b70c08f5b2259a64a195f1a5 Mon Sep 17 00:00:00 2001
From: Amitkumar Karwar <akarwar@marvell.com>
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.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
---
 drivers/net/wireless/mwifiex/main.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 516b80e..dd6548e 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -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);
 
-- 
1.7.3.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3.12] mwifiex: queue main work from main process when bailing on races
  2013-09-25 16:19     ` Bing Zhao
@ 2013-09-25 16:37       ` Daniel Mack
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Mack @ 2013-09-25 16:37 UTC (permalink / raw)
  To: Bing Zhao
  Cc: Paul Stewart, Dylan Reid, linux-wireless@vger.kernel.org,
	s.neumann@raumfeld.com, afenkart@gmail.com,
	linville@tuxdriver.com, johannes.berg@intel.com,
	stable@vger.kernel.org

Hi Bing,

On 25.09.2013 18:19, Bing Zhao wrote:
>>> Acked-by: Bing Zhao <bzhao@marvell.com>
>> 
>> 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

	Tested-by: Daniel Mack <zonque@gmail.com>

if you need it.


Thanks,
Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-09-25 16:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 18:25 [PATCH 3.12] mwifiex: queue main work from main process when bailing on races Daniel Mack
2013-09-17 19:15 ` Bing Zhao
2013-09-25 14:23   ` Daniel Mack
2013-09-25 16:19     ` Bing Zhao
2013-09-25 16:37       ` Daniel Mack

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).