blob: fb8587e144d5f420ed87c882e3f361be21c87f51 [file] [log] [blame]
developer1f55fcf2024-10-17 14:52:33 +08001From 174faa97cf0fdc8f26e4b8c13fd3c4b8d19ced15 Mon Sep 17 00:00:00 2001
2From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
3Date: Wed, 9 Oct 2024 23:13:29 +0000
4Subject: [PATCH] wifi: mt76: mt7915: refine twt mcu update flow
5
6Fix potential issue that if the twt mcu update command fail, the twt_list entry
7is not undo and will remain in the list. Also, remove unecessary parameter for
8twt delete flow.
9
10Signed-off-by: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
11---
12 mt7915/debugfs.c | 4 ++--
13 mt7915/mac.c | 4 +++-
14 mt7915/mcu.c | 22 ++++++++++++----------
15 3 files changed, 17 insertions(+), 13 deletions(-)
16
17diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
18index 72867ff..462e167 100644
19--- a/mt7915/debugfs.c
20+++ b/mt7915/debugfs.c
21@@ -1758,7 +1758,7 @@ mt7915_twt_stats(struct seq_file *s, void *data)
22 struct mt7915_dev *dev = dev_get_drvdata(s->private);
23 struct mt7915_twt_flow *iter;
24
25- rcu_read_lock();
26+ mutex_lock(&dev->mt76.mutex);
27
28 seq_puts(s, " wcid | id | flags | exp | mantissa");
29 seq_puts(s, " | duration | tsf |\n");
30@@ -1773,7 +1773,7 @@ mt7915_twt_stats(struct seq_file *s, void *data)
31 iter->exp, iter->mantissa,
32 iter->duration, iter->tsf);
33
34- rcu_read_unlock();
35+ mutex_unlock(&dev->mt76.mutex);
36
37 return 0;
38 }
39diff --git a/mt7915/mac.c b/mt7915/mac.c
40index 4e7dae7..321a57d 100644
41--- a/mt7915/mac.c
42+++ b/mt7915/mac.c
43@@ -2555,8 +2555,10 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
44 }
45 flow->tsf = le64_to_cpu(twt_agrt->twt);
46
47- if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD))
48+ if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD)) {
49+ list_del(&flow->list);
50 goto unlock;
51+ }
52
53 setup_cmd = TWT_SETUP_CMD_ACCEPT;
54 dev->twt.table_mask |= BIT(table_id);
55diff --git a/mt7915/mcu.c b/mt7915/mcu.c
56index 2c5943b..25ac312 100644
57--- a/mt7915/mcu.c
58+++ b/mt7915/mcu.c
59@@ -4811,20 +4811,22 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
60 .own_mac_idx = mvif->mt76.omac_idx,
61 .flowid = flow->id,
62 .peer_id = cpu_to_le16(flow->wcid),
63- .duration = flow->duration,
64 .bss_idx = mvif->mt76.idx,
65- .start_tsf = cpu_to_le64(flow->tsf),
66- .mantissa = flow->mantissa,
67- .exponent = flow->exp,
68 .is_ap = true,
69 };
70
71- if (flow->protection)
72- req.agrt_params |= TWT_AGRT_PROTECT;
73- if (!flow->flowtype)
74- req.agrt_params |= TWT_AGRT_ANNOUNCE;
75- if (flow->trigger)
76- req.agrt_params |= TWT_AGRT_TRIGGER;
77+ if (cmd == MCU_TWT_AGRT_ADD) {
78+ req.start_tsf = cpu_to_le64(flow->tsf);
79+ req.mantissa = flow->mantissa;
80+ req.exponent = flow->exp;
81+ req.duration = flow->duration;
82+ if (flow->protection)
83+ req.agrt_params |= TWT_AGRT_PROTECT;
84+ if (!flow->flowtype)
85+ req.agrt_params |= TWT_AGRT_ANNOUNCE;
86+ if (flow->trigger)
87+ req.agrt_params |= TWT_AGRT_TRIGGER;
88+ }
89
90 return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TWT_AGRT_UPDATE),
91 &req, sizeof(req), true);
92--
932.18.0
94