[PATCH v2 3/3] wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling()

Howard Hsu howard-yh.hsu at mediatek.com
Tue Dec 6 21:25:00 PST 2022


Firmware expects to disable thermal protect first before reconfiguring.

Fixes: 34b877d972be ("mt76: mt7915: add thermal cooling device support")
Signed-off-by: Howard Hsu <howard-yh.hsu at mediatek.com>
---
 .../net/wireless/mediatek/mt76/mt7915/mcu.c   | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
index b2652de082ba..176d293eb32a 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c
@@ -3070,19 +3070,22 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state)
 	} __packed req = {
 		.ctrl = {
 			.band_idx = phy->mt76->band_idx,
+			.type.protect_type = 1,
+			.type.trigger_type = 1,
 		},
 	};
-	int level;
+	int level, ret;
 
-	if (!state) {
-		req.ctrl.ctrl_id = THERMAL_PROTECT_DISABLE;
-		goto out;
-	}
+	req.ctrl.ctrl_id = THERMAL_PROTECT_DISABLE;
+
+	ret = mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(THERMAL_PROT),
+				&req, sizeof(req.ctrl), false);
+
+	if (ret || !state)
+		return ret;
 
 	/* set duty cycle and level */
 	for (level = 0; level < 4; level++) {
-		int ret;
-
 		req.ctrl.ctrl_id = THERMAL_PROTECT_DUTY_CONFIG;
 		req.ctrl.duty.duty_level = level;
 		req.ctrl.duty.duty_cycle = state;
@@ -3100,8 +3103,6 @@ int mt7915_mcu_set_thermal_throttling(struct mt7915_phy *phy, u8 state)
 	req.restore_temp = cpu_to_le32(phy->throttle_temp[0] - 10);
 	req.trigger_temp = cpu_to_le32(phy->throttle_temp[1]);
 	req.sustain_time = cpu_to_le16(10);
-
-out:
 	req.ctrl.type.protect_type = 1;
 	req.ctrl.type.trigger_type = 1;
 
-- 
2.18.0




More information about the Linux-mediatek mailing list