From patchwork Tue Jul 21 17:14:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676269 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F4266C1 for ; Tue, 21 Jul 2020 17:14:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6632820792 for ; Tue, 21 Jul 2020 17:14:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="KDjqZDsE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730635AbgGUROt (ORCPT ); Tue, 21 Jul 2020 13:14:49 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:14780 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730592AbgGUROs (ORCPT ); Tue, 21 Jul 2020 13:14:48 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351687; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=k+XAw9X2vHW5qNsF1IEl1DDQaBasaYhVfkIaTJygYog=; b=KDjqZDsEkkDW0aEt5fxxjhvy/mtOENTU/HfSxOOVNxrT3mRTjhFvqRUASMVm2dWjguEwP4f4 cLebNj8rskmyTOuROPorDSP+VvU1t8QrDSxZ9oIpKoSoz85XpVfgpO2TcBBOwG4rFyV5gFSu 6RZ57vBVI+vu3y6xml6Kyr6aePI= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n11.prod.us-west-2.postgun.com with SMTP id 5f172287e32d449b31ed61e9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:14:47 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id B7444C433A1; Tue, 21 Jul 2020 17:14:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id 263A8C4339C; Tue, 21 Jul 2020 17:14:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 263A8C4339C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 1/7] mac80211: Add check for napi handle before WARN_ON Date: Tue, 21 Jul 2020 22:44:20 +0530 Message-Id: <1595351666-28193-2-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The function ieee80211_rx_napi can be now called from a thread context as well, with napi context being NULL. Hence add the napi context check before giving out a warning for softirq count being 0. Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- net/mac80211/rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index a88ab6f..1e703f1 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -4652,7 +4652,7 @@ void ieee80211_rx_napi(struct ieee80211_hw *hw, struct ieee80211_sta *pubsta, struct ieee80211_supported_band *sband; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); - WARN_ON_ONCE(softirq_count() == 0); + WARN_ON_ONCE(napi && softirq_count() == 0); if (WARN_ON(status->band >= NUM_NL80211_BANDS)) goto drop; From patchwork Tue Jul 21 17:14:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676271 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9758513A4 for ; Tue, 21 Jul 2020 17:15:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78D6D207DD for ; Tue, 21 Jul 2020 17:15:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="uZR/0Nb+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbgGURPE (ORCPT ); Tue, 21 Jul 2020 13:15:04 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:16979 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730728AbgGURPD (ORCPT ); Tue, 21 Jul 2020 13:15:03 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351702; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=h4XrQmS1jTUM0qC0Ip95PyLtIHFfuNdHLgMI5cV20Ck=; b=uZR/0Nb+Tm7OcBrLLi6Sh1zsFkqzFZlmLCkofdeQtmvi5mx1HjdjWMkueHkDXs3VtNjUIC0r B2Kdy/HOQmpXRRsOq145WntfJDQpr9KorOinppjYiXlb/hvBMSr81JXxdSR2/7CNu5gxw9Jn wcuNoooyOPjosyXRrTNQ5FAws5g= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n17.prod.us-west-2.postgun.com with SMTP id 5f17228b3dbcb593a96a8948 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:14:51 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CC58DC433CA; Tue, 21 Jul 2020 17:14:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id B2DBEC43395; Tue, 21 Jul 2020 17:14:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B2DBEC43395 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 2/7] ath10k: Add support to process rx packet in thread Date: Tue, 21 Jul 2020 22:44:21 +0530 Message-Id: <1595351666-28193-3-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org NAPI instance gets scheduled on a CPU core on which the IRQ was triggered. The processing of rx packets can be CPU intensive and since NAPI cannot be moved to a different CPU core, to get better performance, its better to move the gist of rx packet processing in a high priority thread. Add the init/deinit part for a thread to process the receive packets. Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/core.c | 33 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/core.h | 23 +++++++++++++++++++ drivers/net/wireless/ath/ath10k/snoc.c | 41 ++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 9104496..2b520a0 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -668,6 +668,39 @@ static unsigned int ath10k_core_get_fw_feature_str(char *buf, return scnprintf(buf, buf_len, "%s", ath10k_core_fw_feature_str[feat]); } +int ath10k_core_thread_shutdown(struct ath10k *ar, + struct ath10k_thread *thread) +{ + ath10k_dbg(ar, ATH10K_DBG_BOOT, "shutting down %s\n", thread->name); + set_bit(ATH10K_THREAD_EVENT_SHUTDOWN, thread->event_flags); + wake_up_process(thread->task); + wait_for_completion(&thread->shutdown); + ath10k_info(ar, "thread %s exited\n", thread->name); + + return 0; +} +EXPORT_SYMBOL(ath10k_core_thread_shutdown); + +int ath10k_core_thread_init(struct ath10k *ar, + struct ath10k_thread *thread, + int (*handler)(void *data), + char *thread_name) +{ + thread->task = kthread_create(handler, thread, thread_name); + if (IS_ERR(thread->task)) + return -EINVAL; + + init_waitqueue_head(&thread->wait_q); + init_completion(&thread->shutdown); + memcpy(thread->name, thread_name, ATH10K_THREAD_NAME_SIZE_MAX); + clear_bit(ATH10K_THREAD_EVENT_SHUTDOWN, thread->event_flags); + ath10k_info(ar, "Starting thread %s\n", thread_name); + wake_up_process(thread->task); + + return 0; +} +EXPORT_SYMBOL(ath10k_core_thread_init); + void ath10k_core_get_fw_features_str(struct ath10k *ar, char *buf, size_t buf_len) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 5c18f6c..96919e8 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -970,6 +970,22 @@ struct ath10k_bus_params { bool hl_msdu_ids; }; +#define ATH10K_THREAD_NAME_SIZE_MAX 32 + +enum ath10k_thread_events { + ATH10K_THREAD_EVENT_SHUTDOWN, + ATH10K_THREAD_EVENT_MAX, +}; + +struct ath10k_thread { + struct ath10k *ar; + struct task_struct *task; + struct completion shutdown; + wait_queue_head_t wait_q; + DECLARE_BITMAP(event_flags, ATH10K_THREAD_EVENT_MAX); + char name[ATH10K_THREAD_NAME_SIZE_MAX]; +}; + struct ath10k { struct ath_common ath_common; struct ieee80211_hw *hw; @@ -982,6 +998,7 @@ struct ath10k { } msa; u8 mac_addr[ETH_ALEN]; + struct ath10k_thread rx_thread; enum ath10k_hw_rev hw_rev; u16 dev_id; u32 chip_id; @@ -1276,6 +1293,12 @@ static inline bool ath10k_peer_stats_enabled(struct ath10k *ar) extern unsigned long ath10k_coredump_mask; +int ath10k_core_thread_shutdown(struct ath10k *ar, + struct ath10k_thread *thread); +int ath10k_core_thread_init(struct ath10k *ar, + struct ath10k_thread *thread, + int (*handler)(void *data), + char *thread_name); struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev, enum ath10k_bus bus, enum ath10k_hw_rev hw_rev, diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 1ef5fdb..463c34e 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -909,6 +909,31 @@ static void ath10k_snoc_buffer_cleanup(struct ath10k *ar) } } +int ath10k_snoc_rx_thread_loop(void *data) +{ + struct ath10k_thread *rx_thread = data; + struct ath10k *ar = rx_thread->ar; + bool shutdown = false; + + ath10k_dbg(ar, ATH10K_DBG_SNOC, "rx thread started\n"); + set_user_nice(current, -1); + + while (!shutdown) { + wait_event_interruptible( + rx_thread->wait_q, + (test_bit(ATH10K_THREAD_EVENT_SHUTDOWN, + rx_thread->event_flags))); + if (test_and_clear_bit(ATH10K_THREAD_EVENT_SHUTDOWN, + rx_thread->event_flags)) + shutdown = true; + } + + ath10k_dbg(ar, ATH10K_DBG_SNOC, "rx thread exiting\n"); + complete(&rx_thread->shutdown); + + do_exit(0); +} + static void ath10k_snoc_hif_stop(struct ath10k *ar) { if (!test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags)) @@ -916,6 +941,7 @@ static void ath10k_snoc_hif_stop(struct ath10k *ar) napi_synchronize(&ar->napi); napi_disable(&ar->napi); + ath10k_core_thread_shutdown(ar, &ar->rx_thread); ath10k_snoc_buffer_cleanup(ar); ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif stop\n"); } @@ -923,9 +949,19 @@ static void ath10k_snoc_hif_stop(struct ath10k *ar) static int ath10k_snoc_hif_start(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); + int ret; bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX); napi_enable(&ar->napi); + + ret = ath10k_core_thread_init(ar, &ar->rx_thread, + ath10k_snoc_rx_thread_loop, + "ath10k_rx_thread"); + if (ret) { + ath10k_err(ar, "failed to start rx thread\n"); + goto rx_thread_fail; + } + ath10k_snoc_irq_enable(ar); ath10k_snoc_rx_post(ar); @@ -934,6 +970,10 @@ static int ath10k_snoc_hif_start(struct ath10k *ar) ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n"); return 0; + +rx_thread_fail: + napi_disable(&ar->napi); + return ret; } static int ath10k_snoc_init_pipes(struct ath10k *ar) @@ -1652,6 +1692,7 @@ static int ath10k_snoc_probe(struct platform_device *pdev) return -ENOMEM; } + ar->rx_thread.ar = ar; ar_snoc = ath10k_snoc_priv(ar); ar_snoc->dev = pdev; platform_set_drvdata(pdev, ar); From patchwork Tue Jul 21 17:14:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676291 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6EB913A4 for ; Tue, 21 Jul 2020 17:15:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D94A20792 for ; Tue, 21 Jul 2020 17:15:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="ZTBpGbhT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730688AbgGURO6 (ORCPT ); Tue, 21 Jul 2020 13:14:58 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:16979 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729785AbgGURO4 (ORCPT ); Tue, 21 Jul 2020 13:14:56 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351695; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=PigUcyn1h95S9+H6bcv2J1xVFlRM+Wlov9hyYKxTijY=; b=ZTBpGbhTmxoJKejc11hMCVUF0gusVgVSZrOmWuU4K3wQnPLSSxQo9D5XxxFIsUoq3EwPf7Mx JGElMWNE3f08TtVgDanPM5X4EtoCYsoFzis7LUgdaPUuEtrHy0IJoRV9OybIaL2k443aY6KJ vhvdvgPn3emPMgCKhi89meL7GgY= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n14.prod.us-west-2.postgun.com with SMTP id 5f17228e8e9b2c49c64aa5cc (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:14:54 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 015B3C4339C; Tue, 21 Jul 2020 17:14:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4650CC43391; Tue, 21 Jul 2020 17:14:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4650CC43391 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 3/7] ath10k: Add module param to enable rx thread Date: Tue, 21 Jul 2020 22:44:22 +0530 Message-Id: <1595351666-28193-4-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add a module parameter to enable or disable the processing of received packets in rx thread. To enable rx packet processing in a thread context, use the belo command to load driver: insmod ath10k_snoc.ko rx_thread_enable=1 Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/core.h | 1 + drivers/net/wireless/ath/ath10k/snoc.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 96919e8..59bdf11 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -998,6 +998,7 @@ struct ath10k { } msa; u8 mac_addr[ETH_ALEN]; + bool rx_thread_enable; struct ath10k_thread rx_thread; enum ath10k_hw_rev hw_rev; u16 dev_id; diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 463c34e..f01725b 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -26,6 +26,12 @@ #define CE_POLL_PIPE 4 #define ATH10K_SNOC_WAKE_IRQ 2 +static bool ath10k_rx_thread_enable; + +module_param_named(rx_thread_enable, ath10k_rx_thread_enable, bool, 0644); + +MODULE_PARM_DESC(rx_thread_enable, "Receive packet processing in thread"); + static char *const ce_name[] = { "WLAN_CE_0", "WLAN_CE_1", @@ -941,7 +947,8 @@ static void ath10k_snoc_hif_stop(struct ath10k *ar) napi_synchronize(&ar->napi); napi_disable(&ar->napi); - ath10k_core_thread_shutdown(ar, &ar->rx_thread); + if (ar->rx_thread_enable) + ath10k_core_thread_shutdown(ar, &ar->rx_thread); ath10k_snoc_buffer_cleanup(ar); ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif stop\n"); } @@ -954,12 +961,14 @@ static int ath10k_snoc_hif_start(struct ath10k *ar) bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX); napi_enable(&ar->napi); - ret = ath10k_core_thread_init(ar, &ar->rx_thread, - ath10k_snoc_rx_thread_loop, - "ath10k_rx_thread"); - if (ret) { - ath10k_err(ar, "failed to start rx thread\n"); - goto rx_thread_fail; + if (ar->rx_thread_enable) { + ret = ath10k_core_thread_init(ar, &ar->rx_thread, + ath10k_snoc_rx_thread_loop, + "ath10k_rx_thread"); + if (ret) { + ath10k_err(ar, "failed to start rx thread\n"); + goto rx_thread_fail; + } } ath10k_snoc_irq_enable(ar); @@ -1693,6 +1702,7 @@ static int ath10k_snoc_probe(struct platform_device *pdev) } ar->rx_thread.ar = ar; + ar->rx_thread_enable = ath10k_rx_thread_enable; ar_snoc = ath10k_snoc_priv(ar); ar_snoc->dev = pdev; platform_set_drvdata(pdev, ar); From patchwork Tue Jul 21 17:14:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676289 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0275C13A4 for ; Tue, 21 Jul 2020 17:15:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDA8A20717 for ; Tue, 21 Jul 2020 17:15:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="BwJ5pO4w" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730763AbgGURPB (ORCPT ); Tue, 21 Jul 2020 13:15:01 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:14780 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730716AbgGURO7 (ORCPT ); Tue, 21 Jul 2020 13:14:59 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351698; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=wMU4DbU33JbajyG3cP1sY2UVCv9Nr6xvONZ479ljK6o=; b=BwJ5pO4wNqTd3ENB6lQV5Ni850eFRHpfxnuLudOcpGI8Jk3l8lqhdED9s0E2R7orYbtYzTDh m/a6brb6rQrX9sCZK1iDKc6jLtRwGbwnDOzTHE+yQTwAvY3XLwmfw5p5dOmWyOCRkF6XpSZ6 bR8KzY6AJ1eOAJ4rRCutItke6tY= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-east-1.postgun.com with SMTP id 5f172292f9ca681bd08d75ca (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:14:58 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 0A83DC433B1; Tue, 21 Jul 2020 17:14:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id DB20FC433C6; Tue, 21 Jul 2020 17:14:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org DB20FC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 4/7] ath10k: Do not exhaust budget on process tx completion Date: Tue, 21 Jul 2020 22:44:23 +0530 Message-Id: <1595351666-28193-5-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Currently the entire NAPI budget is marked as exhausted if any tx completion is processed. In scenarios of bi-directional traffic, this leads to a situation where the irqs are never enabled and the NAPI is rescheuled again and again. Increase the work done quota by the number of tx completions which are processed in the NAPI context. Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/htt_rx.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index cac05e7..a4a6618 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -4077,21 +4077,18 @@ int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget) /* Deliver received data after processing data from hardware */ quota = ath10k_htt_rx_deliver_msdu(ar, quota, budget); - /* From NAPI documentation: - * The napi poll() function may also process TX completions, in which - * case if it processes the entire TX ring then it should count that - * work as the rest of the budget. - */ - if ((quota < budget) && !kfifo_is_empty(&htt->txdone_fifo)) - quota = budget; - /* kfifo_get: called only within txrx_tasklet so it's neatly serialized. * From kfifo_get() documentation: * Note that with only one concurrent reader and one concurrent writer, * you don't need extra locking to use these macro. */ - while (kfifo_get(&htt->txdone_fifo, &tx_done)) + while (kfifo_get(&htt->txdone_fifo, &tx_done)) { ath10k_txrx_tx_unref(htt, &tx_done); + quota++; + } + + if (quota > budget) + resched_napi = true; ath10k_mac_tx_push_pending(ar); From patchwork Tue Jul 21 17:14:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676273 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B63B6C1 for ; Tue, 21 Jul 2020 17:15:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D21720792 for ; Tue, 21 Jul 2020 17:15:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="qwi1HOvk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730796AbgGURPJ (ORCPT ); Tue, 21 Jul 2020 13:15:09 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:14780 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730715AbgGURPF (ORCPT ); Tue, 21 Jul 2020 13:15:05 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351704; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=z+QV2LXb5rbvImIDmNfj9kPQzvqQTO89wCls0vl+oAI=; b=qwi1HOvkz1frPb1kkchVktCZRkkU0dtRK0/Rxh/WAa9tRwuIVkA2tpY7s4cVWa8bq7p1ClsS LbhNBpfHd8R+mrrvJH7Lb5MhUg8Uib8ZCShrihzQVYBGlGwFRdT6wsuspx8IPnrRFwdXug77 44swAm6OxSbKge8mkSsNMA6AIAU= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-west-2.postgun.com with SMTP id 5f172297eef925b694dc15d9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:15:03 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3AF6DC43395; Tue, 21 Jul 2020 17:15:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id BB288C4339C; Tue, 21 Jul 2020 17:14:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BB288C4339C Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 5/7] ath10k: Handle the rx packet processing in thread Date: Tue, 21 Jul 2020 22:44:24 +0530 Message-Id: <1595351666-28193-6-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add the support to handle the receive packet and the tx completion processing in a thread context if the feature has been enabled via module parameter. Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/core.c | 8 ++++++ drivers/net/wireless/ath/ath10k/core.h | 4 +++ drivers/net/wireless/ath/ath10k/htt.h | 2 ++ drivers/net/wireless/ath/ath10k/htt_rx.c | 46 +++++++++++++++++++++++++++----- drivers/net/wireless/ath/ath10k/snoc.c | 12 +++++++-- 5 files changed, 64 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 2b520a0..4064fa2 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -668,6 +668,14 @@ static unsigned int ath10k_core_get_fw_feature_str(char *buf, return scnprintf(buf, buf_len, "%s", ath10k_core_fw_feature_str[feat]); } +void ath10k_core_thread_post_event(struct ath10k_thread *thread, + enum ath10k_thread_events event) +{ + set_bit(event, thread->event_flags); + wake_up(&thread->wait_q); +} +EXPORT_SYMBOL(ath10k_core_thread_post_event); + int ath10k_core_thread_shutdown(struct ath10k *ar, struct ath10k_thread *thread) { diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 59bdf11..596d31b 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -974,6 +974,8 @@ struct ath10k_bus_params { enum ath10k_thread_events { ATH10K_THREAD_EVENT_SHUTDOWN, + ATH10K_THREAD_EVENT_RX_POST, + ATH10K_THREAD_EVENT_TX_POST, ATH10K_THREAD_EVENT_MAX, }; @@ -1294,6 +1296,8 @@ static inline bool ath10k_peer_stats_enabled(struct ath10k *ar) extern unsigned long ath10k_coredump_mask; +void ath10k_core_thread_post_event(struct ath10k_thread *thread, + enum ath10k_thread_events event); int ath10k_core_thread_shutdown(struct ath10k *ar, struct ath10k_thread *thread); int ath10k_core_thread_init(struct ath10k *ar, diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h index cad5949..e3cb723 100644 --- a/drivers/net/wireless/ath/ath10k/htt.h +++ b/drivers/net/wireless/ath/ath10k/htt.h @@ -1970,6 +1970,8 @@ struct ath10k_htt { spinlock_t lock; } rx_ring; + /* Protects access to in order indication queue */ + spinlock_t rx_in_ord_q_lock; unsigned int prefetch_len; /* Protects access to pending_tx, num_pending_tx */ diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index a4a6618..becbd56 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -796,6 +796,7 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt) timer_setup(timer, ath10k_htt_rx_ring_refill_retry, 0); spin_lock_init(&htt->rx_ring.lock); + spin_lock_init(&htt->rx_in_ord_q_lock); htt->rx_ring.fill_cnt = 0; htt->rx_ring.sw_rd_idx.msdu_payld = 0; @@ -2702,10 +2703,17 @@ static void ath10k_htt_rx_tx_compl_ind(struct ath10k *ar, */ if (ar->bus_param.dev_type == ATH10K_DEV_TYPE_HL) { ath10k_txrx_tx_unref(htt, &tx_done); - } else if (!kfifo_put(&htt->txdone_fifo, tx_done)) { - ath10k_warn(ar, "txdone fifo overrun, msdu_id %d status %d\n", - tx_done.msdu_id, tx_done.status); - ath10k_txrx_tx_unref(htt, &tx_done); + } else { + if (!kfifo_put(&htt->txdone_fifo, tx_done)) { + ath10k_warn(ar, "txdone fifo overrun, msdu_id %d status %d\n", + tx_done.msdu_id, tx_done.status); + ath10k_txrx_tx_unref(htt, &tx_done); + continue; + } + if (ar->rx_thread_enable) + ath10k_core_thread_post_event( + &ar->rx_thread, + ATH10K_THREAD_EVENT_TX_POST); } } @@ -3903,7 +3911,16 @@ bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb) break; } case HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND: { - skb_queue_tail(&htt->rx_in_ord_compl_q, skb); + if (!ar->rx_thread_enable) { + skb_queue_tail(&htt->rx_in_ord_compl_q, skb); + } else { + spin_lock_bh(&htt->rx_in_ord_q_lock); + skb_queue_tail(&htt->rx_in_ord_compl_q, skb); + spin_unlock_bh(&htt->rx_in_ord_q_lock); + ath10k_core_thread_post_event( + &ar->rx_thread, + ATH10K_THREAD_EVENT_RX_POST); + } return false; } case HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND: { @@ -4032,6 +4049,23 @@ int ath10k_htt_rx_hl_indication(struct ath10k *ar, int budget) } EXPORT_SYMBOL(ath10k_htt_rx_hl_indication); +static inline struct sk_buff * +ath10k_htt_dequeue_in_ord_q(struct ath10k_htt *htt) +{ + struct ath10k *ar = htt->ar; + struct sk_buff *skb = NULL; + + if (ar->rx_thread_enable) { + spin_lock_bh(&htt->rx_in_ord_q_lock); + skb = skb_dequeue(&htt->rx_in_ord_compl_q); + spin_unlock_bh(&htt->rx_in_ord_q_lock); + } else { + skb = skb_dequeue(&htt->rx_in_ord_compl_q); + } + + return skb; +} + int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget) { struct ath10k_htt *htt = &ar->htt; @@ -4053,7 +4087,7 @@ int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget) goto exit; } - while ((skb = skb_dequeue(&htt->rx_in_ord_compl_q))) { + while ((skb = ath10k_htt_dequeue_in_ord_q(htt))) { spin_lock_bh(&htt->rx_ring.lock); ret = ath10k_htt_rx_in_ord_ind(ar, skb); spin_unlock_bh(&htt->rx_ring.lock); diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index f01725b..3eb5eac 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -920,6 +920,7 @@ int ath10k_snoc_rx_thread_loop(void *data) struct ath10k_thread *rx_thread = data; struct ath10k *ar = rx_thread->ar; bool shutdown = false; + u32 thread_budget = 8192; ath10k_dbg(ar, ATH10K_DBG_SNOC, "rx thread started\n"); set_user_nice(current, -1); @@ -927,8 +928,14 @@ int ath10k_snoc_rx_thread_loop(void *data) while (!shutdown) { wait_event_interruptible( rx_thread->wait_q, - (test_bit(ATH10K_THREAD_EVENT_SHUTDOWN, + (test_and_clear_bit(ATH10K_THREAD_EVENT_RX_POST, + rx_thread->event_flags) || + test_and_clear_bit(ATH10K_THREAD_EVENT_TX_POST, + rx_thread->event_flags) || + test_bit(ATH10K_THREAD_EVENT_SHUTDOWN, rx_thread->event_flags))); + + ath10k_htt_txrx_compl_task(ar, thread_budget); if (test_and_clear_bit(ATH10K_THREAD_EVENT_SHUTDOWN, rx_thread->event_flags)) shutdown = true; @@ -1235,7 +1242,8 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget) ath10k_ce_enable_interrupt(ar, ce_id); } - done = ath10k_htt_txrx_compl_task(ar, budget); + if (!ar->rx_thread_enable) + done = ath10k_htt_txrx_compl_task(ar, budget); if (done < budget) napi_complete(ctx); From patchwork Tue Jul 21 17:14:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676285 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF7E46C1 for ; Tue, 21 Jul 2020 17:15:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5E6A206E9 for ; Tue, 21 Jul 2020 17:15:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="Ik8J7tET" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730861AbgGURPa (ORCPT ); Tue, 21 Jul 2020 13:15:30 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:39508 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730816AbgGURPS (ORCPT ); Tue, 21 Jul 2020 13:15:18 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351718; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=PuxwKGt35tpiRMfDgkpJSCtxDJb7QR6bGP5l0QXwvfc=; b=Ik8J7tET8O55cc09LJc6txOcWHF8GMysuoUqSew4l81xBAPTJKzLll3c9QheET2dOAfCGza9 Stu/Xlb9FxcZq7MqkcqgGPaubJkPOH1TGE4/ZuUtpV+2Rw8CCnSKFMcOmL7rnXOBtnTxo9F6 SiBgv7fdG6vaENh+QWwInwdGYTY= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n10.prod.us-west-2.postgun.com with SMTP id 5f17229b3dbcb593a96abfda (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:15:07 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 5D4D7C433C9; Tue, 21 Jul 2020 17:15:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id 71AECC433CA; Tue, 21 Jul 2020 17:15:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 71AECC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 6/7] ath10k: Add deliver to stack from thread context Date: Tue, 21 Jul 2020 22:44:25 +0530 Message-Id: <1595351666-28193-7-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When the receive packets are submitted to the stack from a thread context, the NAPI handle should be passed as NULL to the function ieee80211_rx_napi. This will make sure that the packets are submitted to stack via non-napi method Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/htt_rx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index becbd56..85c169c 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -1321,7 +1321,10 @@ static void ath10k_process_rx(struct ath10k *ar, struct sk_buff *skb) trace_ath10k_rx_hdr(ar, skb->data, skb->len); trace_ath10k_rx_payload(ar, skb->data, skb->len); - ieee80211_rx_napi(ar->hw, NULL, skb, &ar->napi); + if (in_serving_softirq()) + ieee80211_rx_napi(ar->hw, NULL, skb, &ar->napi); + else + ieee80211_rx_napi(ar->hw, NULL, skb, NULL); } static int ath10k_htt_rx_nwifi_hdrlen(struct ath10k *ar, From patchwork Tue Jul 21 17:14:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rakesh Pillai X-Patchwork-Id: 11676275 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 152146C1 for ; Tue, 21 Jul 2020 17:15:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB16220717 for ; Tue, 21 Jul 2020 17:15:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="vateL62j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730846AbgGURPQ (ORCPT ); Tue, 21 Jul 2020 13:15:16 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:14780 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730832AbgGURPO (ORCPT ); Tue, 21 Jul 2020 13:15:14 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1595351713; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=gBDtbC3k7fmgMEBji3WDa1vS2HhVYXF0ZlougiQfyKI=; b=vateL62jR89d8yju2u9mw9YLWeuEZa18sLFjG+uYJ1L3cUAiLXo1lGH3/o6V39fO+Nva6Z7q ePE7tQrh6YyI+KtdKVB8+IbIYFWSC7WNMEC/Tz6NhMxQnbI8AohBFDo0Q28nctGGvAqQYzJI m4cVHppPqf1RMR3WiEt5xGStcFg= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n08.prod.us-east-1.postgun.com with SMTP id 5f1722a1f9ca681bd08d9cc2 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 21 Jul 2020 17:15:13 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8CB73C433B2; Tue, 21 Jul 2020 17:15:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from pillair-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pillair) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7D497C433A1; Tue, 21 Jul 2020 17:15:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7D497C433A1 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=pillair@codeaurora.org From: Rakesh Pillai To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, kvalo@codeaurora.org, johannes@sipsolutions.net, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, dianders@chromium.org, evgreen@chromium.org, Rakesh Pillai Subject: [RFC 7/7] ath10k: Handle rx thread suspend and resume Date: Tue, 21 Jul 2020 22:44:26 +0530 Message-Id: <1595351666-28193-8-git-send-email-pillair@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> References: <1595351666-28193-1-git-send-email-pillair@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org During the system suspend or resume, the rx thread also needs to be suspended or resume respectively. Handle the rx thread as well during the system suspend and resume. Tested-on: WCN3990 hw1.0 SNOC WLAN.HL.3.1-01040-QCAHLSWMTPLZ-1 Signed-off-by: Rakesh Pillai --- drivers/net/wireless/ath/ath10k/core.c | 23 ++++++++++++++++++ drivers/net/wireless/ath/ath10k/core.h | 5 ++++ drivers/net/wireless/ath/ath10k/snoc.c | 44 +++++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 4064fa2..b82b355 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -668,6 +668,27 @@ static unsigned int ath10k_core_get_fw_feature_str(char *buf, return scnprintf(buf, buf_len, "%s", ath10k_core_fw_feature_str[feat]); } +int ath10k_core_thread_suspend(struct ath10k_thread *thread) +{ + ath10k_dbg(thread->ar, ATH10K_DBG_BOOT, "Suspending thread %s\n", + thread->name); + set_bit(ATH10K_THREAD_EVENT_SUSPEND, thread->event_flags); + wait_for_completion(&thread->suspend); + + return 0; +} +EXPORT_SYMBOL(ath10k_core_thread_suspend); + +int ath10k_core_thread_resume(struct ath10k_thread *thread) +{ + ath10k_dbg(thread->ar, ATH10K_DBG_BOOT, "Resuming thread %s\n", + thread->name); + complete(&thread->resume); + + return 0; +} +EXPORT_SYMBOL(ath10k_core_thread_resume); + void ath10k_core_thread_post_event(struct ath10k_thread *thread, enum ath10k_thread_events event) { @@ -700,6 +721,8 @@ int ath10k_core_thread_init(struct ath10k *ar, init_waitqueue_head(&thread->wait_q); init_completion(&thread->shutdown); + init_completion(&thread->suspend); + init_completion(&thread->resume); memcpy(thread->name, thread_name, ATH10K_THREAD_NAME_SIZE_MAX); clear_bit(ATH10K_THREAD_EVENT_SHUTDOWN, thread->event_flags); ath10k_info(ar, "Starting thread %s\n", thread_name); diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 596d31b..df65e75 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -976,6 +976,7 @@ enum ath10k_thread_events { ATH10K_THREAD_EVENT_SHUTDOWN, ATH10K_THREAD_EVENT_RX_POST, ATH10K_THREAD_EVENT_TX_POST, + ATH10K_THREAD_EVENT_SUSPEND, ATH10K_THREAD_EVENT_MAX, }; @@ -983,6 +984,8 @@ struct ath10k_thread { struct ath10k *ar; struct task_struct *task; struct completion shutdown; + struct completion suspend; + struct completion resume; wait_queue_head_t wait_q; DECLARE_BITMAP(event_flags, ATH10K_THREAD_EVENT_MAX); char name[ATH10K_THREAD_NAME_SIZE_MAX]; @@ -1296,6 +1299,8 @@ static inline bool ath10k_peer_stats_enabled(struct ath10k *ar) extern unsigned long ath10k_coredump_mask; +int ath10k_core_thread_suspend(struct ath10k_thread *thread); +int ath10k_core_thread_resume(struct ath10k_thread *thread); void ath10k_core_thread_post_event(struct ath10k_thread *thread, enum ath10k_thread_events event); int ath10k_core_thread_shutdown(struct ath10k *ar, diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 3eb5eac..a373b2b 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -932,13 +932,31 @@ int ath10k_snoc_rx_thread_loop(void *data) rx_thread->event_flags) || test_and_clear_bit(ATH10K_THREAD_EVENT_TX_POST, rx_thread->event_flags) || + test_bit(ATH10K_THREAD_EVENT_SUSPEND, + rx_thread->event_flags) || test_bit(ATH10K_THREAD_EVENT_SHUTDOWN, rx_thread->event_flags))); + if (test_and_clear_bit(ATH10K_THREAD_EVENT_SUSPEND, + rx_thread->event_flags)) { + complete(&rx_thread->suspend); + ath10k_info(ar, "rx thread suspend\n"); + wait_for_completion(&rx_thread->resume); + ath10k_info(ar, "rx thread resume\n"); + } + ath10k_htt_txrx_compl_task(ar, thread_budget); if (test_and_clear_bit(ATH10K_THREAD_EVENT_SHUTDOWN, rx_thread->event_flags)) shutdown = true; + + if (test_and_clear_bit(ATH10K_THREAD_EVENT_SUSPEND, + rx_thread->event_flags)) { + complete(&rx_thread->suspend); + ath10k_info(ar, "rx thread suspend\n"); + wait_for_completion(&rx_thread->resume); + ath10k_info(ar, "rx thread resume\n"); + } } ath10k_dbg(ar, ATH10K_DBG_SNOC, "rx thread exiting\n"); @@ -1133,15 +1151,30 @@ static int ath10k_snoc_hif_suspend(struct ath10k *ar) if (!device_may_wakeup(ar->dev)) return -EPERM; + if (ar->rx_thread_enable) { + ret = ath10k_core_thread_suspend(&ar->rx_thread); + if (ret) { + ath10k_err(ar, "failed to suspend rx_thread, %d\n", + ret); + return ret; + } + } + ret = enable_irq_wake(ar_snoc->ce_irqs[ATH10K_SNOC_WAKE_IRQ].irq_line); if (ret) { ath10k_err(ar, "failed to enable wakeup irq :%d\n", ret); - return ret; + goto fail; } ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc device suspended\n"); return ret; + +fail: + if (ar->rx_thread_enable) + ath10k_core_thread_resume(&ar->rx_thread); + + return ret; } static int ath10k_snoc_hif_resume(struct ath10k *ar) @@ -1158,6 +1191,15 @@ static int ath10k_snoc_hif_resume(struct ath10k *ar) return ret; } + if (ar->rx_thread_enable) { + ret = ath10k_core_thread_resume(&ar->rx_thread); + if (ret) { + ath10k_err(ar, "failed to suspend rx_thread, %d\n", + ret); + return ret; + } + } + ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc device resumed\n"); return ret;