Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5021620pxu; Thu, 10 Dec 2020 10:55:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyG782CNptfBg4OPkq3LetOn+UK+roxrKG55ypCWuhQjqv99OOMUE2v3Yfn0fn/od3lRV68 X-Received: by 2002:a17:906:4d47:: with SMTP id b7mr7534210ejv.420.1607626528523; Thu, 10 Dec 2020 10:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607626528; cv=none; d=google.com; s=arc-20160816; b=VzS/Xyha4zJFVYAcXBCNac7oRO0sOy3Rfl8qt4gfavjr1YX4a+FCh0dzaun3Foarec /0vZhYDxnaOCer3znoIobiLJTraVwTf2gDm1bpGoQF6LIV4t06oD38ZGc7B/0CT7RM1d o4G2FBO36Vm/EVhywdOqTBDo85O7cD8riGMWsqzk7pmhahkDfoTIU5rkyDnu9uAVW4vt hYm7BZa91zNXbkBMYGnIjf2qqFPc0BKGAzQUKeTIqF9lWMu/rVtWgRnHSGhHBgL44ens t4EzAYRX0UOsjtcMbLp8cVGuPaSrIJLFgufya+zd4E9mQTLwoQDPb8Lqilz+gWvzx5mw Eteg== 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=xSJ/uz38ces/NrIJaJH18YDAeklv+v+z5/A3YOpYYh8=; b=HeytiwaIFZ7ETouzC29EiWCX1YwNCyW7+2lMyskyeA4FLyjB5RVuc2q5c2BKoh+qX1 ueaWR40h9YCxwUJ6K9rT0x5Bmclwca4rh66XnQENc+G8VeXm/HX4oId/FPO/uhM7TCBY SnW8qxSqTYcfQeOhtzzl+oHBqqMW0ubfE/io+8JiSQya3Pbtw2J91w4Jz6NVSoUv2H4+ vevA8oJvaTAO2vov3m6zeF/AemvkiM96+5eL/pBDB7M/sJs57qaZyM7KIRgRgs4dSYhz 3Jv723KLTb46EUzNc+7uVcEp6K3+VEyf+36j3Sq3IUWnbaRrGIL78tI/tGZOh/Zr42WR o3PA== 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 d21si3334364edy.92.2020.12.10.10.54.55; Thu, 10 Dec 2020 10:55:28 -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 S2389034AbgLJSwg (ORCPT + 99 others); Thu, 10 Dec 2020 13:52:36 -0500 Received: from mailgw02.mediatek.com ([210.61.82.184]:48960 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2393206AbgLJSwd (ORCPT ); Thu, 10 Dec 2020 13:52:33 -0500 X-UUID: 4ddd42d5ecea4b1098f27352b343f21a-20201211 X-UUID: 4ddd42d5ecea4b1098f27352b343f21a-20201211 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] 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 1082918429; Fri, 11 Dec 2020 02:51:43 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 11 Dec 2020 02:51:42 +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:41 +0800 From: Ryder Lee To: Felix Fietkau , Lorenzo Bianconi CC: Shayne Chen , , , Ryder Lee Subject: [PATCH v3 2/2] mt76: mt7615: reset token when mac_reset happens Date: Fri, 11 Dec 2020 02:51:38 +0800 Message-ID: <7591bc5b4de099713d3bfb3bbf5946bca8a9ff71.1607578601.git.ryder.lee@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <69d62cd40ae52e0ddd5b26ba96bc7480385585a5.1607578601.git.ryder.lee@mediatek.com> References: <69d62cd40ae52e0ddd5b26ba96bc7480385585a5.1607578601.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 --- change since v3 - fix build error change since v2 - rebase on top of latest codebase --- .../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 0f360be0b885..1b4986dd3baa 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mac.c @@ -2058,6 +2058,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; @@ -2101,6 +2117,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..d697ff2ea56e 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 mt7615_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