Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5023051pxu; Thu, 10 Dec 2020 10:58:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRql0BZEy2hoM5z0xpu+ivFfHAgprgyoaMIhUWbR4GYER2f4zS4RUJukHgW7S+d2u1p8Qg X-Received: by 2002:a17:906:1955:: with SMTP id b21mr7689906eje.236.1607626684821; Thu, 10 Dec 2020 10:58:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607626684; cv=none; d=google.com; s=arc-20160816; b=Alm70KBQuZLGdc03r5DcETpOYNk2i7AVYrEfBars7qDbdwACaW+oUueqxw82z0FpPX /pQNbnPv1ztWetex2mnr1phPEBqrJr4h/v2bbF6ap5D7qLey4MCZb4xBhUZZ5Q70TO9d nYcymmkj3a41a2etH57tRLJlcxLecgrGP/8QysZ2kkmRBPr+TyvLbO4YM2ZZEA9PlPuk BI0KppN0TIJPeTSTlxc9hpOxxkDQQDwvKZfk8XeunNRokc5IEJEUeLl18xFjVhBI90sK 173UQmyAu7dw9iydz0uckNrruD7hFvN3XIVIeEcrECBCgXxfDyWBrT2lnde4rrbCdwGN QQVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Pss7NDVr0oJC4VGY5UrryGUxEEC2wRYbsDF+mpyzWhM=; b=J6XPKQ5254yAIQWy4WQPFTS8zH4fdQaj98rrRmdhMruY0Ht1IUv4vKnY9ErvsSAh8r r8tNFxZBMV8Iu+2VgK7S8H5CDAmCPdorWrdvlxX5BGBI0EVdTU8v0rbjJDg1SPGoRiv7 LVtCs0F19VKEx9HbG9ynzyJ2KKTgSjPCkJlnFtCf7o8OOoFphEVRGSP4eNmNRuNFK45A IOYso79XNjVb+RVEFv/izzK1MVfC7dUvhM5nA9vUOb8Dfcm4yDv9A9NQWJSn1mDBlDer Nevqv6048FMxFo0Sn2eLdTbd/iN/zNOKyB+NbkpeGEVRoIM6ffSB65yzgQYuc5rVMK8Q jqLg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si3435620edk.307.2020.12.10.10.57.21; Thu, 10 Dec 2020 10:58:04 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393216AbgLJSwl (ORCPT + 99 others); Thu, 10 Dec 2020 13:52:41 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:53274 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2392891AbgLJSwh (ORCPT ); Thu, 10 Dec 2020 13:52:37 -0500 X-UUID: 8c118315fcc04df98a457613fa715309-20201211 X-UUID: 8c118315fcc04df98a457613fa715309-20201211 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1625513374; Fri, 11 Dec 2020 02:51:43 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 11 Dec 2020 02:51:40 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 11 Dec 2020 02:51:40 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , , , Ryder Lee Subject: [PATCH v3 1/2] mt76: mt7915: reset token when mac_reset happens Date: Fri, 11 Dec 2020 02:51:37 +0800 Message-ID: <69d62cd40ae52e0ddd5b26ba96bc7480385585a5.1607578601.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 225B7377B2753A1E346F1B38FD736EE081DDCEA978D63034C899BE98C32847EA2000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Reset buffering token in mt7915_mac_reset_work() to avoid possible leakege, which leads to Tx stop after mac reset. Tested-by: Bo Jiao Signed-off-by: Ryder Lee --- change since v3 - none change since v2 - rebase on top of latest codebase --- .../net/wireless/mediatek/mt76/mt7915/init.c | 18 +------------- .../net/wireless/mediatek/mt76/mt7915/mac.c | 24 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index ed4635bd151a..255ccd7e3d27 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -672,28 +672,12 @@ int mt7915_register_device(struct mt7915_dev *dev) void mt7915_unregister_device(struct mt7915_dev *dev) { - struct mt76_txwi_cache *txwi; - int id; - mt7915_unregister_ext_phy(dev); mt76_unregister_device(&dev->mt76); mt7915_mcu_exit(dev); mt7915_dma_cleanup(dev); - spin_lock_bh(&dev->token_lock); - idr_for_each_entry(&dev->token, txwi, id) { - mt7915_txp_skb_unmap(&dev->mt76, txwi); - if (txwi->skb) { - struct ieee80211_hw *hw; - - hw = mt76_tx_status_get_hw(&dev->mt76, txwi->skb); - ieee80211_free_txskb(hw, txwi->skb); - } - mt76_put_txwi(&dev->mt76, txwi); - dev->token_count--; - } - spin_unlock_bh(&dev->token_lock); - idr_destroy(&dev->token); + mt7915_tx_token_put(dev); mt76_free_device(&dev->mt76); } diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c index f504eeb221f9..1b4d65310b88 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1485,6 +1485,27 @@ mt7915_dma_reset(struct mt7915_phy *phy) MT_WFDMA1_GLO_CFG_TX_DMA_EN | MT_WFDMA1_GLO_CFG_RX_DMA_EN); } +void mt7915_tx_token_put(struct mt7915_dev *dev) +{ + struct mt76_txwi_cache *txwi; + int id; + + spin_lock_bh(&dev->token_lock); + idr_for_each_entry(&dev->token, txwi, id) { + mt7915_txp_skb_unmap(&dev->mt76, txwi); + if (txwi->skb) { + struct ieee80211_hw *hw; + + hw = mt76_tx_status_get_hw(&dev->mt76, txwi->skb); + ieee80211_free_txskb(hw, txwi->skb); + } + mt76_put_txwi(&dev->mt76, txwi); + dev->token_count--; + } + spin_unlock_bh(&dev->token_lock); + idr_destroy(&dev->token); +} + /* system error recovery */ void mt7915_mac_reset_work(struct work_struct *work) { @@ -1525,6 +1546,9 @@ void mt7915_mac_reset_work(struct work_struct *work) mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_DMA_STOPPED); + mt7915_tx_token_put(dev); + idr_init(&dev->token); + if (mt7915_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) { mt7915_dma_reset(&dev->phy); diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h index 0339abf360d3..94bed8a3a050 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -463,6 +463,7 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct ieee80211_sta *sta, struct mt76_tx_info *tx_info); void mt7915_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e); +void mt7915_tx_token_put(struct mt7915_dev *dev); int mt7915_init_tx_queues(struct mt7915_phy *phy, int idx, int n_desc); void mt7915_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, struct sk_buff *skb); -- 2.18.0