[][MAC80211][MT76][Rework Thermal Protection]
[Description]
Fix thermal protection bugs.
[Release-log]
N/A
Change-Id: I3ec0295572893c14c662a172349110e4129d1ce3
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/6923892
diff --git a/autobuild_mac80211_release/package/kernel/mt76/patches/0004-wifi-mt76-mt7915-add-error-message-in-mt7915_thermal.patch b/autobuild_mac80211_release/package/kernel/mt76/patches/0004-wifi-mt76-mt7915-add-error-message-in-mt7915_thermal.patch
new file mode 100644
index 0000000..8f9fa45
--- /dev/null
+++ b/autobuild_mac80211_release/package/kernel/mt76/patches/0004-wifi-mt76-mt7915-add-error-message-in-mt7915_thermal.patch
@@ -0,0 +1,78 @@
+From 30bd3547690ec1463b34c726577ae821e92a4390 Mon Sep 17 00:00:00 2001
+From: Howard Hsu <howard-yh.hsu@mediatek.com>
+Date: Mon, 12 Dec 2022 13:18:49 +0800
+Subject: [PATCH 4/4] wifi: mt76: mt7915: add error message in
+ mt7915_thermal_set_cur_throttle_state()
+
+Add dev_err so that it is easier to see invalid setting while looking at
+dmesg.
+
+Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
+Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
+Signed-off-by: Howard Hsu <howard-yh.hsu@mediatek.com>
+---
+ mt7915/init.c | 12 +++++++-----
+ mt7915/mt7915.h | 2 ++
+ 2 files changed, 9 insertions(+), 5 deletions(-)
+
+diff --git a/mt7915/init.c b/mt7915/init.c
+index 98655e4d..b23a2fb8 100644
+--- a/mt7915/init.c
++++ b/mt7915/init.c
+@@ -145,8 +145,11 @@ mt7915_thermal_set_cur_throttle_state(struct thermal_cooling_device *cdev,
+ u8 throttling = MT7915_THERMAL_THROTTLE_MAX - state;
+ int ret;
+
+- if (state > MT7915_CDEV_THROTTLE_MAX)
++ if (state > MT7915_CDEV_THROTTLE_MAX) {
++ dev_err(phy->dev->mt76.dev,
++ "please specify a valid throttling state\n");
+ return -EINVAL;
++ }
+
+ if (state == phy->cdev_state)
+ return 0;
+@@ -175,7 +178,7 @@ static void mt7915_unregister_thermal(struct mt7915_phy *phy)
+ struct wiphy *wiphy = phy->mt76->hw->wiphy;
+
+ if (!phy->cdev)
+- return;
++ return;
+
+ sysfs_remove_link(&wiphy->dev.kobj, "cooling_device");
+ thermal_cooling_device_unregister(phy->cdev);
+@@ -209,8 +212,8 @@ static int mt7915_thermal_init(struct mt7915_phy *phy)
+ return PTR_ERR(hwmon);
+
+ /* initialize critical/maximum high temperature */
+- phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = 110;
+- phy->throttle_temp[MT7915_MAX_TEMP_IDX] = 120;
++ phy->throttle_temp[MT7915_CRIT_TEMP_IDX] = MT7915_CRIT_TEMP;
++ phy->throttle_temp[MT7915_MAX_TEMP_IDX] = MT7915_MAX_TEMP;
+
+ return 0;
+ }
+@@ -1185,7 +1188,6 @@ static void mt7915_stop_hardware(struct mt7915_dev *dev)
+ mt7986_wmac_disable(dev);
+ }
+
+-
+ int mt7915_register_device(struct mt7915_dev *dev)
+ {
+ struct mt7915_phy *phy2;
+diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h
+index e58650bb..942d70c5 100644
+--- a/mt7915/mt7915.h
++++ b/mt7915/mt7915.h
+@@ -72,6 +72,8 @@
+
+ #define MT7915_CRIT_TEMP_IDX 0
+ #define MT7915_MAX_TEMP_IDX 1
++#define MT7915_CRIT_TEMP 110
++#define MT7915_MAX_TEMP 120
+
+ struct mt7915_vif;
+ struct mt7915_sta;
+--
+2.18.0
+