Skip to contentSkip to conversation

wifi: ath10k: thermal temp reading modifications

PATCH New Nicolas Escande 1 participant 3 messages Nov 30 Qualcomm Atheros ATH10K wireless driver

lore
Share & tools
lore
#0 lore raw

cover wifi: ath10k: thermal temp reading modifications

A few things that were discussed on the mailing list following a previous patch by Filippo Falezza. See [0]

First we disable temperature reading if the firmware fails to read the temperature the first 3 tries. In that case we return EOPNOTSUPP early.

Second we lower the temperature read timeout to a more sensible value of 100ms (successful read completes in around 200us leaving some margin).

Filippo, if you could try it on your offending hardware that would be great.

Jeff/Loic, the patch subject targets ath-next but the code is based on ath-current (because it has both the original code from Filippo and the revert while ath-next does not have the revert)

[0] https://lore.kernel.org/linux-wireless/[email protected]/

---
Nicolas Escande (2):
wifi: ath10k: disable thermal reads on unresponsive firmware
wifi: ath10k: lower temperature read timeout value

 drivers/net/wireless/ath/ath10k/thermal.c | 10 ++++++++++
 drivers/net/wireless/ath/ath10k/thermal.h |  4 +++-
 2 files changed, 13 insertions(+), 1 deletion(-)

---
base-commit: 88d371012c3e5154ad091504c70e9453a1a2bf1e
change-id: 20261117-ath10k-thermal-17562280c0bd

Best regards,

Signature · 1 line
Nicolas Escande <[email protected]>
#1 lore raw

PATCH 1/2 wifi: ath10k: disable thermal reads on unresponsive firmware

It has been reported that WCN3990 with WLAN.HL.3.3.1-00694-QCAHLSWMTPLZ-1 (at least on a Motorola Moto G 5G Plus SM7250) does not respond to the WMI_PDEV_GET_TEMPERATURE command. Meanwhile, sporadic failures to read the temperature have been seen on at least QCA9984 and QCA9888.

To handle unresponsive firmware, if the first 3 temperature reads time out, stop trying to read the temperature and return -EOPNOTSUPP early on subsequent calls. If any read succeeds, assume the firmware supports thermal reads.

Tested-on: QCA9984 hw1.0 PCI 10.4-3.10-00047
Tested-on: QCA9888 hw2.0 PCI 10.4-3.10-00076

---
 drivers/net/wireless/ath/ath10k/thermal.c | 10 ++++++++++
 drivers/net/wireless/ath/ath10k/thermal.h |  2 ++
 2 files changed, 12 insertions(+)
drivers/net/wireless/ath/ath10k/thermal.c +10 -0
index 9bb486f8e920..96fd769aa0a3 100644
@@ -75,6 +75,11 @@ static ssize_t ath10k_thermal_show_temp(struct device *dev,
 		goto out;
 	}
 
+	if (ar->thermal.read_timeouts == ATH10K_THERMAL_MAX_TIMEOUTS) {
+		ret = -EOPNOTSUPP;
+		goto out;
+	}
+
 	reinit_completion(&ar->thermal.wmi_sync);
 	ret = ath10k_wmi_pdev_get_temperature(ar);
 	if (ret) {
@@ -91,10 +96,15 @@ static ssize_t ath10k_thermal_show_temp(struct device *dev,
 						ATH10K_THERMAL_SYNC_TIMEOUT_HZ);
 	if (!time_left) {
 		ath10k_warn(ar, "failed to synchronize thermal read\n");
+		if (ar->thermal.read_timeouts < ATH10K_THERMAL_MAX_TIMEOUTS &&
+		    ++ar->thermal.read_timeouts == ATH10K_THERMAL_MAX_TIMEOUTS)
+			ath10k_warn(ar, "firmware does not report temperature, disabling reads\n");
 		ret = -ETIMEDOUT;
 		goto out;
 	}
 
+	ar->thermal.read_timeouts = ATH10K_THERMAL_MAX_TIMEOUTS + 1;
+
 	spin_lock_bh(&ar->data_lock);
 	temperature = ar->thermal.temperature;
 	spin_unlock_bh(&ar->data_lock);
drivers/net/wireless/ath/ath10k/thermal.h +2 -0
index 1f4de9fbf2b3..c25795307363 100644
@@ -10,6 +10,7 @@
 #define ATH10K_QUIET_START_OFFSET       10
 #define ATH10K_HWMON_NAME_LEN           15
 #define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5 * HZ)
+#define ATH10K_THERMAL_MAX_TIMEOUTS     3
 #define ATH10K_THERMAL_THROTTLE_MAX     100
 
 struct ath10k_thermal {
@@ -19,6 +20,7 @@ struct ath10k_thermal {
 	/* protected by conf_mutex */
 	u32 throttle_state;
 	u32 quiet_period;
+	u8 read_timeouts;
 	/* temperature value in Celsius degree
 	 * protected by data_lock
 	 */
Signature · 1 line
2.56.1
#2 lore raw

PATCH 2/2 wifi: ath10k: lower temperature read timeout value

In reply to Nicolas Escande

ATH10K_THERMAL_SYNC_TIMEOUT_HZ is currently 5s. That is an awfully long time to hold a lock. Some firmware never responds, and some only fails sporadically. Tests showed an average read time of 90us to 200us on QCA9984, QCA9888 and QCA9886. Set the timeout to 100ms. This is still far above any nominal read time.

Tested-on: QCA9984 hw1.0 PCI 10.4-3.10-00047
Tested-on: QCA9888 hw2.0 PCI 10.4-3.10-00076

---
 drivers/net/wireless/ath/ath10k/thermal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath10k/thermal.h +1 -1
index c25795307363..d80f1a77dd52 100644
@@ -9,7 +9,7 @@
 #define ATH10K_QUIET_PERIOD_MIN         25
 #define ATH10K_QUIET_START_OFFSET       10
 #define ATH10K_HWMON_NAME_LEN           15
-#define ATH10K_THERMAL_SYNC_TIMEOUT_HZ (5 * HZ)
+#define ATH10K_THERMAL_SYNC_TIMEOUT_HZ msecs_to_jiffies(100)
 #define ATH10K_THERMAL_MAX_TIMEOUTS     3
 #define ATH10K_THERMAL_THROTTLE_MAX     100
 
Signature · 1 line
2.56.1