From patchwork Tue Aug 25 05:29:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 259496 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDE1CC433E1 for ; Tue, 25 Aug 2020 05:29:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6232020706 for ; Tue, 25 Aug 2020 05:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="ob2fivK1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728663AbgHYF3R (ORCPT ); Tue, 25 Aug 2020 01:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbgHYF3Q (ORCPT ); Tue, 25 Aug 2020 01:29:16 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2D1C061574 for ; Mon, 24 Aug 2020 22:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ji4VBIcwno29gBLF3yej07qC7lixrXX1GXJhNwV01B8=; b=ob2fivK1XvgLcTO5MS05uABedY vXkpkd3perzzhrZL/WbUK3SXsc+8foFWBpfUOQip/3uVorl0Pxn5K2ehbpkIBPf2OtHkFVqhW9nNc zn2ISKZtPfwLiKKBQ6+Qc9/e0YPopN7V4G+cu5dGjIGzGAe/Y7Jy9t10fivizhm0FdrI=; Received: from p5b206497.dip0.t-ipconnect.de ([91.32.100.151] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1kARWB-0006jr-DB for linux-wireless@vger.kernel.org; Tue, 25 Aug 2020 07:29:11 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 2/9] mt76: mt7915: optimize mt7915_mac_sta_poll Date: Tue, 25 Aug 2020 07:29:02 +0200 Message-Id: <20200825052909.36955-2-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200825052909.36955-1-nbd@nbd.name> References: <20200825052909.36955-1-nbd@nbd.name> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since DMA completion does not imply tx completion, it makes more sense to poll for airtime from mt7915_mac_tx_free. Reduce the runtime of the function by moving all items from dev->sta_poll_list to a local list once and process any stations that were added afterwards on the next run Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7915/dma.c | 1 - drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 13 ++++++++++--- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 1 - 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/dma.c b/drivers/net/wireless/mediatek/mt76/mt7915/dma.c index 8a1ae08d9572..f6c18a08d414 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/dma.c @@ -95,7 +95,6 @@ static int mt7915_poll_tx(struct napi_struct *napi, int budget) dev = container_of(napi, struct mt7915_dev, mt76.tx_napi); mt7915_tx_cleanup(dev); - mt7915_mac_sta_poll(dev); tasklet_schedule(&dev->mt76.tx_tasklet); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index ff08a59c747c..06bb8d0103ba 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -97,7 +97,7 @@ static u32 mt7915_mac_wtbl_lmac_addr(struct mt7915_dev *dev, u16 wcid) } /* TODO: use txfree airtime info to avoid runtime accessing in the long run */ -void mt7915_mac_sta_poll(struct mt7915_dev *dev) +static void mt7915_mac_sta_poll(struct mt7915_dev *dev) { static const u8 ac_to_tid[] = { [IEEE80211_AC_BE] = 0, @@ -114,8 +114,13 @@ void mt7915_mac_sta_poll(struct mt7915_dev *dev) struct ieee80211_sta *sta; struct mt7915_sta *msta; u32 tx_time[IEEE80211_NUM_ACS], rx_time[IEEE80211_NUM_ACS]; + LIST_HEAD(sta_poll_list); int i; + spin_lock_bh(&dev->sta_poll_lock); + list_splice_init(&dev->sta_poll_list, &sta_poll_list); + spin_unlock_bh(&dev->sta_poll_lock); + rcu_read_lock(); while (true) { @@ -124,11 +129,11 @@ void mt7915_mac_sta_poll(struct mt7915_dev *dev) u16 idx; spin_lock_bh(&dev->sta_poll_lock); - if (list_empty(&dev->sta_poll_list)) { + if (list_empty(&sta_poll_list)) { spin_unlock_bh(&dev->sta_poll_lock); break; } - msta = list_first_entry(&dev->sta_poll_list, + msta = list_first_entry(&sta_poll_list, struct mt7915_sta, poll_list); list_del_init(&msta->poll_list); spin_unlock_bh(&dev->sta_poll_lock); @@ -929,6 +934,8 @@ void mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) mt76_put_txwi(mdev, txwi); } dev_kfree_skb(skb); + + mt7915_mac_sta_poll(dev); } void mt7915_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid, diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index cbe84c4aac75..63d4802b4df4 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -436,7 +436,6 @@ mt7915_l2_rmw(struct mt7915_dev *dev, u32 addr, u32 mask, u32 val) bool mt7915_mac_wtbl_update(struct mt7915_dev *dev, int idx, u32 mask); void mt7915_mac_reset_counters(struct mt7915_phy *phy); void mt7915_mac_cca_stats_reset(struct mt7915_phy *phy); -void mt7915_mac_sta_poll(struct mt7915_dev *dev); void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi, struct sk_buff *skb, struct mt76_wcid *wcid, struct ieee80211_key_conf *key, bool beacon); From patchwork Tue Aug 25 05:29:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 259495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8EFBC433DF for ; Tue, 25 Aug 2020 05:29:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C85C720706 for ; Tue, 25 Aug 2020 05:29:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="O+f1AH8M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728693AbgHYF3S (ORCPT ); Tue, 25 Aug 2020 01:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728622AbgHYF3R (ORCPT ); Tue, 25 Aug 2020 01:29:17 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAD24C061796 for ; Mon, 24 Aug 2020 22:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XOwdHT1y0DdvcLP02NShNpxqbyii12ZCmDzCiI4VM8E=; b=O+f1AH8M3A+c0YXri9mK/gQGAd Yb0juthhMRcaSowIqkAdOHg9z9lS5sln+7PAfBATjMb6l0kpZUo4FMKG3Vii5HGvcI/YmF6+PXObV UPsdXP/l8Cb/9f8uKRWD8VgHqYCZ27ndxaEG1fjor70quOKvR7rMpt33F7VHq19cYmXI=; Received: from p5b206497.dip0.t-ipconnect.de ([91.32.100.151] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1kARWB-0006jr-JL for linux-wireless@vger.kernel.org; Tue, 25 Aug 2020 07:29:11 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 3/9] mt76: dma: update q->queued immediately on cleanup Date: Tue, 25 Aug 2020 07:29:03 +0200 Message-Id: <20200825052909.36955-3-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200825052909.36955-1-nbd@nbd.name> References: <20200825052909.36955-1-nbd@nbd.name> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Tx cleanup and tx enqueuing can run in parallel. In order to avoid queue starvation issues under load, update q->queued immediately. Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/dma.c | 39 +++++++++--------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index ade2d58b8da9..7545b552db25 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -152,10 +152,8 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) struct mt76_sw_queue *sq = &dev->q_tx[qid]; struct mt76_queue *q = sq->q; struct mt76_queue_entry entry; - unsigned int n_swq_queued[8] = {}; - unsigned int n_queued = 0; bool wake = false; - int i, last; + int last; if (!q) return; @@ -165,13 +163,14 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) else last = readl(&q->regs->dma_idx); - while ((q->queued > n_queued) && q->tail != last) { + while (q->queued > 0 && q->tail != last) { + int swq_qid = -1; + mt76_dma_tx_cleanup_idx(dev, q, q->tail, &entry); if (entry.schedule) - n_swq_queued[entry.qid]++; + swq_qid = entry.qid; q->tail = (q->tail + 1) % q->ndesc; - n_queued++; if (entry.skb) dev->drv->tx_complete_skb(dev, qid, &entry); @@ -184,29 +183,21 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) if (!flush && q->tail == last) last = readl(&q->regs->dma_idx); - } - - spin_lock_bh(&q->lock); - - q->queued -= n_queued; - for (i = 0; i < 4; i++) { - if (!n_swq_queued[i]) - continue; - dev->q_tx[i].swq_queued -= n_swq_queued[i]; - } - - /* ext PHY */ - for (i = 0; i < 4; i++) { - if (!n_swq_queued[i]) - continue; - - dev->q_tx[__MT_TXQ_MAX + i].swq_queued -= n_swq_queued[4 + i]; + spin_lock_bh(&q->lock); + if (swq_qid >= 4) + dev->q_tx[__MT_TXQ_MAX + swq_qid - 4].swq_queued--; + else if (swq_qid >= 0) + dev->q_tx[swq_qid].swq_queued--; + q->queued--; + spin_unlock_bh(&q->lock); } if (flush) { + spin_lock_bh(&q->lock); mt76_dma_sync_idx(dev, q); mt76_dma_kick_queue(dev, q); + spin_unlock_bh(&q->lock); } wake = wake && q->stopped && @@ -217,8 +208,6 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, enum mt76_txq_id qid, bool flush) if (!q->queued) wake_up(&dev->tx_wait); - spin_unlock_bh(&q->lock); - if (wake) ieee80211_wake_queue(dev->hw, qid); } From patchwork Tue Aug 25 05:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 259493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23D1CC433E1 for ; Tue, 25 Aug 2020 05:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED76020706 for ; Tue, 25 Aug 2020 05:29:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="XyBCJrsh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728715AbgHYF3Z (ORCPT ); Tue, 25 Aug 2020 01:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728653AbgHYF3R (ORCPT ); Tue, 25 Aug 2020 01:29:17 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCA48C061799 for ; Mon, 24 Aug 2020 22:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rA1DOLXwQ59WC5TTbobxF30UxtUDddp+8OTrnM1mI7g=; b=XyBCJrsh8tNXN9PBGYQsWRoQE1 KIyZQXlVd5bb8OF+sKFr2xS7z6ffUylGmERKfwBbsO9xhGVxgQSkrIUymx8teD8y4+1bh0e4NB7Ho KEc6DboUAKTeFCK6l2KyDicQOCej49CB3uICZwKdjY/MIPlhjdEZdEEQb5npUvO8iyJE=; Received: from p5b206497.dip0.t-ipconnect.de ([91.32.100.151] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1kARWB-0006jr-OQ for linux-wireless@vger.kernel.org; Tue, 25 Aug 2020 07:29:11 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 4/9] mt76: mt7915: schedule tx tasklet in mt7915_mac_tx_free Date: Tue, 25 Aug 2020 07:29:04 +0200 Message-Id: <20200825052909.36955-4-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200825052909.36955-1-nbd@nbd.name> References: <20200825052909.36955-1-nbd@nbd.name> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The previous scheduling round may have been limited by AQL. More frames might be available after the tx free run. Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7915/dma.c | 2 -- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/dma.c b/drivers/net/wireless/mediatek/mt76/mt7915/dma.c index f6c18a08d414..34e90bb08f0a 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/dma.c @@ -96,8 +96,6 @@ static int mt7915_poll_tx(struct napi_struct *napi, int budget) mt7915_tx_cleanup(dev); - tasklet_schedule(&dev->mt76.tx_tasklet); - if (napi_complete_done(napi, 0)) mt7915_irq_enable(dev, MT_INT_TX_DONE_ALL); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index 06bb8d0103ba..9c920c9f4d2b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -936,6 +936,7 @@ void mt7915_mac_tx_free(struct mt7915_dev *dev, struct sk_buff *skb) dev_kfree_skb(skb); mt7915_mac_sta_poll(dev); + tasklet_schedule(&dev->mt76.tx_tasklet); } void mt7915_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid, From patchwork Tue Aug 25 05:29:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 259492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BD1DC433DF for ; Tue, 25 Aug 2020 05:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 49FEC20706 for ; Tue, 25 Aug 2020 05:29:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="WrwbczPT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728734AbgHYF30 (ORCPT ); Tue, 25 Aug 2020 01:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728634AbgHYF3R (ORCPT ); Tue, 25 Aug 2020 01:29:17 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C72A2C061798 for ; Mon, 24 Aug 2020 22:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=oTlMHVJTCGDIdsFY9l+qPDvYKh3D2w670EcotbAbM7s=; b=WrwbczPTmatyBWHsDdMcNn9ZX1 KAy0L7LHyBQ6HyzJJyBODPw0gPqKoBrrTLqhx8nSyEaRm9QTEbeArrHsWzoai4uHpblCx/zkSa4b4 uVfAz7TOXfjtx5f4Nm1mRrNcVL+8qlEX05IuNUscHH0cfgevsMD+pdcCcwGMPM/VQTCY=; Received: from p5b206497.dip0.t-ipconnect.de ([91.32.100.151] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1kARWC-0006jr-7w for linux-wireless@vger.kernel.org; Tue, 25 Aug 2020 07:29:12 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 6/9] mt76: mt7615: significantly reduce interrupt load Date: Tue, 25 Aug 2020 07:29:06 +0200 Message-Id: <20200825052909.36955-6-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200825052909.36955-1-nbd@nbd.name> References: <20200825052909.36955-1-nbd@nbd.name> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 7615 and newer, DMA completion only triggers unmap, but not free of queued skbs, since pointers to packets are queued internally. Because of that, there is no need to process the main data queue immediately on DMA completion. To improve performance, mask out the DMA data queue completion interrupt and process the queue only when we receive a txfree event. This brings the number of interrupts under load down to a small fraction. Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7615/dma.c | 24 +++---------------- .../net/wireless/mediatek/mt76/mt7615/mac.c | 8 +++++++ .../net/wireless/mediatek/mt76/mt7615/mmio.c | 8 +++---- .../wireless/mediatek/mt76/mt7615/mt7615.h | 5 ++++ 4 files changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/dma.c b/drivers/net/wireless/mediatek/mt76/mt7615/dma.c index 3b375fdf31b8..abb83d4e7712 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/dma.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/dma.c @@ -94,34 +94,16 @@ mt7615_init_tx_queues(struct mt7615_dev *dev) return 0; } -static void -mt7615_tx_cleanup(struct mt7615_dev *dev) -{ - int i; - - mt76_queue_tx_cleanup(dev, MT_TXQ_MCU, false); - mt76_queue_tx_cleanup(dev, MT_TXQ_PSD, false); - if (is_mt7615(&dev->mt76)) { - mt76_queue_tx_cleanup(dev, MT_TXQ_BE, false); - } else { - for (i = 0; i < IEEE80211_NUM_ACS; i++) - mt76_queue_tx_cleanup(dev, i, false); - } -} - static int mt7615_poll_tx(struct napi_struct *napi, int budget) { struct mt7615_dev *dev; dev = container_of(napi, struct mt7615_dev, mt76.tx_napi); - mt7615_tx_cleanup(dev); - - mt7615_pm_power_save_sched(dev); - tasklet_schedule(&dev->mt76.tx_tasklet); + mt76_queue_tx_cleanup(dev, MT_TXQ_MCU, false); if (napi_complete_done(napi, 0)) - mt7615_irq_enable(dev, MT_INT_TX_DONE_ALL); + mt7615_irq_enable(dev, mt7615_tx_mcu_int_mask(dev)); return 0; } @@ -305,7 +287,7 @@ int mt7615_dma_init(struct mt7615_dev *dev) MT_WPDMA_GLO_CFG_RX_DMA_EN); /* enable interrupts for TX/RX rings */ - mt7615_irq_enable(dev, MT_INT_RX_DONE_ALL | MT_INT_TX_DONE_ALL | + mt7615_irq_enable(dev, MT_INT_RX_DONE_ALL | mt7615_tx_mcu_int_mask(dev) | MT_INT_MCU_CMD); if (is_mt7622(&dev->mt76)) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index e4aeba17da67..9b8fbf26cd1e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -1424,6 +1424,14 @@ static void mt7615_mac_tx_free(struct mt7615_dev *dev, struct sk_buff *skb) struct mt7615_tx_free *free = (struct mt7615_tx_free *)skb->data; u8 i, count; + mt76_queue_tx_cleanup(dev, MT_TXQ_PSD, false); + if (is_mt7615(&dev->mt76)) { + mt76_queue_tx_cleanup(dev, MT_TXQ_BE, false); + } else { + for (i = 0; i < IEEE80211_NUM_ACS; i++) + mt76_queue_tx_cleanup(dev, i, false); + } + count = FIELD_GET(MT_TX_FREE_MSDU_ID_CNT, le16_to_cpu(free->ctrl)); if (is_mt7615(&dev->mt76)) { __le16 *token = &free->token[0]; diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c b/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c index 99ece641bdef..6de492a4cf02 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mmio.c @@ -101,7 +101,7 @@ static irqreturn_t mt7615_irq_handler(int irq, void *dev_instance) static void mt7615_irq_tasklet(unsigned long data) { struct mt7615_dev *dev = (struct mt7615_dev *)data; - u32 intr, mask = 0; + u32 intr, mask = 0, tx_mcu_mask = mt7615_tx_mcu_int_mask(dev); mt76_wr(dev, MT_INT_MASK_CSR, 0); @@ -112,11 +112,11 @@ static void mt7615_irq_tasklet(unsigned long data) trace_dev_irq(&dev->mt76, intr, dev->mt76.mmio.irqmask); mask |= intr & MT_INT_RX_DONE_ALL; - if (intr & MT_INT_TX_DONE_ALL) - mask |= MT_INT_TX_DONE_ALL; + if (intr & tx_mcu_mask) + mask |= tx_mcu_mask; mt76_set_irq_mask(&dev->mt76, MT_INT_MASK_CSR, mask, 0); - if (intr & MT_INT_TX_DONE_ALL) + if (intr & tx_mcu_mask) napi_schedule(&dev->mt76.tx_napi); if (intr & MT_INT_RX_DONE(0)) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 7567485256f8..bcd09cc52ce8 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -540,6 +540,11 @@ static inline u8 mt7615_lmac_mapping(struct mt7615_dev *dev, u8 ac) return lmac_queue_map[ac]; } +static inline u32 mt7615_tx_mcu_int_mask(struct mt7615_dev *dev) +{ + return MT_INT_TX_DONE(dev->mt76.q_tx[MT_TXQ_MCU].q->hw_idx); +} + void mt7615_dma_reset(struct mt7615_dev *dev); void mt7615_scan_work(struct work_struct *work); void mt7615_roc_work(struct work_struct *work); From patchwork Tue Aug 25 05:29:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Fietkau X-Patchwork-Id: 259494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 515DFC433E3 for ; Tue, 25 Aug 2020 05:29:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3238220706 for ; Tue, 25 Aug 2020 05:29:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=nbd.name header.i=@nbd.name header.b="KZ/UJhul" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728670AbgHYF3R (ORCPT ); Tue, 25 Aug 2020 01:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728333AbgHYF3Q (ORCPT ); Tue, 25 Aug 2020 01:29:16 -0400 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9BE4C0613ED for ; Mon, 24 Aug 2020 22:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=TQUY20uymugMjzesOEr4DiO2q9rqRWCCRtR6t9JNX6c=; b=KZ/UJhulXhT4ttCslp4l2I8IZA lLV0z/sEPUIvtL8PWLRraZru242rMgkorwujOnym7aFkxmRtTnUQjStnDyv/Z3nNwZYMoj7ZWGrnD 0AOd/N//9i42QbsErV3mrMOcIj/2IiE40rO9OWC/4fBNcSB1fcQeq752Ze2mLT3ieVxw=; Received: from p5b206497.dip0.t-ipconnect.de ([91.32.100.151] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1kARWC-0006jr-RD for linux-wireless@vger.kernel.org; Tue, 25 Aug 2020 07:29:12 +0200 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH 9/9] mt76: mt7603: check for single-stream EEPROM configuration Date: Tue, 25 Aug 2020 07:29:09 +0200 Message-Id: <20200825052909.36955-9-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200825052909.36955-1-nbd@nbd.name> References: <20200825052909.36955-1-nbd@nbd.name> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Some devices using MT7628 or MT7603 have only one antenna chain connected. Detect these using the EEPROM rx/tx path settings Reported-by: Qin Wei Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h | 3 +++ drivers/net/wireless/mediatek/mt76/mt7603/init.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h index b893facfba48..4687d6dc00dc 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h @@ -85,4 +85,7 @@ enum mt7603_eeprom_source { MT_EE_SRC_FLASH, }; +#define MT_EE_NIC_CONF_0_RX_PATH GENMASK(3, 0) +#define MT_EE_NIC_CONF_0_TX_PATH GENMASK(7, 4) + #endif diff --git a/drivers/net/wireless/mediatek/mt76/mt7603/init.c b/drivers/net/wireless/mediatek/mt76/mt7603/init.c index 94196599797e..43dbabccc083 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7603/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7603/init.c @@ -510,11 +510,17 @@ mt7603_init_txpower(struct mt7603_dev *dev, } } +static inline bool is_mt7688(struct mt7603_dev *dev) +{ + return mt76_rr(dev, MT_EFUSE_BASE + 0x64) & BIT(4); +} + int mt7603_register_device(struct mt7603_dev *dev) { struct mt76_bus_ops *bus_ops; struct ieee80211_hw *hw = mt76_hw(dev); struct wiphy *wiphy = hw->wiphy; + u8 *eeprom = (u8 *)dev->mt76.eeprom.data; int ret; dev->bus_ops = dev->mt76.bus; @@ -536,9 +542,11 @@ int mt7603_register_device(struct mt7603_dev *dev) tasklet_init(&dev->mt76.pre_tbtt_tasklet, mt7603_pre_tbtt_tasklet, (unsigned long)dev); - /* Check for 7688, which only has 1SS */ + /* Check for 1SS devices */ dev->mphy.antenna_mask = 3; - if (mt76_rr(dev, MT_EFUSE_BASE + 0x64) & BIT(4)) + if (FIELD_GET(MT_EE_NIC_CONF_0_RX_PATH, eeprom[MT_EE_NIC_CONF_0]) == 1 || + FIELD_GET(MT_EE_NIC_CONF_0_TX_PATH, eeprom[MT_EE_NIC_CONF_0]) == 1 || + is_mt7688(dev)) dev->mphy.antenna_mask = 1; dev->slottime = 9;