blob: 112b0990970fa5b9cb1653a95b95cd03d7fa6db5 [file] [log] [blame]
From 7fdf5d384f377d0b7b1bb1aa441cebb98d3c61fa Mon Sep 17 00:00:00 2001
From: Howard Hsu <howard-yh.hsu@mediatek.com>
Date: Thu, 13 Jul 2023 15:50:00 +0800
Subject: [PATCH] wifi: mt76: mt7915: move temperature margin check to
mt7915_thermal_temp_store()
Originally, we would reduce the 10-degree margin to the restore
temperature, but the user would not be aware of this when setting it.
Moving the margin reduction to the user setting check allows the user to
clearly understand that there is a 10-degree difference between the
restore and trigger temperature.
Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
---
mt7915/init.c | 7 ++++---
mt7915/mcu.c | 3 +--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mt7915/init.c b/mt7915/init.c
index 75f8d96d..3e9b082c 100644
--- a/mt7915/init.c
+++ b/mt7915/init.c
@@ -83,12 +83,13 @@ static ssize_t mt7915_thermal_temp_store(struct device *dev,
mutex_lock(&phy->dev->mt76.mutex);
val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), 60, 130);
+ /* add a safety margin ~10 */
if ((i - 1 == MT7915_CRIT_TEMP_IDX &&
- val > phy->throttle_temp[MT7915_MAX_TEMP_IDX]) ||
+ val > phy->throttle_temp[MT7915_MAX_TEMP_IDX] - 10) ||
(i - 1 == MT7915_MAX_TEMP_IDX &&
- val < phy->throttle_temp[MT7915_CRIT_TEMP_IDX])) {
+ val - 10 < phy->throttle_temp[MT7915_CRIT_TEMP_IDX])) {
dev_err(phy->dev->mt76.dev,
- "temp1_max shall be greater than temp1_crit.");
+ "temp1_max shall be 10 degrees greater than temp1_crit.");
mutex_unlock(&phy->dev->mt76.mutex);
return -EINVAL;
}
diff --git a/mt7915/mcu.c b/mt7915/mcu.c
index 146c3d64..820eb555 100644
--- a/mt7915/mcu.c
+++ b/mt7915/mcu.c
@@ -3148,8 +3148,7 @@ int mt7915_mcu_set_thermal_protect(struct mt7915_phy *phy)
/* set high-temperature trigger threshold */
req.ctrl.ctrl_id = THERMAL_PROTECT_ENABLE;
- /* add a safety margin ~10 */
- req.restore_temp = cpu_to_le32(phy->throttle_temp[0] - 10);
+ req.restore_temp = cpu_to_le32(phy->throttle_temp[0]);
req.trigger_temp = cpu_to_le32(phy->throttle_temp[1]);
req.sustain_time = cpu_to_le16(10);
--
2.18.0