From patchwork Mon Jan 22 15:04:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ganapathi Bhat X-Patchwork-Id: 10178731 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB0A160353 for ; Mon, 22 Jan 2018 15:09:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C190727F93 for ; Mon, 22 Jan 2018 15:09:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B64F4280B0; Mon, 22 Jan 2018 15:09:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A44DA27F93 for ; Mon, 22 Jan 2018 15:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751255AbeAVPJa (ORCPT ); Mon, 22 Jan 2018 10:09:30 -0500 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:43030 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751086AbeAVPJ2 (ORCPT ); Mon, 22 Jan 2018 10:09:28 -0500 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w0MF4JuK027715; Mon, 22 Jan 2018 07:09:27 -0800 Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2fmw7pjgnh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 22 Jan 2018 07:09:27 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 22 Jan 2018 07:09:25 -0800 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 22 Jan 2018 07:09:25 -0800 Received: from localhost (gbhat-thinkpad-t430.marvell.com [10.31.130.81]) by maili.marvell.com (Postfix) with ESMTP id 9528D3F7040; Mon, 22 Jan 2018 07:09:25 -0800 (PST) Received: from localhost.marvell.com (localhost [127.0.0.1]) by localhost (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w0MF55rR006626; Mon, 22 Jan 2018 20:35:05 +0530 Received: (from root@localhost) by localhost.marvell.com (8.14.4/8.14.4/Submit) id w0MF55m0006625; Mon, 22 Jan 2018 20:35:05 +0530 From: Ganapathi Bhat To: CC: Brian Norris , Cathy Luo , Xinming Hu , Zhiyuan Yang , James Cao , Mangesh Malusare , Shrenik Shikhare , Ganapathi Bhat Subject: [PATCH 1/2] mwifiex: schedule rx_work on RX interrupt for USB Date: Mon, 22 Jan 2018 20:34:56 +0530 Message-ID: <1516633497-6584-2-git-send-email-gbhat@marvell.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1516633497-6584-1-git-send-email-gbhat@marvell.com> References: <1516633497-6584-1-git-send-email-gbhat@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-01-22_06:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1801220214 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shrenik Shikhare 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 Signed-off-by: Ganapathi Bhat --- 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,