Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp363393pxu; Fri, 4 Dec 2020 05:19:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxGk9PsgURBPDQeGGmq9AsXjKK44KbAwREWXy1L7XI3iuiixKXJIJZn09jGIH016LZSUjM X-Received: by 2002:a17:906:3513:: with SMTP id r19mr6908525eja.445.1607087998275; Fri, 04 Dec 2020 05:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607087998; cv=none; d=google.com; s=arc-20160816; b=Fp/g8K74et9k3Tz9xMYK7d8UWPeK0w9Oog23+6H4AqyAxHdb7UHqkOOToTuKkmQGto O3nWIcZO7jTtAfVvIkTHLMvkdeJ5qd9dhKHke6zE8/p3ItyQ1LlvveLVH4El8hUOhEhO vHAnK2wEusxhpgnfEFpYMSFKQ7qOKLQPmlHj7YJ8D3f4TGmnENWYdlUnc49G77nd+0OP oAqofRoejyjKgnO0mFUG/KwmwEs6dUK+K9TFCEI9yc6SZNb4d0+Me+wUopl/PHdH/Irt +25c1xbY/jqJgmwqDdzp9VS8aGqlS//ZywMPbf2Z0lou2dCTmbyUoPRUNNzEkovsomf+ jItg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=t8pBDJi0dyYUTKOnPVNaknc1WMsZPzCmuNMZgL6xdnQ=; b=SFWAKKPPCrUJkEJMxjwI4/syEpCy3kHtiqbY7ujHmuo7bw1u8kFT90GZR4IsS8Y08X MIhYSp2UAClIZm3AqvjUBeIFJhOKRAPLgh+fxEuzqDJ1CQxjWBEAaj98PBSOY0yOWtnP Dvs3C8wSQuTxNh2Z5/HWnZyl9cJlZBZrAmEYkG5/G4iS+ZLubg5wlf8lEuvubQcD8UyR Vp5nqEj2tfeRfoPDKtzWPJ19bPUi8lY8sjB3uL71StSgrtsXU0D5VXyHV46+DF9hRa5i 9glZPlBL6q3jvn0KdiqoKORnlhueNR04cCS1VtNQw51OOs+uzTmkVB6fvOt3haOgVvnm zuug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ct2lJSgE; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hq4si1352865ejc.14.2020.12.04.05.19.27; Fri, 04 Dec 2020 05:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=ct2lJSgE; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730254AbgLDNSi (ORCPT + 99 others); Fri, 4 Dec 2020 08:18:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbgLDNSh (ORCPT ); Fri, 4 Dec 2020 08:18:37 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3EA7C061A4F for ; Fri, 4 Dec 2020 05:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version: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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=t8pBDJi0dyYUTKOnPVNaknc1WMsZPzCmuNMZgL6xdnQ=; b=ct2lJSgEuMuKjvie8j/9jUsIXU ZjmSsf1TRkOclVEFsRCJqbGXN89gM2RPod8Hio5+ya7JlPykzHrKCiby3DzxVEEExmkdFAett32Ap lQmxindhEM588+nVO2djubFMEY7Z2b9ZY4llbO4KikWX08ZuPxseJuQlHD9iPcfpBCfE=; Received: from p4ff13815.dip0.t-ipconnect.de ([79.241.56.21] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1klAxu-00033k-A2 for linux-wireless@vger.kernel.org; Fri, 04 Dec 2020 14:17:38 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Subject: [PATCH v2 1/3] mt76: improve tx queue stop/wake Date: Fri, 4 Dec 2020 14:17:35 +0100 Message-Id: <20201204131737.41086-1-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Instead of stopping and waking only a single queue, handle all phy tx queues mapped ot the same hardware queue. Also allow the driver to block tx queues Signed-off-by: Felix Fietkau --- drivers/net/wireless/mediatek/mt76/dma.c | 10 ---------- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + drivers/net/wireless/mediatek/mt76/tx.c | 23 ++++++++++++----------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c index bab961ebdf1c..6255f4f0a455 100644 --- a/drivers/net/wireless/mediatek/mt76/dma.c +++ b/drivers/net/wireless/mediatek/mt76/dma.c @@ -220,7 +220,6 @@ static void mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) { struct mt76_queue_entry entry; - bool wake = false; int last; if (!q) @@ -238,7 +237,6 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) if (entry.txwi) { if (!(dev->drv->drv_flags & MT_DRV_TXWI_NO_FREE)) mt76_put_txwi(dev, entry.txwi); - wake = !flush; } if (!flush && q->tail == last) @@ -253,16 +251,8 @@ mt76_dma_tx_cleanup(struct mt76_dev *dev, struct mt76_queue *q, bool flush) spin_unlock_bh(&q->lock); } - wake = wake && q->stopped && - q->qid < IEEE80211_NUM_ACS && q->queued < q->ndesc - 8; - if (wake) - q->stopped = false; - if (!q->queued) wake_up(&dev->tx_wait); - - if (wake) - ieee80211_wake_queue(dev->hw, q->qid); } static void * diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 15d52af24d12..ea80ae188dd6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -136,6 +136,7 @@ struct mt76_queue { int queued; int buf_size; bool stopped; + bool blocked; u8 buf_offset; u8 hw_idx; diff --git a/drivers/net/wireless/mediatek/mt76/tx.c b/drivers/net/wireless/mediatek/mt76/tx.c index 65360067b8fa..4026e5f4f3f3 100644 --- a/drivers/net/wireless/mediatek/mt76/tx.c +++ b/drivers/net/wireless/mediatek/mt76/tx.c @@ -291,12 +291,6 @@ mt76_tx(struct mt76_phy *phy, struct ieee80211_sta *sta, spin_lock_bh(&q->lock); __mt76_tx_queue_skb(phy, qid, skb, wcid, sta, NULL); dev->queue_ops->kick(dev, q); - - if (q->queued > q->ndesc - 8 && !q->stopped) { - ieee80211_stop_queue(phy->hw, skb_get_queue_mapping(skb)); - q->stopped = true; - } - spin_unlock_bh(&q->lock); } EXPORT_SYMBOL_GPL(mt76_tx); @@ -381,6 +375,13 @@ mt76_release_buffered_frames(struct ieee80211_hw *hw, struct ieee80211_sta *sta, } EXPORT_SYMBOL_GPL(mt76_release_buffered_frames); +static bool +mt76_txq_stopped(struct mt76_queue *q) +{ + return q->stopped || q->blocked || + q->queued + MT_TXQ_FREE_THR >= q->ndesc; +} + static int mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q, struct mt76_txq *mtxq) @@ -419,10 +420,7 @@ mt76_txq_send_burst(struct mt76_phy *phy, struct mt76_queue *q, test_bit(MT76_RESET, &phy->state)) return -EBUSY; - if (stop) - break; - - if (q->queued + MT_TXQ_FREE_THR >= q->ndesc) + if (stop || mt76_txq_stopped(q)) break; skb = mt76_txq_dequeue(phy, mtxq); @@ -463,7 +461,7 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid) break; } - if (q->queued + MT_TXQ_FREE_THR >= q->ndesc) + if (mt76_txq_stopped(q)) break; txq = ieee80211_next_txq(phy->hw, qid); @@ -498,11 +496,14 @@ mt76_txq_schedule_list(struct mt76_phy *phy, enum mt76_txq_id qid) void mt76_txq_schedule(struct mt76_phy *phy, enum mt76_txq_id qid) { + struct mt76_queue *q; int len; if (qid >= 4) return; + q = phy->q_tx[qid]; + rcu_read_lock(); do { -- 2.28.0