1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
From: Deren Wu <Deren.Wu@mediatek.com>
To: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi
<lorenzo.bianconi@redhat.com>
CC: Sean Wang <sean.wang@mediatek.com>, Soul Huang <Soul.Huang@mediatek.com>,
YN Chen <YN.Chen@mediatek.com>, Leon Yen <Leon.Yen@mediatek.com>, "Eric-SY
Chang" <Eric-SY.Chang@mediatek.com>, Deren Wu <Deren.Wu@mediatek.com>,
KM Lin <km.lin@mediatek.com>, Robin Chiu <robin.chiu@mediatek.com>, CH Yeh
<ch.yeh@mediatek.com>, Posh Sun <posh.sun@mediatek.com>, Eric Liang
<Eric.Liang@mediatek.com>, Stella Chang <Stella.Chang@mediatek.com>, Jimmy Hu
<Jimmy.Hu@mediatek.com>, <jemele@google.com>, <yenlinlai@google.com>,
linux-wireless <linux-wireless@vger.kernel.org>, linux-mediatek
<linux-mediatek@lists.infradead.org>, Deren Wu <deren.wu@mediatek.com>
Subject: [PATCH] mt76: mt7921: fix dma hang in rmmod
Date: Tue, 27 Jul 2021 17:47:09 +0800
From: Deren Wu <deren.wu@mediatek.com>
The dma would be broken after rmmod flow. There are two different
cases causing this issue.
1. dma access without privilege.
2. hw access sequence borken by another context.
This patch handle both cases to avoid hw crash.
Fixes: 2b9ea5a8cf1bd ("mt76: mt7921: add mt7921_dma_cleanup in mt7921_unregister_device")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
---
drivers/net/wireless/mediatek/mt76/mt7921/init.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
index 49725caca7ed..1f37e64b6038 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
@@ -266,10 +266,20 @@ int mt7921_register_device(struct mt7921_dev *dev)
void mt7921_unregister_device(struct mt7921_dev *dev)
{
+ int i;
+ struct mt76_connac_pm *pm = &dev->pm;
+
mt76_unregister_device(&dev->mt76);
+ mt76_for_each_q_rx(&dev->mt76, i)
+ napi_disable(&dev->mt76.napi[i]);
+ cancel_delayed_work_sync(&pm->ps_work);
+ cancel_work_sync(&pm->wake_work);
+
mt7921_tx_token_put(dev);
+ mt7921_mcu_drv_pmctrl(dev);
mt7921_dma_cleanup(dev);
mt7921_mcu_exit(dev);
+ mt7921_mcu_fw_pmctrl(dev);
tasklet_disable(&dev->irq_tasklet);
mt76_free_device(&dev->mt76);
|