Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4194828pxu; Wed, 9 Dec 2020 10:35:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwaz6V4Bi7qGufldiBdb9GbgSWGySmhXPLBOPqC2qluVz4o9fl43PkJ/IFHmBWRqkk+hfpr X-Received: by 2002:a05:6402:1d15:: with SMTP id dg21mr3224334edb.280.1607538903343; Wed, 09 Dec 2020 10:35:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607538903; cv=none; d=google.com; s=arc-20160816; b=rQxDSXxa8CCEeJMxBouuOEvteHdL0AdAOOcjpdEG0FpUyPHDOJwkXZyQCMZ8NtpTCc rCNQaS8wIPTV4CHqICAfgeJE0NFoSTFVeUCcjbk67mE+u20huf/s6pnCRgQ+2fY7V7Ln cTvQgHU5eKWNqvrMaiCQvG6cBnAa/wjljvykgzd+WDH1WVqRv1LXE1mjF50ymOPfSkSc TSi9kylLpIpFctqvtpxqFkastUbcjX2bUecTAjkIkG59HA5xKcY33U9qIwcckHLFftjo lp9LT1iWsSruiakGDSGBczQMDarGENbNM7uIaGiJSRgTAiJlkIBCg5ZmVF3saZPLWYTd ahLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=aQaxPID1SAlITJWl8DIyIaSRsqzmhkQQurcCgkDHp5o=; b=ZAPqdqUYSUCVVdirMav67TvTLHSLrMwOdjwsgv64zJLTVkSNFPH/As3KJi8F7n/ct4 RTebKHySr75i/gv5hb7CQe+4kny3FLSD5CulUR0jHiy0D1yUxasG0fpnPVum5EeuQW4B uVPFhUtfzuin5WmO7bu9Rvmw7rflvYQ4BQ5BY8tp38yOlPYKGPeThDm1dnWqD36371sY KQ6xW4rHywrOU9oAxUKxlYAW8L/P54uXHHabqw5ku8sYuo9a+aYRKMlK9P7F28cXEYdJ kiFqiJwLRmkuujVMruPiv5c77tv528FkqtzCsgGXcCe+DVxUSf09KuapcLKpJOhvE9FC F7NQ== 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.34.38; Wed, 09 Dec 2020 10:35:03 -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 S1733106AbgLISck (ORCPT + 99 others); Wed, 9 Dec 2020 13:32:40 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:37518 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732917AbgLISci (ORCPT ); Wed, 9 Dec 2020 13:32:38 -0500 X-UUID: d206d2686acf424bbd7158d7946ed2da-20201210 X-UUID: d206d2686acf424bbd7158d7946ed2da-20201210 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] 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 896218878; Thu, 10 Dec 2020 02:31:53 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs08n1.mediatek.inc (172.21.101.55) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Dec 2020 02:31:51 +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:51 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , , , Ryder Lee Subject: [PATCH 2/2] mt76: mt7615: reset token when mac_reset happens Date: Thu, 10 Dec 2020 02:31:48 +0800 Message-ID: X-Mailer: git-send-email 2.18.0 In-Reply-To: <96fb46ff1e2e3a9c0646a3b3dce43c3840b7bae0.1607536573.git.ryder.lee@mediatek.com> References: <96fb46ff1e2e3a9c0646a3b3dce43c3840b7bae0.1607536573.git.ryder.lee@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Reset token in mt7615_mac_reset_work() to avoid possible leakege. Signed-off-by: Ryder Lee --- .../net/wireless/mediatek/mt76/mt7615/mac.c | 19 +++++++++++++++++++ .../wireless/mediatek/mt76/mt7615/mt7615.h | 2 +- .../wireless/mediatek/mt76/mt7615/pci_init.c | 12 +----------- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c index 9e0765ddcb5f..ff1a601000d6 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -2067,6 +2067,22 @@ void mt7615_dma_reset(struct mt7615_dev *dev) } EXPORT_SYMBOL_GPL(mt7615_dma_reset); +void mt7615_tx_token_put(struct mt7615_dev *dev); +{ + struct mt76_txwi_cache *txwi; + int id; + + spin_lock_bh(&dev->token_lock); + idr_for_each_entry(&dev->token, txwi, id) { + mt7615_txp_skb_unmap(&dev->mt76, txwi); + if (txwi->skb) + dev_kfree_skb_any(txwi->skb); + mt76_put_txwi(&dev->mt76, txwi); + } + spin_unlock_bh(&dev->token_lock); + idr_destroy(&dev->token); +} + void mt7615_mac_reset_work(struct work_struct *work) { struct mt7615_phy *phy2; @@ -2110,6 +2126,9 @@ void mt7615_mac_reset_work(struct work_struct *work) mt76_wr(dev, MT_MCU_INT_EVENT, MT_MCU_INT_EVENT_PDMA_STOPPED); + mt7615_tx_token_put(dev); + idr_init(&dev->token); + if (mt7615_wait_reset_state(dev, MT_MCU_CMD_RESET_DONE)) { mt7615_dma_reset(dev); diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h index 99b8abdbb08f..50e729906fa9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mt7615.h @@ -583,7 +583,7 @@ int mt7615_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, struct mt76_tx_info *tx_info); void mt7615_tx_complete_skb(struct mt76_dev *mdev, struct mt76_queue_entry *e); - +void mt7615_tx_token_put(struct mt7915_dev *dev); void mt7615_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, struct sk_buff *skb); void mt7615_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps); diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c b/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c index 27fcb1374685..58a0ec1bf8d7 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c @@ -160,9 +160,7 @@ int mt7615_register_device(struct mt7615_dev *dev) void mt7615_unregister_device(struct mt7615_dev *dev) { - struct mt76_txwi_cache *txwi; bool mcu_running; - int id; mcu_running = mt7615_wait_for_mcu_init(dev); @@ -172,15 +170,7 @@ void mt7615_unregister_device(struct mt7615_dev *dev) mt7615_mcu_exit(dev); mt7615_dma_cleanup(dev); - spin_lock_bh(&dev->token_lock); - idr_for_each_entry(&dev->token, txwi, id) { - mt7615_txp_skb_unmap(&dev->mt76, txwi); - if (txwi->skb) - dev_kfree_skb_any(txwi->skb); - mt76_put_txwi(&dev->mt76, txwi); - } - spin_unlock_bh(&dev->token_lock); - idr_destroy(&dev->token); + mt7615_tx_token_put(dev); tasklet_disable(&dev->irq_tasklet); -- 2.18.0