2022-12-14 02:44:08

by Howard Hsu

[permalink] [raw]
Subject: [PATCH v3 0/4] rework thermal protection

Rework thermal protection with the following changes:
1. Send thermal fw commands only after mcu init done.
2. Firmware expects to disable thermal protect before reconfiguring thermal protect.
3. Send fw commands through mt7915_thermal_temp_store() to update firmware
temperature directly.
4. Add error messages for invalid setting.

Howard Hsu (4):
wifi: mt76: mt7915: call mt7915_mcu_set_thermal_throttling() only
after init_work
wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling
wifi: mt76: mt7915: rework mt7915_thermal_temp_store()
wifi: mt76: mt7915: add error message in
mt7915_thermal_set_cur_throttle_state()

.../net/wireless/mediatek/mt76/mt7915/init.c | 32 +++++++----
.../net/wireless/mediatek/mt76/mt7915/main.c | 11 ++++
.../net/wireless/mediatek/mt76/mt7915/mcu.c | 54 +++++++++++--------
.../wireless/mediatek/mt76/mt7915/mt7915.h | 6 +++
4 files changed, 70 insertions(+), 33 deletions(-)

--
2.18.0


2022-12-14 02:45:14

by Howard Hsu

[permalink] [raw]
Subject: [PATCH v3 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 <[email protected]>
Signed-off-by: Ryder Lee <[email protected]>
Signed-off-by: Howard Hsu <[email protected]>
---
drivers/net/wireless/mediatek/mt76/mt7915/init.c | 12 +++++++-----
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 ++
2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/init.c b/drivers/net/wireless/mediatek/mt76/mt7915/init.c
index 0ab9e1320fac..a89b37a320c0 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/init.c
+++ b/drivers/net/wireless/mediatek/mt76/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;
}
@@ -1182,7 +1185,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/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h b/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
index e58650bbbd14..942d70c53825 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h
+++ b/drivers/net/wireless/mediatek/mt76/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

Subject: Re: [PATCH v3 0/4] rework thermal protection

Il 14/12/22 03:28, Howard Hsu ha scritto:
> Rework thermal protection with the following changes:
> 1. Send thermal fw commands only after mcu init done.
> 2. Firmware expects to disable thermal protect before reconfiguring thermal protect.
> 3. Send fw commands through mt7915_thermal_temp_store() to update firmware
> temperature directly.
> 4. Add error messages for invalid setting.
>
> Howard Hsu (4):
> wifi: mt76: mt7915: call mt7915_mcu_set_thermal_throttling() only
> after init_work
> wifi: mt76: mt7915: rework mt7915_mcu_set_thermal_throttling
> wifi: mt76: mt7915: rework mt7915_thermal_temp_store()
> wifi: mt76: mt7915: add error message in
> mt7915_thermal_set_cur_throttle_state()
>
> .../net/wireless/mediatek/mt76/mt7915/init.c | 32 +++++++----
> .../net/wireless/mediatek/mt76/mt7915/main.c | 11 ++++
> .../net/wireless/mediatek/mt76/mt7915/mcu.c | 54 +++++++++++--------
> .../wireless/mediatek/mt76/mt7915/mt7915.h | 6 +++
> 4 files changed, 70 insertions(+), 33 deletions(-)
>


For the entire series:

Tested-by: AngeloGioacchino Del Regno <[email protected]>