All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ganapathi Bhat <gbhat@marvell.com>
To: <linux-wireless@vger.kernel.org>
Cc: Brian Norris <briannorris@chromium.org>,
	Cathy Luo <cluo@marvell.com>, Xinming Hu <huxm@marvell.com>,
	Zhiyuan Yang <yangzy@marvell.com>, James Cao <jcao@marvell.com>,
	Mangesh Malusare <mmangesh@marvell.com>,
	Shrenik Shikhare <shrenik@marvell.com>,
	Ganapathi Bhat <gbhat@marvell.com>
Subject: [PATCH 1/2] mwifiex: schedule rx_work on RX interrupt for USB
Date: Mon, 22 Jan 2018 20:34:56 +0530	[thread overview]
Message-ID: <1516633497-6584-2-git-send-email-gbhat@marvell.com> (raw)
In-Reply-To: <1516633497-6584-1-git-send-email-gbhat@marvell.com>

From: Shrenik Shikhare <shrenik@marvell.com>

There is race for data_received flag between main thread and
RX data interrupt(mwifiex_usb_rx_complete()):
1. USB received an RX data interrupt, set data_received flag
2. main thread checks data_received, if set queues rx_work
3. rx worker thread independently start processing rx_data_q
4. rx work exits (once rx_data_q is empty)
5. main thread resets the data_received flag(after #2)
6. Now at the corner case there will be high RX data interrupts
between #4 and #5
7. Driver stops submitting URBs to firmware, once rx_pending
exceeds HIGH_RX_PENDING
8. The flag data_received(cleared in #5) will remain unset since
there will be no interrupts from firmware to set it(after #7)

Above scenario causes RX stall in driver, which will finally
result in command/TX timeouts in firmware.

As a fix, queue rx_work directly in mwifiex_usb_rx_complete()
callback, instead in the main thread. This removes dependency
of RX processing on data_received flag.

Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Ganapathi Bhat <gbhat@marvell.com>
---
 drivers/net/wireless/marvell/mwifiex/main.c | 7 ++++---
 drivers/net/wireless/marvell/mwifiex/main.h | 1 +
 drivers/net/wireless/marvell/mwifiex/usb.c  | 2 ++
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c
index 12e7399..6e6e1a7 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.c
+++ b/drivers/net/wireless/marvell/mwifiex/main.c
@@ -171,7 +171,7 @@ void mwifiex_queue_main_work(struct mwifiex_adapter *adapter)
 }
 EXPORT_SYMBOL_GPL(mwifiex_queue_main_work);
 
-static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter)
+void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter)
 {
 	unsigned long flags;
 
@@ -183,6 +183,7 @@ static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter)
 		queue_work(adapter->rx_workqueue, &adapter->rx_work);
 	}
 }
+EXPORT_SYMBOL_GPL(mwifiex_queue_rx_work);
 
 static int mwifiex_process_rx(struct mwifiex_adapter *adapter)
 {
@@ -283,10 +284,10 @@ int mwifiex_main_process(struct mwifiex_adapter *adapter)
 				mwifiex_process_hs_config(adapter);
 			if (adapter->if_ops.process_int_status)
 				adapter->if_ops.process_int_status(adapter);
+			if (adapter->rx_work_enabled && adapter->data_received)
+				mwifiex_queue_rx_work(adapter);
 		}
 
-		if (adapter->rx_work_enabled && adapter->data_received)
-			mwifiex_queue_rx_work(adapter);
 
 		/* Need to wake up the card ? */
 		if ((adapter->ps_state == PS_STATE_SLEEP) &&
diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h
index 6b5539b..66ba95c 100644
--- a/drivers/net/wireless/marvell/mwifiex/main.h
+++ b/drivers/net/wireless/marvell/mwifiex/main.h
@@ -1667,6 +1667,7 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter);
 void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags);
 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter);
+void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter);
 int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action,
 			      int cmd_type,
 			      struct mwifiex_ds_wakeup_reason *wakeup_reason);
diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c
index 4bc2448..d20fda1 100644
--- a/drivers/net/wireless/marvell/mwifiex/usb.c
+++ b/drivers/net/wireless/marvell/mwifiex/usb.c
@@ -144,6 +144,8 @@ static int mwifiex_usb_recv(struct mwifiex_adapter *adapter,
 		skb_queue_tail(&adapter->rx_data_q, skb);
 		adapter->data_received = true;
 		atomic_inc(&adapter->rx_pending);
+		if (adapter->rx_work_enabled)
+			mwifiex_queue_rx_work(adapter);
 		break;
 	default:
 		mwifiex_dbg(adapter, ERROR,
-- 
1.9.1

  reply	other threads:[~2018-01-22 15:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 15:04 [PATCH 0/2] mwifiex: fix RX data stall issue on USB interface Ganapathi Bhat
2018-01-22 15:04 ` Ganapathi Bhat [this message]
2018-01-25  7:10   ` [1/2] mwifiex: schedule rx_work on RX interrupt for USB Kalle Valo
     [not found]   ` <20180125071052.E370660A4E@smtp.codeaurora.org>
2018-01-25 18:32     ` Brian Norris
2018-01-25 18:59   ` [PATCH 1/2] " Brian Norris
2018-01-29  7:21     ` [EXT] " Ganapathi Bhat
2018-01-22 15:04 ` [PATCH 2/2] mwifiex: use more_rx_task_flag to avoid USB RX stall Ganapathi Bhat
2018-01-25  7:12   ` [2/2] " Kalle Valo
2018-01-25  7:13     ` Kalle Valo
2018-01-25 10:02       ` [EXT] " Ganapathi Bhat
     [not found]   ` <20180125071202.0F39560A60@smtp.codeaurora.org>
2018-01-25  9:59     ` Ganapathi Bhat
2018-01-25 12:59       ` Kalle Valo
2018-01-25 13:26         ` Ganapathi Bhat
2018-01-25 18:33       ` Brian Norris
2018-01-29  7:17         ` Ganapathi Bhat
2018-01-29  7:19         ` Ganapathi Bhat
2018-01-29 22:08           ` Brian Norris
2018-01-30 15:25             ` Ganapathi Bhat
2018-01-31  6:59             ` Ganapathi Bhat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516633497-6584-2-git-send-email-gbhat@marvell.com \
    --to=gbhat@marvell.com \
    --cc=briannorris@chromium.org \
    --cc=cluo@marvell.com \
    --cc=huxm@marvell.com \
    --cc=jcao@marvell.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mmangesh@marvell.com \
    --cc=shrenik@marvell.com \
    --cc=yangzy@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.