blob: fb8587e144d5f420ed87c882e3f361be21c87f51 [file] [log] [blame]
From 174faa97cf0fdc8f26e4b8c13fd3c4b8d19ced15 Mon Sep 17 00:00:00 2001
From: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
Date: Wed, 9 Oct 2024 23:13:29 +0000
Subject: [PATCH] wifi: mt76: mt7915: refine twt mcu update flow
Fix potential issue that if the twt mcu update command fail, the twt_list entry
is not undo and will remain in the list. Also, remove unecessary parameter for
twt delete flow.
Signed-off-by: Yi-Chia Hsieh <Yi-Chia.Hsieh@mediatek.com>
---
mt7915/debugfs.c | 4 ++--
mt7915/mac.c | 4 +++-
mt7915/mcu.c | 22 ++++++++++++----------
3 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c
index 72867ff..462e167 100644
--- a/mt7915/debugfs.c
+++ b/mt7915/debugfs.c
@@ -1758,7 +1758,7 @@ mt7915_twt_stats(struct seq_file *s, void *data)
struct mt7915_dev *dev = dev_get_drvdata(s->private);
struct mt7915_twt_flow *iter;
- rcu_read_lock();
+ mutex_lock(&dev->mt76.mutex);
seq_puts(s, " wcid | id | flags | exp | mantissa");
seq_puts(s, " | duration | tsf |\n");
@@ -1773,7 +1773,7 @@ mt7915_twt_stats(struct seq_file *s, void *data)
iter->exp, iter->mantissa,
iter->duration, iter->tsf);
- rcu_read_unlock();
+ mutex_unlock(&dev->mt76.mutex);
return 0;
}
diff --git a/mt7915/mac.c b/mt7915/mac.c
index 4e7dae7..321a57d 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
@@ -2555,8 +2555,10 @@ void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
}
flow->tsf = le64_to_cpu(twt_agrt->twt);
- if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD))
+ if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD)) {
+ list_del(&flow->list);
goto unlock;
+ }
setup_cmd = TWT_SETUP_CMD_ACCEPT;
dev->twt.table_mask |= BIT(table_id);
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
index 2c5943b..25ac312 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -4811,20 +4811,22 @@ int mt7915_mcu_twt_agrt_update(struct mt7915_dev *dev,
.own_mac_idx = mvif->mt76.omac_idx,
.flowid = flow->id,
.peer_id = cpu_to_le16(flow->wcid),
- .duration = flow->duration,
.bss_idx = mvif->mt76.idx,
- .start_tsf = cpu_to_le64(flow->tsf),
- .mantissa = flow->mantissa,
- .exponent = flow->exp,
.is_ap = true,
};
- if (flow->protection)
- req.agrt_params |= TWT_AGRT_PROTECT;
- if (!flow->flowtype)
- req.agrt_params |= TWT_AGRT_ANNOUNCE;
- if (flow->trigger)
- req.agrt_params |= TWT_AGRT_TRIGGER;
+ if (cmd == MCU_TWT_AGRT_ADD) {
+ req.start_tsf = cpu_to_le64(flow->tsf);
+ req.mantissa = flow->mantissa;
+ req.exponent = flow->exp;
+ req.duration = flow->duration;
+ if (flow->protection)
+ req.agrt_params |= TWT_AGRT_PROTECT;
+ if (!flow->flowtype)
+ req.agrt_params |= TWT_AGRT_ANNOUNCE;
+ if (flow->trigger)
+ req.agrt_params |= TWT_AGRT_TRIGGER;
+ }
return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(TWT_AGRT_UPDATE),
&req, sizeof(req), true);
--
2.18.0