Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH backport-iwlwifi] [BUGFIX][NOUPSTREAM] wifi: iwlwifi: Fix thermal zone registration for kernel < 6.3
@ 2026-11-01  0:42 Abraham Zukor
  0 siblings, 0 replies; only message in thread
From: Abraham Zukor @ 2026-11-01  0:42 UTC (permalink / raw)
  To: Miri Korenblit; +Cc: linux-wireless, Abraham Zukor

This is a backport-iwlwifi-only fix; upstream does not need it.

Before commit 7c3d5c20dc16 ("thermal/core: Add a generic
thermal_zone_get_trip() function"), merged in 6.3,
thermal_zone_device_register_with_trips() rejects a zone with trips
unless both .get_trip_temp and .get_trip_type are provided, even when
a trips array is passed. As a result, both mvm and mld fail to register
their thermal zone on older kernels. Provide the callbacks for
kernels older than 6.3.

Signed-off-by: Abraham Zukor <abe@maticrobots.com>
---
Build-tested against v5.15 and v6.1 (mvm and mld); runtime-tested on 5.15.
6.2-6.4 aren't buildable in this tree any more (no guard(rcu) compat).

 .../net/wireless/intel/iwlwifi/mld/thermal.c  | 40 ++++++++++++++++---
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c   | 34 ++++++++++++++++
 2 files changed, 69 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mld/thermal.c b/drivers/net/wireless/intel/iwlwifi/mld/thermal.c
index a4265a6ca..deeffd636 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/thermal.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/thermal.c
@@ -238,11 +238,6 @@ unlock:
 	return ret;
 }
 
-static  struct thermal_zone_device_ops tzone_ops = {
-	.get_temp = iwl_mld_tzone_get_temp,
-	.set_trip_temp = iwl_mld_tzone_set_trip_temp,
-};
-
 #if LINUX_VERSION_IS_LESS(6,9,0)
 static struct thermal_trip trips[IWL_MAX_DTS_TRIPS] = {
 	[0 ... IWL_MAX_DTS_TRIPS - 1] = {
@@ -253,6 +248,41 @@ static struct thermal_trip trips[IWL_MAX_DTS_TRIPS] = {
 };
 #endif
 
+#if LINUX_VERSION_IS_LESS(6,3,0)
+static int iwl_mld_tzone_get_trip_temp(struct thermal_zone_device *device,
+				       int trip, int *temp)
+{
+	if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
+		return -EINVAL;
+
+	*temp = trips[trip].temperature;
+	if (*temp == THERMAL_TEMP_INVALID)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int iwl_mld_tzone_get_trip_type(struct thermal_zone_device *device,
+				       int trip, enum thermal_trip_type *type)
+{
+	if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
+		return -EINVAL;
+
+	*type = trips[trip].type;
+
+	return 0;
+}
+#endif /* LINUX_VERSION_IS_LESS(6,3,0) */
+
+static  struct thermal_zone_device_ops tzone_ops = {
+	.get_temp = iwl_mld_tzone_get_temp,
+	.set_trip_temp = iwl_mld_tzone_set_trip_temp,
+#if LINUX_VERSION_IS_LESS(6,3,0)
+	.get_trip_temp = iwl_mld_tzone_get_trip_temp,
+	.get_trip_type = iwl_mld_tzone_get_trip_type,
+#endif /* LINUX_VERSION_IS_LESS(6,3,0) */
+};
+
 static void iwl_mld_thermal_zone_register(struct iwl_mld *mld)
 {
 	int ret;
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 9d7b8f78f..18fa38ec5 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -652,9 +652,43 @@ static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
 	return iwl_mvm_send_temp_report_ths_cmd(mvm);
 }
 
+#if LINUX_VERSION_IS_LESS(6,3,0)
+static int iwl_mvm_tzone_get_trip_temp(struct thermal_zone_device *device,
+				       int trip, int *temp)
+{
+	struct iwl_mvm *mvm = thermal_zone_device_priv(device);
+
+	if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
+		return -EINVAL;
+
+	*temp = mvm->tz_device.trips[trip].temperature;
+	if (*temp == THERMAL_TEMP_INVALID)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int iwl_mvm_tzone_get_trip_type(struct thermal_zone_device *device,
+				       int trip, enum thermal_trip_type *type)
+{
+	struct iwl_mvm *mvm = thermal_zone_device_priv(device);
+
+	if (trip < 0 || trip >= IWL_MAX_DTS_TRIPS)
+		return -EINVAL;
+
+	*type = mvm->tz_device.trips[trip].type;
+
+	return 0;
+}
+#endif /* LINUX_VERSION_IS_LESS(6,3,0) */
+
 static  struct thermal_zone_device_ops tzone_ops = {
 	.get_temp = iwl_mvm_tzone_get_temp,
 	.set_trip_temp = iwl_mvm_tzone_set_trip_temp,
+#if LINUX_VERSION_IS_LESS(6,3,0)
+	.get_trip_temp = iwl_mvm_tzone_get_trip_temp,
+	.get_trip_type = iwl_mvm_tzone_get_trip_type,
+#endif /* LINUX_VERSION_IS_LESS(6,3,0) */
 };
 
 static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)
-- 
2.55.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-01  0:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-01  0:42 [PATCH backport-iwlwifi] [BUGFIX][NOUPSTREAM] wifi: iwlwifi: Fix thermal zone registration for kernel < 6.3 Abraham Zukor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox