Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4194092pxu; Wed, 9 Dec 2020 10:33:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyHnSmdEwvggBNO1f+ro9w4EMRl2O1mB8LKe0r7vonXx74ov06JksswgjlLngMGV6NA0hMA X-Received: by 2002:aa7:c547:: with SMTP id s7mr3238487edr.240.1607538839245; Wed, 09 Dec 2020 10:33:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607538839; cv=none; d=google.com; s=arc-20160816; b=lF/jXUgSG32xm5PyF8prKDibGBJItaUCBy5VwXSFHZxOGpIaeH7aSk/UCUx0LZ5xyZ 36oERJpeMIXe9buP/5//BH2t8tdIpwdJth55Oq9XLTl+E8nL2LAnKg4Ys2xOLKlweQlk n18/Y9TekCn4DNZs0fDw/IBU+7YJJ5igm5/dYuI1SwNPjhWT9PfFgpMnQV2P+mQl84qC IEnE76tmoBVj5PG1w/3aalw6MapY9cXsomavu7O6MvWlZAg5usw0kOG8Sjx3fjw2Ko92 cH0XiPHxE7rp0/nLm5rQ5vTuJnDuxjffjhEsn6pAufQXwUgVqlPXFpvXuUeYanRYtr1r IVgg== 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=2Lf4ZitRuBiyGt74+yJweWwk0hhCVdX274Jon1LKc3Y=; b=jxF5d69v33iwVbGZywovOL50B/qNAsTWgdm29MYEnrr16FvHvevIBRXq/2DygwG8PA w6X3/ozoMY57XdhlFWE51KcKy/wZH/owpgffD8HxFV6LeITQBgarjCV2YBadnIimGqZX PCIgxxLpDP54rvJfNeK4mx9ezRGABjvI7fxiKRaXW7T7Axaxu0BZcUnxz5/lMK607FgM JfA1ok1CP4QyX3H0ys7x4xCsZYhcw+Mvavx9P3hYBkbM9rm64kRw+qNbonB4wIVb6qWA 41CaRUU+CwIjL2HbR2xBB8atjxyBKu4KDI+zWqcpr5Vhbks+j6g25MCS6YNgMGMDmh2i g6Bg== 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 t19si1143001ejb.85.2020.12.09.10.33.19; Wed, 09 Dec 2020 10:33:59 -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 S1733061AbgLISck (ORCPT + 99 others); Wed, 9 Dec 2020 13:32:40 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:37449 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1733052AbgLISch (ORCPT ); Wed, 9 Dec 2020 13:32:37 -0500 X-UUID: 7f49fd8d783745079b34fba92d3901d5-20201210 X-UUID: 7f49fd8d783745079b34fba92d3901d5-20201210 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.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 947489655; Thu, 10 Dec 2020 02:31:44 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Dec 2020 02:31:41 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Dec 2020 02:31:41 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , , , Ryder Lee Subject: [PATCH 1/2] mt76: mt7915: reset token when mac_reset happens Date: Thu, 10 Dec 2020 02:31:39 +0800 Message-ID: <96fb46ff1e2e3a9c0646a3b3dce43c3840b7bae0.1607536573.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: 553B1583006BD7092163E84094310DD0E4FDF9A565044402C3BE8B704379B0772000: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 --- .../net/wireless/mediatek/mt76/mt7915/init.c | 17 +------------- .../net/wireless/mediatek/mt76/mt7915/mac.c | 23 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7915/mt7915.h | 1 + 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c index ff29a8090739..255ccd7e3d27 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/init.c @@ -672,27 +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); - } - 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 7f08c88d3282..25623e450bc5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c @@ -1466,6 +1466,26 @@ 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); + } + spin_unlock_bh(&dev->token_lock); + idr_destroy(&dev->token); +} + /* system error recovery */ void mt7915_mac_reset_work(struct work_struct *work) { @@ -1506,6 +1526,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 5bf76c74373f..3cee1cffc95e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h @@ -468,6 +468,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