thermal: improve handling of disabled thermal zone
Subsystems (2)
Zhang Rui
reviewercover thermal: improve handling of disabled thermal zone
Andrzej Pietrasiewicz has proposed two patches at
https://patchwork.kernel.org/patch/11506053/
and
https://patchwork.kernel.org/patch/11506065/
to improve the thermal zone mode support.
But there are still some issues left, and this patch set is made based on these two patches, to improve the handling of disabled thermal zone.
Patch 1/6 to Patch 4/6 clean up the code and fix thermal_zone_device_update() to do nothing but cancelling the polling timer, for a disabled thermal zone.
Patch 6/6 is a prototype patch. Patch 1-5 in this patch series make it possible to fix a known iwlwifi thermal issue, by registering the iwlwifi thermal zone device as disabled, and enable it after firmware ready. I'd like to get feedback from the iwlwifi experts to get it fixed.
thanks,
rui
Zhang Rui
reviewerPATCH 1/6 iwlwifi: use thermal_zone_device_update() for temperature change
thermal_notify_framework() is an obsolete API, and iwlwifi is the only user of it.
Convert iwlwifi driver to use thermal_zone_device_update() instead.
Note that, thermal_zone_device_update() is able to handle the crossed threshold by comparing the current temperature with every trip point, so ths_crossed variant in iwl_mvm_temp_notif() is probably not needed. It is still left there in this patch, in case the debug information is still needed.
--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/tt.c +2 -3
@@ -203,9 +203,8 @@ void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)if (mvm->tz_device.tzone) {struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device; - -thermal_notify_framework (tz_dev->tzone, - tz_dev->fw_trips_index[ths_crossed]); +thermal_zone_device_update (tz_dev->tzone, +THERMAL_EVENT_UNSPECIFIED ); }#endif /* CONFIG_THERMAL */ }
Signature · 1 line
2.7.4
Zhang Rui
reviewerRe: [PATCH 1/6] iwlwifi: use thermal_zone_device_update() for temperature change
Quoted 13 lines · Zhang Rui
thermal_notify_framework()is an obsolete API, and iwlwifi is the only
user of it.
Convert iwlwifi driver to usethermal_zone_device_update()instead.Note that,
thermal_zone_device_update()is able to handle the crossed threshold by comparing the current temperature with every trip point, soths_crossedvariant iniwl_mvm_temp_notif()is probably not needed. It is still left there in this patch, in case the debug information is
still needed.
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]>
Hi, Luca,
Any comments about this patch and patch 6/6?
thanks,
rui
Quoted 24 lines
--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/net/wireless/intel/iwlwifi/mvm/tt.c +2
-3@@ -203,9 +203,8 @@ void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)if (mvm->tz_device.tzone) {struct iwl_mvm_thermal_device *tz_dev = &mvm- >tz_device; - -thermal_notify_framework (tz_dev->tzone, - tz_dev- >fw_trips_index[ths_crossed]); +thermal_zone_device_update (tz_dev->tzone, +THERMAL_EVENT_UNSPECIFIED );}
#endif /*CONFIG_THERMAL*/
}
Re: [PATCH 1/6] iwlwifi: use thermal_zone_device_update() for temperature change
Quoted 14 lines · Zhang Rui
Quoted 13 lines · Zhang Rui
thermal_notify_framework()is an obsolete API, and iwlwifi is the only
user of it.
Convert iwlwifi driver to usethermal_zone_device_update()instead.Note that,
thermal_zone_device_update()is able to handle the crossed threshold by comparing the current temperature with every trip point, soths_crossedvariant iniwl_mvm_temp_notif()is probably not needed. It is still left there in this patch, in case the debug information is
still needed.
Quoted 5 lines
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]>Hi, Luca,
Any comments about this patch and patch 6/6?
Hi Rui,
Sorry for the delay, we have been making some small changes in this code to support a new interface with our firmware and I wanted to make sure things work together.
I'm adding Gil, who is making the changes, to this thread so he can also take a look.
--
Cheers,
Luca.
Zhang Rui
reviewerRe: [PATCH 1/6] iwlwifi: use thermal_zone_device_update() for temperature change
Quoted 28 lines · Luca Coelho
Quoted 19 lines · Zhang Rui
Quoted 18 lines · Zhang Rui
thermal_notify_framework()is an obsolete API, and iwlwifi is the only
user of it.
Convert iwlwifi driver to usethermal_zone_device_update()instead.Note that,
thermal_zone_device_update()is able to handle the crossed
threshold by comparing the current temperature with every trip point,
soths_crossedvariant iniwl_mvm_temp_notif()is probably not needed.
It is still left there in this patch, in case the debug information
is
still needed.Quoted 5 lines
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]>Hi, Luca,
Any comments about this patch and patch 6/6?
Hi Rui,
Quoted 7 lines
Sorry for the delay, we have been making some small changes in this code to support a new interface with our firmware and I wanted to make
sure things work together.I'm adding Gil, who is making the changes, to this thread so he can also take a look.
thanks, Luca.
Gil,
can you please take a look at this patches series?
thanks,
rui
Quoted 5 lines
--
Cheers,
Luca.
Rafael J. Wysocki
maintainerRe: [PATCH 1/6] iwlwifi: use thermal_zone_device_update() for temperature change
In reply to Zhang RuiQuoted 4 lines · Zhang Rui
thermal_notify_framework()is an obsolete API, and iwlwifi is the only user of it.
Convert iwlwifi driver to usethermal_zone_device_update()instead.
IMO it is rather hard to figure out what is going to change functionally, from the driver's perspective, after this change.
In particular, is user space going to notice any change? If so, then what kind of change can it see?
Quoted 6 lines
Note that,
thermal_zone_device_update()is able to handle the crossed threshold by comparing the current temperature with every trip point, soths_crossedvariant iniwl_mvm_temp_notif()is probably not needed.It is still left there in this patch, in case the debug information is still needed.
Well, it should be possible to figure this out just from the code ...
Quoted 24 lines
Signed-off-by Zhang Rui <[email protected]>--- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/net/wireless/intel/iwlwifi/mvm/tt.c +2
-4@@ -203,9 +203,8 @@ void iwl_mvm_temp_notif(struct iwl_mvm *mvm, struct iwl_rx_cmd_buffer *rxb)if (mvm->tz_device.tzone) {struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device; - -thermal_notify_framework (tz_dev->tzone, - tz_dev->fw_trips_index[ths_crossed]); +thermal_zone_device_update (tz_dev->tzone, +THERMAL_EVENT_UNSPECIFIED ); }#endif /* CONFIG_THERMAL */ } --2.7.4
Zhang Rui
reviewerPATCH 2/6 thermal: core: delete thermal_notify_framework()
In reply to Zhang RuiDelete thermal_notify_framework() as there is no user of it.
--- drivers/thermal/thermal_core.c | 18 ------------------ include/linux/thermal.h | 4 ---- 2 files changed, 22 deletions(-)
drivers/thermal/thermal_core.c +0 -18
@@ -532,24 +532,6 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, }EXPORT_SYMBOL_GPL (thermal_zone_device_update); -/** -* thermal_notify_framework - Sensor drivers use this API to notify framework -* @tz: thermal zone device -* @trip: indicates which trip point has been crossed -* -* This function handles the trip events from sensor drivers. It starts -* throttling the cooling devices according to the policy configured. -* For CRITICAL and HOT trip points, this notifies the respective drivers, -* and does actual throttling for other trip points i.e ACTIVE and PASSIVE. -* The throttling policy is based on the configured platform data; if no -* platform data is provided, this uses the step_wise throttling policy. -*/ -void thermal_notify_framework (struct thermal_zone_device *tz,int trip) -{ -handle_thermal_trip (tz, trip); -} -EXPORT_SYMBOL_GPL (thermal_notify_framework); -static void thermal_zone_device_check (struct work_struct *work) { struct thermal_zone_device *tz = container_of(work, struct
include/linux/thermal.h +0 -4
@@ -420,7 +420,6 @@ int thermal_zone_get_slope(struct thermal_zone_device *tz);int thermal_zone_get_offset (struct thermal_zone_device *tz);void thermal_cdev_update (struct thermal_cooling_device *); -void thermal_notify_framework (struct thermal_zone_device *,int );#else static inline struct thermal_zone_device *thermal_zone_device_register( const char *type, int trips, int mask, void *devdata,
@@ -468,9 +467,6 @@ static inline int thermal_zone_get_offset(static inline void thermal_cdev_update (struct thermal_cooling_device *cdev) { } -static inline void thermal_notify_framework (struct thermal_zone_device *tz, -int trip) -{ }#endif /* CONFIG_THERMAL */ static inline int thermal_zone_device_enable (struct thermal_zone_device *tz)
Signature · 1 line
2.7.4
Re: [PATCH 2/6] thermal: core: delete thermal_notify_framework()
Hi Rui,
Thanks for the series,
W dniu 30.04.2020 o 08:32, Zhang Rui pisze:
Quoted 8 lines
Delete
thermal_notify_framework()as there is no user of it.Signed-off-by Zhang Rui <[email protected]>--- drivers/thermal/thermal_core.c | 18 ------------------ include/linux/thermal.h | 4 ---- 2 files changed, 22 deletions(-)
git grep thermal_notify_framework Documentation/driver-api/thermal/sysfs-api.rst:4.3. thermal_notify_framework
Should the documentation be still documenting a non-existent function?
BTW, get_tz_trend() is only used in drivers/thermal/step_wise.c, but is still exported with EXPORT_SYMBOL(). Probably does not need to be exported anymore.
Andrzej
Zhang, Rui
reviewerRE: [PATCH 2/6] thermal: core: delete thermal_notify_framework()
Quoted 24 lines
-----Original Message-----
From: Andrzej Pietrasiewicz <[email protected]>
Sent: Thursday, April 30, 2020 4:47 PM
To: Zhang, Rui <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/6] thermal: core: deletethermal_notify_framework()
Importance: HighHi Rui,
Thanks for the series,
W dniu 30.04.2020 o 08:32, Zhang Rui pisze:
Quoted 8 lines
Delete
thermal_notify_framework()as there is no user of it.Signed-off-by Zhang Rui <[email protected]>--- drivers/thermal/thermal_core.c | 18 ------------------ include/linux/thermal.h | 4 ---- 2 files changed, 22 deletions(-)
Quoted 6 lines
git grep
thermal_notify_frameworkDocumentation/driver-api/thermal/sysfs-api.rst:4.3.thermal_notify_frameworkShould the documentation be still documenting a non-existent function?
Right, thanks for the reminder.
Will clean it up in next version.
Quoted 4 lines
BTW,
get_tz_trend()is only used indrivers/thermal/step_wise.c, but is still exported withEXPORT_SYMBOL(). Probably does not need to be exported anymore.
Right, that worth a separate cleanup patch.
Can you please try this patch and confirm the polling timers are queued/cancelled as expected?
thanks,
rui
Andrzej Pietrasiewicz
Tested-byRe: [PATCH 2/6] thermal: core: delete thermal_notify_framework()
Hi Rui,
W dniu 30.04.2020 o 10:58, Zhang, Rui pisze:
Quoted 18 lines
Quoted 18 lines
-----Original Message-----
From: Andrzej Pietrasiewicz <[email protected]>
Sent: Thursday, April 30, 2020 4:47 PM
To: Zhang, Rui <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/6] thermal: core: deletethermal_notify_framework()
Importance: HighHi Rui,
Thanks for the series,
W dniu 30.04.2020 o 08:32, Zhang Rui pisze:
Quoted 3 lines
Delete
thermal_notify_framework()as there is no user of it.Signed-off-by Zhang Rui <[email protected]>
<snip>
Quoted 2 lines
Can you please try this patch and confirm the polling timers are queued/cancelled as expected?
Yes, they are. I'm testing on an x86 machine with drivers/acpi/thermal.c.
Re: [PATCH 2/6] thermal: core: delete thermal_notify_framework()
W dniu 30.04.2020 o 13:32, Andrzej Pietrasiewicz pisze:
Quoted 20 lines
Hi Rui,
W dniu 30.04.2020 o 10:58, Zhang, Rui pisze:
Quoted 17 lines
Quoted 17 lines
-----Original Message-----
From: Andrzej Pietrasiewicz <[email protected]>
Sent: Thursday, April 30, 2020 4:47 PM
To: Zhang, Rui <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 2/6] thermal: core: deletethermal_notify_framework()
Importance: HighHi Rui,
Thanks for the series,
W dniu 30.04.2020 o 08:32, Zhang Rui pisze:
Quoted 2 lines
Delete
thermal_notify_framework()as there is no user of it.
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Signed-off-by Zhang Rui <[email protected]><snip>
Quoted 2 lines
Can you please try this patch and confirm the polling timers are queued/cancelled as expected?
Yes, they are. I'm testing on an x86 machine with
drivers/acpi/thermal.c.
I should've said x86_64.
Quoted 3 lines
Re: [PATCH 2/6] thermal: core: delete thermal_notify_framework()
In reply to Zhang RuiHi Rui,
W dniu 30.04.2020 o 08:32, Zhang Rui pisze:
Quoted 3 lines
Delete
thermal_notify_framework()as there is no user of it.Signed-off-by Zhang Rui <[email protected]>
Provided that PATCH 1/6 is applied:
Quoted 57 lines
--- drivers/thermal/thermal_core.c | 18 ------------------ include/linux/thermal.h | 4 ---- 2 files changed, 22 deletions(-)drivers/thermal/thermal_core.c +0
-18@@ -532,24 +532,6 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, }EXPORT_SYMBOL_GPL (thermal_zone_device_update); -/** -* thermal_notify_framework - Sensor drivers use this API to notify framework -* @tz: thermal zone device -* @trip: indicates which trip point has been crossed -* -* This function handles the trip events from sensor drivers. It starts -* throttling the cooling devices according to the policy configured. -* For CRITICAL and HOT trip points, this notifies the respective drivers, -* and does actual throttling for other trip points i.e ACTIVE and PASSIVE. -* The throttling policy is based on the configured platform data; if no -* platform data is provided, this uses the step_wise throttling policy. -*/ -void thermal_notify_framework (struct thermal_zone_device *tz,int trip) -{ -handle_thermal_trip (tz, trip); -} -EXPORT_SYMBOL_GPL (thermal_notify_framework); -static void thermal_zone_device_check (struct work_struct *work) { struct thermal_zone_device *tz = container_of(work, structinclude/linux/thermal.h +0
-4@@ -420,7 +420,6 @@ int thermal_zone_get_slope(struct thermal_zone_device *tz);int thermal_zone_get_offset (struct thermal_zone_device *tz);void thermal_cdev_update (struct thermal_cooling_device *); -void thermal_notify_framework (struct thermal_zone_device *,int );#else static inline struct thermal_zone_device *thermal_zone_device_register( const char *type, int trips, int mask, void *devdata,@@ -468,9 +467,6 @@ static inline int thermal_zone_get_offset(static inline void thermal_cdev_update (struct thermal_cooling_device *cdev) { } -static inline void thermal_notify_framework (struct thermal_zone_device *tz, -int trip) -{ }#endif /* CONFIG_THERMAL */ static inline int thermal_zone_device_enable (struct thermal_zone_device *tz)
Zhang Rui
reviewerPATCH 3/6 thermal: core: update polling after all trips handled
In reply to Zhang RuiMove monitor_thermal_zone() from handle_thermal_trip() to thermal_zone_device_update() because updating the polling timers after all trips handled is sufficient.
--- drivers/thermal/thermal_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/thermal/thermal_core.c +6 -5
@@ -430,11 +430,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)handle_critical_trips (tz, trip, type); elsehandle_non_critical_trips (tz ,trip ); -/* -* Alright, we handled this trip successfully. -* So, start monitoring again. -*/ -monitor_thermal_zone (tz); }static void update_temperature (struct thermal_zone_device *tz)
@@ -529,6 +524,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,for (count =0 ; count < tz->trips; count++)handle_thermal_trip (tz, count); + +/* +* Alright, we handled all the trips successfully. +* So, start monitoring again. +*/ +monitor_thermal_zone (tz); }EXPORT_SYMBOL_GPL (thermal_zone_device_update);
Signature · 1 line
2.7.4
Re: [PATCH 3/6] thermal: core: update polling after all trips handled
Quoted 5 lines · Zhang Rui
Move
monitor_thermal_zone()fromhandle_thermal_trip()tothermal_zone_device_update()because updating the polling timers after all trips handled is sufficient.Signed-off-by Zhang Rui <[email protected]>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Quoted 33 lines
--- drivers/thermal/thermal_core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)drivers/thermal/thermal_core.c +6
-5@@ -430,11 +430,6 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)handle_critical_trips (tz, trip, type); elsehandle_non_critical_trips (tz ,trip ); -/* -* Alright, we handled this trip successfully. -* So, start monitoring again. -*/ -monitor_thermal_zone (tz); }static void update_temperature (struct thermal_zone_device *tz)@@ -529,6 +524,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,for (count =0 ; count < tz->trips; count++)handle_thermal_trip (tz, count); + +/* +* Alright, we handled all the trips successfully. +* So, start monitoring again. +*/ +monitor_thermal_zone (tz); }EXPORT_SYMBOL_GPL (thermal_zone_device_update);
Zhang Rui
reviewerPATCH 4/6 thermal: core: stop polling timer for disabled thermal zone
In reply to Zhang RuiFor a disabled thermal zone, thermal_zone_device_update() should do nothing but cancelling the polling timer.
--- drivers/thermal/thermal_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/thermal_core.c +2 -1
@@ -508,7 +508,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,int count;if (should_stop_polling (tz)) -return ; + goto update_polling;if (atomic_read (&in_suspend))return ;
@@ -525,6 +525,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,for (count =0 ; count < tz->trips; count++)handle_thermal_trip (tz, count); +update_polling:/* * Alright, we handled all the trips successfully. * So, start monitoring again.
Signature · 1 line
2.7.4
Re: [PATCH 4/6] thermal: core: stop polling timer for disabled thermal zone
Quoted 4 lines · Zhang Rui
For a disabled thermal zone,
thermal_zone_device_update()should do nothing but cancelling the polling timer.Signed-off-by Zhang Rui <[email protected]>
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Quoted 26 lines
--- drivers/thermal/thermal_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/thermal/thermal_core.c +2
-1@@ -508,7 +508,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,int count;if (should_stop_polling (tz)) -return ; + goto update_polling;if (atomic_read (&in_suspend))return ;@@ -525,6 +525,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,for (count =0 ; count < tz->trips; count++)handle_thermal_trip (tz, count); +update_polling:/* * Alright, we handled all the trips successfully. * So, start monitoring again.
Zhang Rui
reviewerPATCH 5/6 thermal: core: introduce tz_disabled() helper function
In reply to Zhang RuiRename should_stop_polling() to tz_disabled(), and make it global. Because there are platform thermal drivers which also need this.
--- drivers/thermal/thermal_core.c | 17 ++++++++--------- include/linux/thermal.h | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-)
drivers/thermal/thermal_core.c +8 -9
@@ -305,16 +305,9 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,cancel_delayed_work (&tz->poll_queue); } -static inline bool should_stop_polling (struct thermal_zone_device *tz) -{ -return thermal_zone_device_get_mode (tz) ==THERMAL_DEVICE_DISABLED ; -} -static void monitor_thermal_zone (struct thermal_zone_device *tz) { -bool stop; - - stop =should_stop_polling (tz); +bool stop =tz_disabled (tz);mutex_lock (&tz->lock);
@@ -502,12 +495,18 @@ int thermal_zone_device_set_mode(struct thermal_zone_device *tz, }EXPORT_SYMBOL_GPL (thermal_zone_device_set_mode); +bool tz_disabled (struct thermal_zone_device *tz) +{ +return thermal_zone_device_get_mode (tz) ==THERMAL_DEVICE_DISABLED ; +} +EXPORT_SYMBOL (tz_disabled); +void thermal_zone_device_update (struct thermal_zone_device *tz,enum thermal_notify_event event) {int count; -if (should_stop_polling (tz)) +if (tz_disabled (tz)) goto update_polling;if (atomic_read (&in_suspend))
include/linux/thermal.h +2 -0
@@ -479,4 +479,6 @@ static inline int thermal_zone_device_disable(struct thermal_zone_device *tz) return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); } +bool tz_disabled (struct thermal_zone_device *tz); +#endif /* __THERMAL_H__ */
Signature · 1 line
2.7.4
Re: [PATCH 5/6] thermal: core: introduce tz_disabled() helper function
Quoted 32 lines · Zhang Rui
Rename
should_stop_polling()totz_disabled(), and make it global. Because there are platform thermal drivers which also need this.Signed-off-by Zhang Rui <[email protected]>--- drivers/thermal/thermal_core.c | 17 ++++++++--------- include/linux/thermal.h | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-)drivers/thermal/thermal_core.c +1
-8@@ -305,16 +305,9 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,cancel_delayed_work (&tz->poll_queue); } -static inline bool should_stop_polling (struct thermal_zone_device *tz) -{ -return thermal_zone_device_get_mode (tz) ==THERMAL_DEVICE_DISABLED ; -} -static void monitor_thermal_zone (struct thermal_zone_device *tz) { -bool stop; - - stop =should_stop_polling (tz); +bool stop =tz_disabled (tz);mutex_lock (&tz->lock);
drivers/thermal/thermal_core.c int thermal_zone_device_set_mode(struct thermal_zone_device *tz, · line 502
Quoted 8 lines
drivers/thermal/thermal_core.c +5
-0@@ -502,12 +495,18 @@ int thermal_zone_device_set_mode(struct thermal_zone_device *tz, }EXPORT_SYMBOL_GPL (thermal_zone_device_set_mode); +bool tz_disabled (struct thermal_zone_device *tz) +{ +return thermal_zone_device_get_mode (tz) ==THERMAL_DEVICE_DISABLED ; +} +EXPORT_SYMBOL (tz_disabled);
Is there actual reason to not make it _GPL?
[ all other thermal core functionality seems to be _GPL anyway ]
Otherwise the patch looks fine:
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Quoted 23 lines
drivers/thermal/thermal_core.c +2
-1+void thermal_zone_device_update (struct thermal_zone_device *tz,enum thermal_notify_event event) {int count; -if (should_stop_polling (tz)) +if (tz_disabled (tz)) goto update_polling;if (atomic_read (&in_suspend))include/linux/thermal.h +2
-0@@ -479,4 +479,6 @@ static inline int thermal_zone_device_disable(struct thermal_zone_device *tz) return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); } +bool tz_disabled (struct thermal_zone_device *tz); +#endif /* __THERMAL_H__ */
Zhang Rui
reviewerRe: [PATCH 5/6] thermal: core: introduce tz_disabled() helper function
Quoted 50 lines · Bartlomiej Zolnierkiewicz
Quoted 36 lines · Zhang Rui
Rename
should_stop_polling()totz_disabled(), and make it global. Because there are platform thermal drivers which also need this.Signed-off-by Zhang Rui <[email protected]>--- drivers/thermal/thermal_core.c | 17 ++++++++--------- include/linux/thermal.h | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-)drivers/thermal/thermal_core.c +1
-8@@ -305,16 +305,9 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, cancel_delayed_work(&tz->poll_queue); } -static inline bool should_stop_polling (struct thermal_zone_device *tz) -{ -return thermal_zone_device_get_mode (tz) ==THERMAL_DEVICE_DISABLED ; -} -static void monitor_thermal_zone (struct thermal_zone_device *tz) { -bool stop; - - stop =should_stop_polling (tz); +bool stop =tz_disabled (tz);drivers/thermal/thermal_core.c +0
-0mutex_lock (&tz->lock);drivers/thermal/thermal_core.c int thermal_zone_device_set_mode(struct · line 504
Quoted 10 lines
drivers/thermal/thermal_core.c +5
-0@@ -502,12 +495,18 @@ int thermal_zone_device_set_mode(structthermal_zone_device *tz, }EXPORT_SYMBOL_GPL (thermal_zone_device_set_mode ); +bool tz_disabled (struct thermal_zone_device *tz) +{ +return thermal_zone_device_get_mode (tz) ==THERMAL_DEVICE_DISABLED ; +} +EXPORT_SYMBOL (tz_disabled);Is there actual reason to not make it
_GPL?
Quoted 1 line
[ all other thermal core functionality seems to be
_GPLanyway ]
Thanks for catching this, will fix in next version.
Quoted 4 lines
Otherwise the patch looks fine:
Reviewed-by Bartlomiej Zolnierkiewicz <[email protected]>
thanks for the review.
-Rui
Quoted 34 lines
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung ElectronicsQuoted 25 lines
drivers/thermal/thermal_core.c +2
-1+void thermal_zone_device_update (struct thermal_zone_device *tz,enum thermal_notify_event event) {int count; -if (should_stop_polling (tz)) +if (tz_disabled (tz)) goto update_polling;drivers/thermal/thermal_core.c +0
-0if (atomic_read (&in_suspend))include/linux/thermal.h +2
-0@@ -479,4 +479,6 @@ static inline int thermal_zone_device_disable(struct thermal_zone_device *tz) return thermal_zone_device_set_mode(tz, THERMAL_DEVICE_DISABLED); } +bool tz_disabled (struct thermal_zone_device *tz); +#endif /* __THERMAL_H__ */
Zhang Rui
reviewerRFC PATCH 6/6 iwlwifi: enable thermal zone only when firmware loaded
In reply to Zhang Ruiin iwl_mvm_thermal_zone_register(), when registering a thermal zone, the thermal subsystem will evaluate its temperature.
But iwl_mvm_tzone_get_temp() fails at this time because iwl_mvm_firmware_running() returns false.
And that's why many users report that they see
"thermal thermal_zoneX: failed to read out thermal zone (-61)" message during wifi driver probing.
With the changes made earlier in this patch series, the problem can be solved by registering the iwlwifi thermal zone as disabled, and enable it later when the firmware is ready.
*NOTE*
This is just a prototype patch to illustrate the problem and how we can fix it based on the new thermal changes.
I'm not sure what is the proper place to enable/disable the thermal zone. The solution in this patch causes a deadlock issue because
a) thermal_zone_device_enable() is invoked with mvm->mutex locked.
b) .get_temp() callback is invoked when enabling the thermal zone.
c) iwl_mvm_tzone_get_temp() also needs to hold mvm->mutex. And that's why I hacked iwl_mvm_tzone_get_temp() to avoid this.
So if you have ideas on how to fix this, please feel free to propose it.
--- drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 2 ++ drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 4 ++++ drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +2 -0
@@ -1222,6 +1222,8 @@ int iwl_mvm_up(struct iwl_mvm *mvm)#ifdef CONFIG_THERMAL /* TODO: read the budget from BIOS / Platform NVM */ +if (mvm->tz_device.tzone &&tz_disabled (mvm->tz_device.tzone)) +thermal_zone_device_enable (mvm->tz_device.tzone);/* * In case there is no budget from BIOS / Platform NVM the default * budget should be 2000mW (cooling state 0).
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +4 -0
@@ -1946,6 +1946,10 @@ static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm)static inline void iwl_mvm_stop_device (struct iwl_mvm *mvm) { +#ifdef CONFIG_THERMAL +if (mvm->tz_device.tzone && !tz_disabled (mvm->tz_device.tzone)) +thermal_zone_device_disable (mvm->tz_device.tzone); +#endif lockdep_assert_held (&mvm->mutex);iwl_fw_cancel_timestamp (&mvm->fwrt);clear_bit (IWL_MVM_STATUS_FIRMWARE_RUNNING , &mvm->status);
drivers/net/wireless/intel/iwlwifi/mvm/tt.c +9 -3
@@ -620,8 +620,9 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,struct iwl_mvm *mvm = (struct iwl_mvm *)device->devdata;int ret;int temp; +int locked; -mutex_lock (&mvm->mutex); + locked =mutex_trylock (&mvm->mutex);if (!iwl_mvm_firmware_running (mvm) || mvm->fwrt.cur_fw_img !=IWL_UCODE_REGULAR ) {
@@ -636,7 +637,8 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device, *temperature = temp *1000 ; out: -mutex_unlock (&mvm->mutex); +if (locked) +mutex_unlock (&mvm->mutex);return ret; }
@@ -730,6 +732,10 @@ static struct thermal_zone_device_ops tzone_ops = {/* make all trips writable */ #define IWL_WRITABLE_TRIPS_MSK (BIT(IWL_MAX_DTS_TRIPS) - 1) +static struct thermal_zone_params tz_params = { + .initial_mode =THERMAL_DEVICE_DISABLED , +}; +static void iwl_mvm_thermal_zone_register (struct iwl_mvm *mvm) {int i;
@@ -749,7 +755,7 @@ static void iwl_mvm_thermal_zone_register(struct iwl_mvm *mvm)IWL_MAX_DTS_TRIPS ,IWL_WRITABLE_TRIPS_MSK , mvm, &tzone_ops, - NULL, 0, 0); + &tz_params, 0, 0);if (IS_ERR (mvm->tz_device.tzone)) { IWL_DEBUG_TEMP(mvm, "Failed to register to thermal zone (err = %ld)\n",
Signature · 1 line
2.7.4