thermal/drivers/hisi: Switch to interrupt mode
PATCH 1/1 thermal/drivers/hisi: Switch to interrupt mode
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive ooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
This patch disables the sensor when the temperature is below the temperature and enables it when passing the threshold. It resuls the sensor thermal sensor driver will have no activity most of the time.
--- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/thermal/hisi_thermal.c +14 -10
@@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } +static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, +bool on) +{ +struct thermal_zone_device *tzd = sensor->tzd; + + tzd->ops->set_mode (tzd, + on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); +} +static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };
@@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)dev_crit (&data->pdev->dev,"THERMAL ALARM: %d > %d\n" , temp, sensor->thres_temp); +hisi_thermal_toggle_sensor (&data->sensor, true); +thermal_zone_device_update (data->sensor.tzd,THERMAL_EVENT_UNSPECIFIED ); }else if (temp < sensor->thres_temp) {dev_crit (&data->pdev->dev,"THERMAL ALARM stopped: %d < %d\n" , temp, sensor->thres_temp); + +hisi_thermal_toggle_sensor (&data->sensor, false); }return IRQ_HANDLED ;
@@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { };MODULE_DEVICE_TABLE (of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, -bool on) -{ -struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode (tzd, - on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); -} -static int hisi_thermal_setup (struct hisi_thermal_data *data) {struct hisi_thermal_sensor *sensor;
@@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)return ret; } -hisi_thermal_toggle_sensor (&data->sensor, true); +hisi_thermal_toggle_sensor (&data->sensor, false);return 0 ; }
Signature · 1 line
2.7.4
Quoted 6 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive ooling device enters in the dance when 75C is reached. We need to
/s/ooling/cooling
Quoted 5 lines
sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
This patch disables the sensor when the temperature is below the temperature
temperature below 65C you mean?
Quoted 1 line
and enables it when passing the threshold. It resuls the sensor thermal sensor
/s/resuls/results
Quoted 1 line
driver will have no activity most of the time.
By chance you miss the interrupt you will never have cooling on again?
Quoted 69 lines
Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)drivers/thermal/hisi_thermal.c +14
-10@@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } +static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, +bool on) +{ +struct thermal_zone_device *tzd = sensor->tzd; + + tzd->ops->set_mode (tzd, + on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); +} +static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };@@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)dev_crit (&data->pdev->dev,"THERMAL ALARM: %d > %d\n" , temp, sensor->thres_temp); +hisi_thermal_toggle_sensor (&data->sensor, true); +thermal_zone_device_update (data->sensor.tzd,THERMAL_EVENT_UNSPECIFIED ); }else if (temp < sensor->thres_temp) {dev_crit (&data->pdev->dev,"THERMAL ALARM stopped: %d < %d\n" , temp, sensor->thres_temp); + +hisi_thermal_toggle_sensor (&data->sensor, false); }return IRQ_HANDLED ;@@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { };MODULE_DEVICE_TABLE (of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, -bool on) -{ -struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode (tzd, - on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); -} -static int hisi_thermal_setup (struct hisi_thermal_data *data) {struct hisi_thermal_sensor *sensor;@@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)return ret; } -hisi_thermal_toggle_sensor (&data->sensor, true); +hisi_thermal_toggle_sensor (&data->sensor, false);return 0 ; }
Quoted 12 lines · Keerthy
Quoted 6 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive ooling device enters in the dance when 75C is reached. We need to
/s/ooling/cooling
Quoted 7 lines
Quoted 5 lines
sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
This patch disables the sensor when the temperature is below the temperature
temperature below 65C you mean?
Yeah ... :/
Quoted 7 lines
Quoted 1 line
and enables it when passing the threshold. It resuls the sensor thermal sensor
/s/resuls/results
Quoted 1 line
driver will have no activity most of the time.
By chance you miss the interrupt you will never have cooling on again?
Mmh, I'm not sure it is possible to miss an interrupt with this driver but if it is the case, there are different scenario.
- The temperature is increasing and reaches the reset value: then the board reboots
- The temperature increases above 65C and then decreases, and increases again, the interrupt will fire and the driver will work as expected
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
PATCH v2 1/1 thermal/drivers/hisi: Switch to interrupt mode
In reply to KeerthyAt this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time.
--- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/thermal/hisi_thermal.c +14 -10
@@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } +static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, +bool on) +{ +struct thermal_zone_device *tzd = sensor->tzd; + + tzd->ops->set_mode (tzd, + on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); +} +static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };
@@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)dev_crit (&data->pdev->dev,"THERMAL ALARM: %d > %d\n" , temp, sensor->thres_temp); +hisi_thermal_toggle_sensor (&data->sensor, true); +thermal_zone_device_update (data->sensor.tzd,THERMAL_EVENT_UNSPECIFIED ); }else if (temp < sensor->thres_temp) {dev_crit (&data->pdev->dev,"THERMAL ALARM stopped: %d < %d\n" , temp, sensor->thres_temp); + +hisi_thermal_toggle_sensor (&data->sensor, false); }return IRQ_HANDLED ;
@@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { };MODULE_DEVICE_TABLE (of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, -bool on) -{ -struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode (tzd, - on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); -} -static int hisi_thermal_setup (struct hisi_thermal_data *data) {struct hisi_thermal_sensor *sensor;
@@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)return ret; } -hisi_thermal_toggle_sensor (&data->sensor, true); +hisi_thermal_toggle_sensor (&data->sensor, false);return 0 ; }
Signature · 1 line
2.7.4
Hi Daniel,
Quoted 10 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
Quoted 6 lines
This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time.
Cc Keerthy <[email protected]>Cc Leo Yang <[email protected]>
s/Yang/Yan :) Have tested this patch on Hikey at my side:
Quoted 70 lines
Signed-off-by Daniel Lezcano <[email protected]>--- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)drivers/thermal/hisi_thermal.c +14
-10@@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } +static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, +bool on) +{ +struct thermal_zone_device *tzd = sensor->tzd; + + tzd->ops->set_mode (tzd, + on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); +} +static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };@@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)dev_crit (&data->pdev->dev,"THERMAL ALARM: %d > %d\n" , temp, sensor->thres_temp); +hisi_thermal_toggle_sensor (&data->sensor, true); +thermal_zone_device_update (data->sensor.tzd,THERMAL_EVENT_UNSPECIFIED ); }else if (temp < sensor->thres_temp) {dev_crit (&data->pdev->dev,"THERMAL ALARM stopped: %d < %d\n" , temp, sensor->thres_temp); + +hisi_thermal_toggle_sensor (&data->sensor, false); }return IRQ_HANDLED ;@@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { };MODULE_DEVICE_TABLE (of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, -bool on) -{ -struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode (tzd, - on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); -} -static int hisi_thermal_setup (struct hisi_thermal_data *data) {struct hisi_thermal_sensor *sensor;@@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)return ret; } -hisi_thermal_toggle_sensor (&data->sensor, true); +hisi_thermal_toggle_sensor (&data->sensor, false);return 0 ; }Signature · 1 line
2.7.4
Quoted 13 lines · Leo Yan
Hi Daniel,
Quoted 10 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
Quoted 8 lines
Quoted 6 lines
This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time.
Cc Keerthy <[email protected]>Cc Leo Yang <[email protected]>s/Yang/Yan :) Have tested this patch on Hikey at my side:
Oops sorry :)
Quoted 2 lines
Reviewed-by Leo Yan <[email protected]>Tested-by Leo Yan <[email protected]>
Great! Thanks for testing.
-- Daniel
Hi,
Quoted 8 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation.
Sample collection is a valid point, but passive cooling should become active as soon as 65C is reached (at least that's the case with IPA). Furthermore, IPA's PID controller is reset when the temperature drops below the first trip-point (threshold) - as such, I believe the PID's behavior should be the same now as it with polling.
I think the main selling point of interrupt-based updates is a faster reaction time.
On the HiKey960, we can go from below the threshold temperature to over the control temperature in less than a second (default polling rate is 1s). In this situation, IPA's PID starts accumulating error while already overshooting, which isn't optimal. On top of that, the passive cooling reacts too slowly.
Quoted 10 lines
If the SoC is running at a temperature below 65C, we will
be constantly polling for nothing.This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time.
Cc Keerthy <[email protected]>Cc Leo Yang <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>
I've tested this on HiKey960 (Android 4.9 + upstream patches to apply your thermal/drivers/hisi series + Kevin's hi3600 support). I ran a video workload, and noticed I get several interrupts while passive cooling is already in effect
(I might move part of this discussion to Kevin's posting, but I think it's still relevant to be here):
[ 118.107357] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531] hisi_thermal fff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865] hisi_thermal fff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70700 > 65000
This isn't optimal for IPA, as the PID is supposed to use a specific sampling rate, but those interrupts forced a re-trigger of power_allocator_throttle which changes the PID's actual sampling rate. IPA isn't expecting this kind of scenarios, as I can see a tz->passive_delay in the computation of the derivative term (although the derivative coefficient defaults to 0...).
In a perfect world I would see those interrupts being toggled by the thermal governor, as that is where we know what to do with each trip point - we could still want the interrupts, but in the case of IPA we'd like to disable them while the PID controller is active, and we would know when to re-enable them (as soon as IPA is toggled off).
Quoted 66 lines
--- drivers/thermal/hisi_thermal.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)drivers/thermal/hisi_thermal.c +14
-10@@ -218,6 +218,15 @@ static int hisi_thermal_get_temp(void *__data, int *temp)return 0 ; } +static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, +bool on) +{ +struct thermal_zone_device *tzd = sensor->tzd; + + tzd->ops->set_mode (tzd, + on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); +} +static const struct thermal_zone_of_device_ops hisi_of_thermal_ops = { .get_temp = hisi_thermal_get_temp, };@@ -236,12 +245,16 @@ static irqreturn_t hisi_thermal_alarm_irq_thread(int irq, void *dev)dev_crit (&data->pdev->dev,"THERMAL ALARM: %d > %d\n" , temp, sensor->thres_temp); +hisi_thermal_toggle_sensor (&data->sensor, true); +thermal_zone_device_update (data->sensor.tzd,THERMAL_EVENT_UNSPECIFIED ); }else if (temp < sensor->thres_temp) {dev_crit (&data->pdev->dev,"THERMAL ALARM stopped: %d < %d\n" , temp, sensor->thres_temp); + +hisi_thermal_toggle_sensor (&data->sensor, false); }return IRQ_HANDLED ;@@ -286,15 +299,6 @@ static const struct of_device_id of_hisi_thermal_match[] = { };MODULE_DEVICE_TABLE (of, of_hisi_thermal_match); -static void hisi_thermal_toggle_sensor (struct hisi_thermal_sensor *sensor, -bool on) -{ -struct thermal_zone_device *tzd = sensor->tzd; - - tzd->ops->set_mode (tzd, - on ?THERMAL_DEVICE_ENABLED :THERMAL_DEVICE_DISABLED ); -} -static int hisi_thermal_setup (struct hisi_thermal_data *data) {struct hisi_thermal_sensor *sensor;@@ -393,7 +397,7 @@ static int hisi_thermal_probe(struct platform_device *pdev)return ret; } -hisi_thermal_toggle_sensor (&data->sensor, true); +hisi_thermal_toggle_sensor (&data->sensor, false);return 0 ; }
Hi Valentin,
On 29/09/2017 13:07, Valentin Schneider wrote:
[ ... ]
Quoted 13 lines
I've tested this on HiKey960 (Android 4.9 + upstream patches to apply your thermal/drivers/hisi series + Kevin's hi3600 support). I ran a video workload, and noticed I get several interrupts while passive cooling is already in effect
(I might move part of this discussion to Kevin's posting, but I think it's still relevant to be here):[ 118.107357]
hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531]hisi_thermalfff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865]hisi_thermalfff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70700 > 65000
Quoted 8 lines
This isn't optimal for IPA, as the PID is supposed to use a specific sampling rate, but those interrupts
forced a re-trigger ofpower_allocator_throttlewhich changes the PID's actual sampling rate.
IPA isn't expecting this kind of scenarios, as I can see atz->passive_delayin the computation
of the derivative term (although the derivative coefficient defaults to 0...).
Interesting. This patch actually is for the hikey, not for the hikey960. I didn't tested with Kevin's patches.
The thermal characteristics are very different on hi960. For example, the temperature increase is must faster on hikey960. So I guess, the driver itself should be fine tuned to prevent this kind of scenario.
Quoted 7 lines
In a perfect world I would see those interrupts being toggled by the thermal governor, as that is
where we know what to do with each trip point - we could still want the interrupts, but in the case
of IPA we'd like to disable them while the PID controller is active, and we would know when to re-enable them
(as soon as IPA is toggled off).
Yes, that is true the thermal framework could be enhanced to support this.
Do you have an hikey (not 960) to test this patch?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 27 lines · Daniel Lezcano
Hi Valentin,
On 29/09/2017 13:07, Valentin Schneider wrote:
[ ... ]
Quoted 13 lines
I've tested this on HiKey960 (Android 4.9 + upstream patches to apply your thermal/drivers/hisi series + Kevin's hi3600 support). I ran a video workload, and noticed I get several interrupts while passive cooling is already in effect
(I might move part of this discussion to Kevin's posting, but I think it's still relevant to be here):[ 118.107357]
hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531]hisi_thermalfff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865]hisi_thermalfff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70700 > 65000Quoted 8 lines
This isn't optimal for IPA, as the PID is supposed to use a specific sampling rate, but those interrupts
forced a re-trigger ofpower_allocator_throttlewhich changes the PID's actual sampling rate.
IPA isn't expecting this kind of scenarios, as I can see atz->passive_delayin the computation
of the derivative term (although the derivative coefficient defaults to 0...).
Quoted 6 lines
Interesting. This patch actually is for the hikey, not for the hikey960. I didn't tested with Kevin's patches.
The thermal characteristics are very different on hi960. For example, the temperature increase is must faster on hikey960. So I guess, the driver itself should be fine tuned to prevent this kind of scenario.
True
Quoted 8 lines
Quoted 7 lines
In a perfect world I would see those interrupts being toggled by the thermal governor, as that is
where we know what to do with each trip point - we could still want the interrupts, but in the case
of IPA we'd like to disable them while the PID controller is active, and we would know when to re-enable them
(as soon as IPA is toggled off).Yes, that is true the thermal framework could be enhanced to support this.
If you're up for it, it could be an interesting discussion. In any case, I might spend a little bit of time looking into making such an interrupt-toggling work (at least as a prototype just on the HiKey960).
Quoted 2 lines
Do you have an hikey (not 960) to test this patch?
I do have one but I'm currently lending it to someone else in my team, I'll have to track it down (probably next week).
I'm actually quite interested in having IPA triggered by interrupt because of the HiKey960's tendency to heat up insanely fast, which leads to IPA starting when the temperature is already way too high. I started toying around with Kevin's patches but saw your own patch and thought it was related, so I figured I would share some of my thoughts before starting to work on something someone else might already be working on.
I should perhaps move some of those comments to Kevin's posting - sorry for the noise.
Quoted 2 lines
Oh, I noticed Kevin is not in the loop, Cc'ing him.
Sorry Kevin.
Quoted 76 lines · Valentin Schneider
Quoted 32 lines · Daniel Lezcano
Hi Valentin,
On 29/09/2017 13:07, Valentin Schneider wrote:
[ ... ]
Quoted 18 lines
I've tested this on HiKey960 (Android 4.9 + upstream patches to apply your thermal/drivers/hisi series + Kevin's hi3600 support). I ran a video workload, and noticed I get several interrupts while passive cooling is already in effect
(I might move part of this discussion to Kevin's posting, but I think it's still relevant to be here):[ 118.107357]
hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000
[ 119.182531]hisi_thermalfff30000.tsensor: THERMAL ALARM: 76235 > 65000
[ 119.361964]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000
[ 119.907865]hisi_thermalfff30000.tsensor: THERMAL ALARM: 75620 > 65000
[ 119.959076]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70700 > 65000Quoted 8 lines
This isn't optimal for IPA, as the PID is supposed to use a specific sampling rate, but those interrupts
forced a re-trigger ofpower_allocator_throttlewhich changes the PID's actual sampling rate.
IPA isn't expecting this kind of scenarios, as I can see atz->passive_delayin the computation
of the derivative term (although the derivative coefficient defaults to 0...).Quoted 6 lines
Interesting. This patch actually is for the hikey, not for the hikey960. I didn't tested with Kevin's patches.
The thermal characteristics are very different on hi960. For example, the temperature increase is must faster on hikey960. So I guess, the driver itself should be fine tuned to prevent this kind of scenario.
True
Quoted 9 lines
Quoted 7 lines
In a perfect world I would see those interrupts being toggled by the thermal governor, as that is
where we know what to do with each trip point - we could still want the interrupts, but in the case
of IPA we'd like to disable them while the PID controller is active, and we would know when to re-enable them
(as soon as IPA is toggled off).Yes, that is true the thermal framework could be enhanced to support this.
If you're up for it, it could be an interesting discussion. In any case, I might spend a little bit of time looking into making such an interrupt-toggling work (at least as a prototype just on the HiKey960).
Quoted 2 lines
Do you have an hikey (not 960) to test this patch?
I do have one but I'm currently lending it to someone else in my team, I'll have to track it down (probably next week).
I'm actually quite interested in having IPA triggered by interrupt because of the HiKey960's tendency to heat up insanely fast, which leads to IPA starting when the temperature is already way too high. I started toying around with Kevin's patches but saw your own patch and thought it was related, so I figured I would share some of my thoughts before starting to work on something someone else might already be working on.I should perhaps move some of those comments to Kevin's posting - sorry for the noise.
Quoted 2 lines
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 53 lines · Valentin Schneider
Hi,
Quoted 6 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The
interrupt does nothing more than forcing an update while the temperature is
polled every second.Quoted 7 lines
We can do much better than that, threshold is set to 65C in the DT and the
passive cooling device enters in the dance when 75C is reached. We need to
sample the temperature at 65C in order to let the IPA gather enough values for
the PID computation.Sample collection is a valid point, but passive cooling should become active as soon
as 65C is reached (at least that's the case with IPA). Furthermore, IPA's PID controller
is reset when the temperature drops below the first trip-point (threshold) - as such,
I believe the PID's behavior should be the same now as it with polling.I think the main selling point of interrupt-based updates is a faster reaction time.
On the HiKey960, we can go from below the threshold temperature to over the control temperature
in less than a second (default polling rate is 1s). In this situation, IPA's PID starts accumulating error
while already overshooting, which isn't optimal. On top of that, the passive cooling reacts
too slowly.Quoted 9 lines
If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
This patch disables the sensor when the temperature is below 65C and enables it
when passing the threshold. It results the thermal sensor driver will have no
activity most of the time.Quoted 3 lines
Cc Keerthy <[email protected]>Cc Leo Yang <[email protected]>Signed-off-by Daniel Lezcano <[email protected]>I've tested this on HiKey960 (Android 4.9 + upstream patches to apply your thermal/drivers/hisi series + Kevin's hi3600 support). I ran a video workload, and noticed I get several interrupts while passive cooling is already in effect
(I might move part of this discussion to Kevin's posting, but I think it's still relevant to be here):
Quoted 5 lines
[ 118.107357]
hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531]hisi_thermalfff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865]hisi_thermalfff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70700 > 65000
Ok, so apparently there are multiple alarms level in the driver for the hikey960 [1]. So I prefer to drop this patch for now and take the hikey960 thermal support first and we can sort out the issue later.
For my information, can you show me the DT snippet you have for the thermal zones?
-- Daniel
[1] https://patchwork.kernel.org/patch/9965743/
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 6 lines · Daniel Lezcano
Ok, so apparently there are multiple alarms level in the driver for the hikey960 [1]. So I prefer to drop this patch for now and take the hikey960 thermal support first and we can sort out the issue later.
For my information, can you show me the DT snippet you have for the thermal zones?
Sure thing:
thermal-zones {
cls0: cls0 {
polling-delay = <1000>;
polling-delay-passive = <100>;
sustainable-power = <4500>;
/* sensor ID */
thermal-sensors = <&tsensor 1>;
trips {
threshold: trip-point@0 {
temperature = <65000>;
hysteresis = <1000>;
type = "passive";
};
target: trip-point@1 {
temperature = <75000>;
hysteresis = <1000>;
type = "passive";
};
};
cooling-maps {
map0 {
trip = <&target>;
contribution = <1024>;
cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; };
map1 {
trip = <&target>;
contribution = <512>;
cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; };
map2 {
trip = <&target>;
contribution = <1024>;
cooling-device = <&gpu THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; };
};
};
};
It's exactly what is on the Android 4.9 kernel (https://android.googlesource.com/kernel/hikey-linaro/+/android-hikey-linaro-4.9/arch/arm64/boot/dts/hisilicon/hi3660.dtsi#1272), with the tsensor index changed from 4 to 1 to work with Kevin's patches.
Quoted 6 lines
-- Daniel
Quoted 27 lines · Valentin Schneider
Quoted 6 lines · Daniel Lezcano
Ok, so apparently there are multiple alarms level in the driver for the hikey960 [1]. So I prefer to drop this patch for now and take the hikey960 thermal support first and we can sort out the issue later.
For my information, can you show me the DT snippet you have for the thermal zones?
Sure thing:
thermal-zones {
cls0: cls0 {
polling-delay = <1000>;
polling-delay-passive = <100>;
sustainable-power = <4500>;/* sensor ID */
thermal-sensors = <&tsensor 1>;trips {
threshold: trip-point@0 {
temperature = <65000>;
hysteresis = <1000>;
type = "passive";
};
Quoted 6 lines
target: trip-point@1 {
temperature = <75000>;
hysteresis = <1000>;
type = "passive";
};
};
That's strange, regarding your traces:
"
[ 118.107357] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531] hisi_thermal fff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865] hisi_thermal fff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70700 > 65000
"
I was expecting to see more trip points. Did you test the driver with a 70000 trip point?
[ ... ]
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 41 lines · Daniel Lezcano
Quoted 26 lines · Valentin Schneider
Quoted 6 lines · Daniel Lezcano
Ok, so apparently there are multiple alarms level in the driver for the hikey960 [1]. So I prefer to drop this patch for now and take the hikey960 thermal support first and we can sort out the issue later.
For my information, can you show me the DT snippet you have for the thermal zones?
Sure thing:
thermal-zones {
cls0: cls0 {
polling-delay = <1000>;
polling-delay-passive = <100>;
sustainable-power = <4500>;/* sensor ID */
thermal-sensors = <&tsensor 1>;trips {
threshold: trip-point@0 {
temperature = <65000>;
hysteresis = <1000>;
type = "passive";
};Quoted 6 lines
target: trip-point@1 {
temperature = <75000>;
hysteresis = <1000>;
type = "passive";
};
};That's strange, regarding your traces:
"
[ 118.107357] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531] hisi_thermal fff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865] hisi_thermal fff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70700 > 65000
Quoted 4 lines
"
I was expecting to see more trip points. Did you test the driver with a 70000 trip point?
No, I didn't change any setting other than the tsensor index to make things work. Mind you, in Kevin's patch series the thermal alarm is setup with a 4 degrees "lag", i.e. alarms will only be re-triggered if temperature increases/decreases of at least 4 degrees (which explains the traces).
Quoted 5 lines
[ ... ]
Quoted 51 lines · Valentin Schneider
Quoted 48 lines · Daniel Lezcano
Quoted 26 lines · Valentin Schneider
Quoted 6 lines · Daniel Lezcano
Ok, so apparently there are multiple alarms level in the driver for the hikey960 [1]. So I prefer to drop this patch for now and take the hikey960 thermal support first and we can sort out the issue later.
For my information, can you show me the DT snippet you have for the thermal zones?
Sure thing:
thermal-zones {
cls0: cls0 {
polling-delay = <1000>;
polling-delay-passive = <100>;
sustainable-power = <4500>;/* sensor ID */
thermal-sensors = <&tsensor 1>;trips {
threshold: trip-point@0 {
temperature = <65000>;
hysteresis = <1000>;
type = "passive";
};Quoted 6 lines
target: trip-point@1 {
temperature = <75000>;
hysteresis = <1000>;
type = "passive";
};
};That's strange, regarding your traces:
"
[ 118.107357]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000
[ 119.182531]hisi_thermalfff30000.tsensor: THERMAL ALARM: 76235 > 65000
[ 119.361964]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70495 > 65000
[ 119.907865]hisi_thermalfff30000.tsensor: THERMAL ALARM: 75620 > 65000
[ 119.959076]hisi_thermalfff30000.tsensor: THERMAL ALARM: 70700 > 65000
"
Quoted 8 lines
Quoted 2 lines
I was expecting to see more trip points. Did you test the driver with a 70000 trip point?
No, I didn't change any setting other than the tsensor index to make things work. Mind you, in Kevin's patch series the thermal alarm is setup with a 4 degrees "lag", i.e. alarms will only be re-triggered if temperature increases/decreases of at least 4 degrees (which explains the traces).
Mmh, the behavior regarding the interrupt is slightly different with the hi960, perhaps a bit fuzzy regarding how it is handled now. Anyway, we can live with that now and go further to fix that later, the result is the same.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Quoted 52 lines · Daniel Lezcano
Quoted 51 lines · Valentin Schneider
Quoted 48 lines · Daniel Lezcano
Quoted 24 lines · Valentin Schneider
Quoted 6 lines · Daniel Lezcano
Ok, so apparently there are multiple alarms level in the driver for the hikey960 [1]. So I prefer to drop this patch for now and take the hikey960 thermal support first and we can sort out the issue later.
For my information, can you show me the DT snippet you have for the thermal zones?
Sure thing:
thermal-zones { cls0: cls0 { polling-delay = <1000>; polling-delay-passive = <100>; sustainable-power = <4500>; /* sensor ID */ thermal-sensors = <&tsensor 1>; trips { threshold: trip-point@0 { temperature = <65000>; hysteresis = <1000>; type = "passive";Quoted 8 lines
}; target: trip-point@1 { temperature = <75000>; hysteresis = <1000>; type = "passive"; }; };That's strange, regarding your traces:
"
[ 118.107357] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.182531] hisi_thermal fff30000.tsensor: THERMAL ALARM: 76235 > 65000 [ 119.361964] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70495 > 65000 [ 119.907865] hisi_thermal fff30000.tsensor: THERMAL ALARM: 75620 > 65000 [ 119.959076] hisi_thermal fff30000.tsensor: THERMAL ALARM: 70700 >65000
"
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
I was expecting to see more trip points. Did you test the driver with a 70000 trip point?
No, I didn't change any setting other than the tsensor index to make things work. Mind you, in Kevin's patch series the thermal alarm is setup with a 4 degrees "lag", i.e. alarms will only be re-triggered if temperature increases/decreases of at least 4 degrees (which explains the traces).
This should be a trip point 75000, cross 75000 triger an interrupt and drop below 71000 triger another interrupt, the multi alarm interrupt is not suitable for ipa as you discussed before, we should drop the patch of multi alarm support.
Quoted 7 lines
Mmh, the behavior regarding the interrupt is slightly different with the hi960, perhaps a bit fuzzy regarding how it is handled now. Anyway, we can live with that now and go further to fix that later, the result is the same.
Hello,
Quoted 18 lines · Daniel Lezcano
Quoted 17 lines · Leo Yan
Hi Daniel,
Quoted 14 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time.
Quoted 10 lines
Quoted 4 lines
Quoted 2 lines
Cc Keerthy <[email protected]>Cc Leo Yang <[email protected]>s/Yang/Yan :) Have tested this patch on Hikey at my side:
Oops sorry :)
Quoted 2 lines
Reviewed-by Leo Yan <[email protected]>Tested-by Leo Yan <[email protected]>
Is this still needed after the latest rework done?
Quoted 4 lines
Great! Thanks for testing.
-- Daniel
Quoted 26 lines · Eduardo Valentin
Hello,
Quoted 23 lines · Daniel Lezcano
Quoted 21 lines · Leo Yan
Hi Daniel,
Quoted 10 lines · Daniel Lezcano
At this moment, we have both the interrupt setup and the polling enabled. The interrupt does nothing more than forcing an update while the temperature is polled every second.
We can do much better than that, threshold is set to 65C in the DT and the passive cooling device enters in the dance when 75C is reached. We need to sample the temperature at 65C in order to let the IPA gather enough values for the PID computation. If the SoC is running at a temperature below 65C, we will be constantly polling for nothing.
Quoted 6 lines
This patch disables the sensor when the temperature is below 65C and enables it when passing the threshold. It results the thermal sensor driver will have no activity most of the time.
Cc Keerthy <[email protected]>Cc Leo Yang <[email protected]>s/Yang/Yan :) Have tested this patch on Hikey at my side:
Quoted 7 lines
Quoted 5 lines
Oops sorry :)
Quoted 2 lines
Reviewed-by Leo Yan <[email protected]>Tested-by Leo Yan <[email protected]>Is this still needed after the latest rework done?
No longer needed.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog