cpufreq:boost: CPU Boost mode support
Subsystems (12)
Re: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST feature
In reply to R, DurgadossOn Thu, 4 Jul 2013 17:19:04 +0000
"R, Durgadoss" <[email protected]> wrote:
Hi,
Quoted 71 lines
Hi Lukasz,
Quoted 69 lines
-----Original Message-----
From: [email protected] [mailto:linux-pm- [email protected]] On Behalf Of Lukasz Majewski
Sent: Thursday, July 04, 2013 2:20 PM
To: Viresh Kumar; Rafael J. Wysocki; Zhang, Rui; Eduardo Valentin
Cc: [email protected]; Linux PM list; Jonghwa Lee; Lukasz Majewski; [email protected]; linux-kernel; Andre Przywara; Daniel Lezcano; Kukjin Kim; Myungjoo Ham
Subject: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST featureThis patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled. In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Changes for v4:
- New patchdrivers/thermal/thermal_core.c | 31+++++++++++++++++++++++++++++++
include/linux/thermal.h|
2 ++ 2 files changed, 33 insertions(+)(quoted diff) +0
-0
b/drivers/thermal/thermal_core.cindex d755440..12adbad 100644drivers/thermal/thermal_core.c +10
-0@@ -33,6 +33,7 @@#include <linux/idr.h> #include <linux/thermal.h> #include <linux/reboot.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h> @@ -326,6 +327,15 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)static void handle_non_critical_trips (struct thermal_zone_device *tz,int trip,enum thermal_trip_type trip_type) { +if (cpufreq_boost_supported ()) { + tz->overheated = true; +cpufreq_boost_trigger_state (0 ); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + } +if (tz->governor) tz->governor->throttle (tz, trip);}
drivers/thermal/thermal_core.c +0
-0@@ -453,6 +463,27 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct
Quoted 8 lines
drivers/thermal/thermal_core.c static void thermal_zone_device_check(struct work_struct *work) · line 468
Quoted 5 lines
drivers/thermal/thermal_core.c +3
-0thermal_zone_device, poll_queue.work); +long trip_temp; + +if (cpufreq_boost_supported () && tz->overheated) {Not all thermal drivers support trip points. So, we first need a if (
tz->ops->get_trip_temp) check here.
Ok, thanks for tip. Bluntly speaking, I thought, that all SoCs supported by thermal set trip points.
Quoted 12 lines
Quoted 9 lines
drivers/thermal/thermal_core.c +3
-0+ tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less
drivers/thermal/thermal_core.c +3
-0+* than 75% of trip_temp[0] +*/ + if ((tz->temperature + (trip_temp >> 2)) <
trip_temp) {Another way would be to use the
get_trendAPIs for this thermal zone. If the trend is cooling we can re-enable boost otherwise not.
Trend evaluation seems like a good complementary idea.
However, I would also like to have the relative temperature drop measurement (if possible) like above (to 75% of the first trip point).
Then I would be more confident, that everything cooled down and that I can start boost again.
Quoted 10 lines
drivers/thermal/thermal_core.c static void thermal_zone_device_check(struct work_struct *work) · line 480
Quoted 7 lines
drivers/thermal/thermal_core.c +6
-0+ tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; +monitor_thermal_zone (tz); + }Overall, I believe this will work well only if the thermal zone is CPU.
My assumption:
When I enable boost at CPU, then I also shall cool down the CPU. And the CPU zone seemed a natural choice.
However I might be missing something, so hints are welcome.
Quoted 3 lines
Another suggestion is: We tried hard to remove all throttling logic from
thermal_core.c.
By throttling logic you mean:
if ((tz->temperature + (trip_temp >> 2)) and other conditions (like trend measurement)?
Quoted 2 lines
May be we should include this kind of logic in
step_wise.c?
It sounds interesting (since ->throttle at thermal_core.c is called always when needed), but I'm afraid of a code duplication when one use Boost with fair_share or other thermal governor.
Quoted 33 lines
Rui/Eduardo: Any thoughts on this ?
Thanks,
DurgaQuoted 29 lines
drivers/thermal/thermal_core.c +6
-0+ +cpufreq_boost_trigger_state (1 ); +return ; + } + } +thermal_zone_device_update (tz); }include/linux/thermal.h +2
-1@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor; --1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST feature
Hi Lukasz,
Quoted 14 lines
-----Original Message-----
From: Lukasz Majewski [mailto:[email protected]]
Sent: Friday, July 05, 2013 2:28 AM
To: R, Durgadoss
Cc: Lukasz Majewski; Viresh Kumar; Rafael J. Wysocki; Zhang, Rui; Eduardo Valentin; [email protected]; Linux PM list; Jonghwa Lee; linux-kernel; Andre Przywara; Daniel Lezcano; Kukjin Kim; Myungjoo Ham
Subject: Re: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST featureOn Thu, 4 Jul 2013 17:19:04 +0000
"R, Durgadoss" <[email protected]> wrote:
Hi,
[Cut.]
Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
drivers/thermal/thermal_core.c +9
-0@@ -326,6 +327,15 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)static void handle_non_critical_trips (struct thermal_zone_device *tz,int trip,enum thermal_trip_type trip_type) { +if (cpufreq_boost_supported ()) { + tz->overheated = true; +cpufreq_boost_trigger_state (0 ); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + } +if (tz->governor) tz->governor->throttle (tz, trip);}
(quoted diff) +0
-0@@ -453,6 +463,27 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, structQuoted 8 lines
drivers/thermal/thermal_core.c static void thermal_zone_device_check(struct work_struct *work) · line 468
Quoted 5 lines
drivers/thermal/thermal_core.c +3
-0thermal_zone_device, poll_queue.work); +long trip_temp; + +if (cpufreq_boost_supported () && tz->overheated) {Not all thermal drivers support trip points. So, we first need a if (
tz->ops->get_trip_temp) check here.
Quoted 2 lines
Ok, thanks for tip. Bluntly speaking, I thought, that all SoCs supported by thermal set trip points.
We would wish to get there. But not the reality today ;)
Quoted 41 lines
Quoted 13 lines
Quoted 10 lines
drivers/thermal/thermal_core.c +3
-0+ tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less
drivers/thermal/thermal_core.c +3
-0+* than 75% of trip_temp[0] +*/ + if ((tz->temperature + (trip_temp >> 2)) <
trip_temp) {Another way would be to use the
get_trendAPIs for this thermal zone. If the trend is cooling we can re-enable boost otherwise not.Trend evaluation seems like a good complementary idea.
However, I would also like to have the relative temperature drop measurement (if possible) like above (to 75% of the first trip point).
Then I would be more confident, that everything cooled down and that I can start boost again.
Quoted 10 lines
drivers/thermal/thermal_core.c static void thermal_zone_device_check(struct work_struct *work) · line 480
Quoted 7 lines
drivers/thermal/thermal_core.c +6
-0+ tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; +monitor_thermal_zone (tz); + }Overall, I believe this will work well only if the thermal zone is CPU.
My assumption:
When I enable boost at CPU, then I also shall cool down the CPU. And the CPU zone seemed a natural choice.
However I might be missing something, so hints are welcome.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Another suggestion is: We tried hard to remove all throttling logic from
thermal_core.c.By throttling logic you mean:
if ((tz->temperature+ (trip_temp>> 2)) and other conditions (like trend measurement)?
Yes. That is correct.
Quoted 7 lines
Quoted 3 lines
May be we should include this kind of logic in
step_wise.c?It sounds interesting (since ->throttle at
thermal_core.cis called always when needed), but I'm afraid of a code duplication when one use Boost withfair_shareor other thermal governor.
right. So, for the time being, (as part of this patch series) I am Okay to have this code in thermal_core.c. From the thermal subsystem perspective, we will (need to) work out a better/ cleaner/easier approach for this later.
Thanks,
Durga
Re: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST feature
On Fri, 05 Jul 2013 05:31:42 +0000, R, Durgadoss wrote:
Hi Durga,
Quoted 48 lines
Hi Lukasz,
Quoted 14 lines
-----Original Message-----
From: Lukasz Majewski [mailto:[email protected]]
Sent: Friday, July 05, 2013 2:28 AM
To: R, Durgadoss
Cc: Lukasz Majewski; Viresh Kumar; Rafael J. Wysocki; Zhang, Rui; Eduardo Valentin; [email protected]; Linux PM list; Jonghwa Lee; linux-kernel; Andre Przywara; Daniel Lezcano; Kukjin Kim; Myungjoo Ham Subject: Re: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST featureOn Thu, 4 Jul 2013 17:19:04 +0000
"R, Durgadoss" <[email protected]> wrote:
Hi,[Cut.]
Quoted 29 lines
Quoted 28 lines
Quoted 18 lines
(quoted diff) +0
-0@@ -326,6 +327,15 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz) static void handle_non_critical_trips(struct
thermal_zone_device*tz, int trip, enumthermal_trip_typetrip_type) {drivers/thermal/thermal_core.c +9
-0+if (cpufreq_boost_supported ()) { + tz->overheated = true; +cpufreq_boost_trigger_state (0 ); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + } +if (tz->governor) tz->governor->throttle (tz, trip); }drivers/thermal/thermal_core.c static void · line 469
Quoted 7 lines
drivers/thermal/thermal_core.c +3
-0@@ -453,6 +463,27 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +long trip_temp; + +if (cpufreq_boost_supported () && tz->overheated) {Not all thermal drivers support trip points. So, we first need a if (
tz->ops->get_trip_temp) check here.
Quoted 4 lines
Quoted 2 lines
Ok, thanks for tip. Bluntly speaking, I thought, that all SoCs supported by thermal set trip points.
We would wish to get there. But not the reality today ;)
Ok, I see :-).
Quoted 44 lines
Quoted 44 lines
Quoted 15 lines
Quoted 11 lines
drivers/thermal/thermal_core.c +3
-0+ tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less
drivers/thermal/thermal_core.c +3
-0+* than 75% of trip_temp[0] +*/ + if ((tz->temperature + (trip_temp >> 2)) <
trip_temp) {Another way would be to use the
get_trendAPIs for this thermal zone. If the trend is cooling we can re-enable boost otherwise not.Trend evaluation seems like a good complementary idea.
However, I would also like to have the relative temperature drop measurement (if possible) like above (to 75% of the first trip point).
Then I would be more confident, that everything cooled down and that I can start boost again.
Quoted 10 lines
drivers/thermal/thermal_core.c static void thermal_zone_device_check(struct work_struct *work) · line 480
Quoted 7 lines
drivers/thermal/thermal_core.c +6
-0+ tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; +monitor_thermal_zone (tz); + }Overall, I believe this will work well only if the thermal zone is CPU.
My assumption:
When I enable boost at CPU, then I also shall cool down the CPU. And the CPU zone seemed a natural choice.
However I might be missing something, so hints are welcome.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Another suggestion is: We tried hard to remove all throttling logic from
thermal_core.c.By throttling logic you mean:
if ((tz->temperature+ (trip_temp>> 2)) and other conditions (like trend measurement)?Yes. That is correct.
Ok.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
May be we should include this kind of logic in
step_wise.c?
Quoted 8 lines
Quoted 3 lines
It sounds interesting (since ->throttle at
thermal_core.cis called always when needed), but I'm afraid of a code duplication when one use Boost withfair_shareor other thermal governor.right. So, for the time being, (as part of this patch series) I am Okay to have this code in
thermal_core.c. From the thermal subsystem perspective, we will (need to) work out a better/ cleaner/easier approach for this later.
Thanks for understanding. I'm going to embed the trend checking in the next version of this patch (to be more confident that I can reenable boost).
Quoted 4 lines
Thanks,
Durga
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST feature
In reply to Lukasz MajewskiDear Zhang, Eduardo
Do you have any comments/feedback for me regarding this thermal framework related patch?
I've already received some feedback from Durga for this patch, but I think that maintainers are most welcome to express their opinion :-)
Thanks in advance.
Quoted 97 lines
This patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Changes for v4:
- New patchdrivers/thermal/thermal_core.c | 31 +++++++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 33 insertions(+)(quoted diff) +0
-0
b/drivers/thermal/thermal_core.cindex d755440..12adbad 100644drivers/thermal/thermal_core.c +1
-0@@ -33,6 +33,7 @@#include <linux/idr.h> #include <linux/thermal.h> #include <linux/reboot.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h> @@ -326,6 +327,15 @@ static void monitor_thermal_zone(struct
thermal_zone_device*tz) static voidhandle_non_critical_trips(struct thermal_zone_device *tz, int trip, enum thermal_trip_type trip_type)
{drivers/thermal/thermal_core.c +9
-0+if (cpufreq_boost_supported ()) { + tz->overheated = true; +cpufreq_boost_trigger_state (0 ); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + } +if (tz->governor) tz->governor->throttle (tz, trip); }@@ -453,6 +463,27 @@ static void thermal_zone_device_check(struct
work_struct*work) structthermal_zone_device*tz = container_of(work, structthermal_zone_device,drivers/thermal/thermal_core.c +6
-0poll_queue.work); +long trip_temp; + +if (cpufreq_boost_supported () && tz->overheated) { + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less
drivers/thermal/thermal_core.c +3
-0+* than 75% of trip_temp[0] +*/ + if ((tz->temperature + (trip_temp >> 2)) <
trip_temp) {drivers/thermal/thermal_core.c +12
-0+ tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; +monitor_thermal_zone (tz); + } + +cpufreq_boost_trigger_state (1 ); +return ; + } + } +thermal_zone_device_update (tz); }include/linux/thermal.h +2
-0@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v5 5/7] thermal:boost: Automatic enable/disable of BOOST feature
Dear Zhang, Eduardo,
Quoted 8 lines
Dear Zhang, Eduardo
Do you have any comments/feedback for me regarding this thermal framework related patch?
I've already received some feedback from Durga for this patch, but I think that maintainers are most welcome to express their opinion :-)
Will you find time to give me the feedback about proposed changes to thermal_core.c regarding the cpufreq boost support?
Quoted 2 lines
Thanks in advance.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v5 6/7 cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "CPU frequency BOOST support" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ be enabled without thermal subsystem with properly defined temperatures, which indicate overheating.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 14 ++++++++++++++ drivers/cpufreq/exynos-cpufreq.c | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-)
drivers/cpufreq/Kconfig +14 -0
@@ -23,6 +23,20 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)" + depends on ARM_EXYNOS_CPUFREQ && EXYNOS_THERMAL + default n + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for a particular processor + if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly defined + trip points. + + If in doubt, say N. + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE
drivers/cpufreq/exynos-cpufreq.c +4 -1
@@ -288,7 +288,9 @@ static struct cpufreq_driver exynos_driver = {static int __init exynos_cpufreq_init (void ) { +#ifdef CONFIG_CPU_FREQ_BOOST_SW struct device_node *node = pdev->dev.of_node; +#endif int ret = -EINVAL ; exynos_info =kzalloc (sizeof (struct exynos_dvfs_info ),GFP_KERNEL );
@@ -319,9 +321,10 @@ static int __init exynos_cpufreq_init(void) } locking_frequency =exynos_getspeed (0 ); +#ifdef CONFIG_CPU_FREQ_BOOST_SW if (of_property_read_bool (node,"boost_mode" )) exynos_driver.boost_supported =1 ; - +#endif register_pm_notifier (&exynos_cpufreq_nb);if (cpufreq_register_driver (&exynos_driver)) {
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 4 lines · Lukasz Majewski
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)"
Name it "CPU Frequency Overclocking - Software"
Quoted 1 line
+ depends on
ARM_EXYNOS_CPUFREQ&&EXYNOS_THERMAL
Remote Exynos from here. If you want to enable it for your platform by default, then select it from EXYNOS.
Quoted 29 lines
drivers/cpufreq/Kconfig +11
-0+ default n + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for a particular processor + if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly defined + trip points. + + If in doubt, say N. + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLEdrivers/cpufreq/exynos-cpufreq.c +2
-0@@ -288,7 +288,9 @@ static struct cpufreq_driver exynos_driver = {static int __init exynos_cpufreq_init (void ) { +#ifdef CONFIG_CPU_FREQ_BOOST_SW struct device_node *node = pdev->dev.of_node; +#endif int ret = -EINVAL ; exynos_info =kzalloc (sizeof (struct exynos_dvfs_info ),GFP_KERNEL );
drivers/cpufreq/exynos-cpufreq.c static int __init exynos_cpufreq_init(void) · line 327
Quoted 8 lines
drivers/cpufreq/exynos-cpufreq.c +2
-1@@ -319,9 +321,10 @@ static int __init exynos_cpufreq_init(void) } locking_frequency =exynos_getspeed (0 ); +#ifdef CONFIG_CPU_FREQ_BOOST_SW if (of_property_read_bool (node,"boost_mode" )) exynos_driver.boost_supported =1 ; - +#endif
Add a blank line here.
Quoted 6 lines
drivers/cpufreq/exynos-cpufreq.c +0
-1register_pm_notifier (&exynos_cpufreq_nb);if (cpufreq_register_driver (&exynos_driver)) { --1.7.10.4
Re: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
On Tue, 16 Jul 2013 15:28:40 +0530 Viresh Kumar [email protected] wrote,
Quoted 7 lines · Lukasz Majewski
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 4 lines
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)"Name it "CPU Frequency Overclocking - Software"
Thanks, I had a puzzle to came up with a good short name :-).
Quoted 2 lines
Quoted 2 lines
+ depends on
ARM_EXYNOS_CPUFREQ&&EXYNOS_THERMAL&&EXYNOS_THERMAL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]
Quoted 3 lines
Remote Exynos from here. If you want to enable it for your platform by default, then select it from EXYNOS.
The purpose of the condition [*] here is to prevent from enabling boost when thermal for Exynos is not supported.
Only for properly configured Exynos (when thermal + cpufreq is set) the option is possible to enable. And by default it is disabled. This shall prevent from accidental boost usage.
Please also note, that this switch only affects software based boost. The HW boost (Intel ACPI) support doesn't depend on this Kconfig setting.
Quoted 34 lines
Quoted 34 lines
drivers/cpufreq/Kconfig +4
-0+ default n + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for a particularprocessor
drivers/cpufreq/Kconfig +3
-0+ if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework withproperly defined
drivers/cpufreq/Kconfig +4
-0+ trip points. + + If in doubt, say N. + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE(quoted diff) +0
-0
b/drivers/cpufreq/exynos-cpufreq.cindex 4f42fcc..7586b28 100644drivers/cpufreq/exynos-cpufreq.c +2
-0@@ -288,7 +288,9 @@ static struct cpufreq_driver exynos_driver = {static int __init exynos_cpufreq_init (void ) { +#ifdef CONFIG_CPU_FREQ_BOOST_SW struct device_node *node = pdev->dev.of_node; +#endif int ret = -EINVAL ; exynos_info = kzalloc(sizeof(struct exynos_dvfs_info),
GFP_KERNEL); @@ -319,9 +321,10 @@ static int__initexynos_cpufreq_init(void)}
Quoted 8 lines
drivers/cpufreq/exynos-cpufreq.c static int __init exynos_cpufreq_init(void) · line 327
Quoted 6 lines
locking_frequency = exynos_getspeed(0);drivers/cpufreq/exynos-cpufreq.c +2
-1+#ifdef CONFIG_CPU_FREQ_BOOST_SW if (of_property_read_bool (node,"boost_mode" )) exynos_driver.boost_supported =1 ; - +#endif Add a blank line here.
OK
Quoted 7 lines
Quoted 7 lines
register_pm_notifier(&exynos_cpufreq_nb); if (cpufreq_register_driver(&exynos_driver)) {--
1.7.10.4
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
Quoted 8 lines · Lukasz Majewski
On Tue, 16 Jul 2013 15:28:40 +0530 Viresh Kumar [email protected] wrote,
Quoted 6 lines · Lukasz Majewski
Quoted 4 lines
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)"
Quoted 10 lines
Quoted 1 line
Name it "CPU Frequency Overclocking - Software"
Thanks, I had a puzzle to came up with a good short name :-).
Quoted 2 lines
Quoted 2 lines
+ depends on
ARM_EXYNOS_CPUFREQ&&EXYNOS_THERMAL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Remote Exynos from here. If you want to enable it for your platform by default, then select it from EXYNOS.
I misread it a bit. I wanted to say make it dependent only on THERMAL and not on Exynos.
Quoted 2 lines
The purpose of the condition [*] here is to prevent from enabling boost when thermal for Exynos is not supported.
Why? Can't others use it? Its not exynos specific :)
Re: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
On Wed, 17 Jul 2013 10:54:55 +0530 Viresh Kumar [email protected] wrote,
Quoted 12 lines · Lukasz Majewski
Quoted 11 lines
On Tue, 16 Jul 2013 15:28:40 +0530 Viresh Kumar
[email protected] wrote,Quoted 8 lines
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 4 lines · Lukasz Majewski
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)"Name it "CPU Frequency Overclocking - Software"
Quoted 8 lines
Quoted 8 lines
Thanks, I had a puzzle to came up with a good short name :-).
Quoted 2 lines
Quoted 2 lines
+ depends on
ARM_EXYNOS_CPUFREQ&&EXYNOS_THERMAL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Remote Exynos from here. If you want to enable it for your platform by default, then select it from EXYNOS.
I can change ARM_EXYNOS_CPUFREQ -> CPUFREQ at [*]
Quoted 3 lines
I misread it a bit. I wanted to say make it dependent only on THERMAL and not on Exynos.
The cpufreq boost feature is possible to be enabled only when those [*] dependencies are met. Moreover, it is disabled by default.
This means that not only THERMAL generic code must be supported, but also EXYNOS specific one - like per SoC trip points [**].
With thermal it is possible (and correct) to only define THERMAL, with no platform (in this case Exynos) specific definitions. To force potential user to define [**], I think, that EXYNOS_THERMAL is required.
Quoted 5 lines
Quoted 3 lines
The purpose of the condition [*] here is to prevent from enabling boost when thermal for Exynos is not supported.
Why? Can't others use it? Its not exynos specific :)
No it is not exynos specific.
For other platform one need to define:
depends on CPUFREQ && (EXYNOS_THERMAL || <PLATFORM_SUPPORTED>_THERMAL)
Such condition improves my confidence about proper boost usage.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
Quoted 17 lines · Lukasz Majewski
On Wed, 17 Jul 2013 10:54:55 +0530 Viresh Kumar [email protected] wrote,
Quoted 15 lines · Lukasz Majewski
Quoted 14 lines
On Tue, 16 Jul 2013 15:28:40 +0530 Viresh Kumar
[email protected] wrote,Quoted 8 lines
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 4 lines · Lukasz Majewski
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)"Name it "CPU Frequency Overclocking - Software"
Thanks, I had a puzzle to came up with a good short name :-).
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
+ depends on
ARM_EXYNOS_CPUFREQ&&EXYNOS_THERMAL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Remote Exynos from here. If you want to enable it for your platform by default, then select it from EXYNOS.
I can change
ARM_EXYNOS_CPUFREQ-> CPUFREQ at [*]
We are in cpufreq Kconfig and so dependency is automatically there on cpufreq.
Quoted 18 lines
Quoted 3 lines
I misread it a bit. I wanted to say make it dependent only on THERMAL and not on Exynos.
The cpufreq boost feature is possible to be enabled only when those [*] dependencies are met. Moreover, it is disabled by default.
This means that not only THERMAL generic code must be supported, but also EXYNOS specific one - like per SoC trip points [**].
With thermal it is possible (and correct) to only define THERMAL, with no platform (in this case Exynos) specific definitions. To force potential user to define [**], I think, that
EXYNOS_THERMALis required.Quoted 4 lines
Quoted 3 lines
The purpose of the condition [*] here is to prevent from enabling boost when thermal for Exynos is not supported.
Quoted 6 lines
Quoted 1 line
Why? Can't others use it? Its not exynos specific :)
No it is not exynos specific.
For other platform one need to define:depends on CPUFREQ && (
EXYNOS_THERMAL|| <PLATFORM_SUPPORTED>_THERMAL)
Exactly. I don't want this kind of mess to be present here.
People selecting this feature must know what it does and dependency on a coolant is enough.
For other drivers, selecting this doesn't matter as they don't support boost.
Re: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
On Wed, 17 Jul 2013 13:22:20 +0530 Viresh Kumar [email protected] wrote,
Quoted 22 lines · Lukasz Majewski
Quoted 21 lines
On Wed, 17 Jul 2013 10:54:55 +0530 Viresh Kumar
[email protected] wrote,Quoted 19 lines
Quoted 17 lines · Lukasz Majewski
On Tue, 16 Jul 2013 15:28:40 +0530 Viresh Kumar
[email protected] wrote,Quoted 8 lines
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 4 lines · Lukasz Majewski
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool "CPU frequency overclocking (BOOST)"Name it "CPU Frequency Overclocking - Software"
Thanks, I had a puzzle to came up with a good short name :-).
Quoted 2 lines
Quoted 2 lines
+ depends on
ARM_EXYNOS_CPUFREQ&&EXYNOS_THERMAL^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Remote Exynos from here. If you want to enable it for your platform by default, then select it from EXYNOS.
I can change
ARM_EXYNOS_CPUFREQ-> CPUFREQ at [*]We are in cpufreq
Kconfigand so dependency is automatically there on cpufreq.
So then, it can be removed.
Quoted 28 lines
Quoted 20 lines
Quoted 4 lines
I misread it a bit. I wanted to say make it dependent only on THERMAL and not on Exynos.
The cpufreq boost feature is possible to be enabled only when those [*] dependencies are met. Moreover, it is disabled by default.
This means that not only THERMAL generic code must be supported, but also EXYNOS specific one - like per SoC trip points [**].
With thermal it is possible (and correct) to only define THERMAL, with no platform (in this case Exynos) specific definitions. To force potential user to define [**], I think, that
EXYNOS_THERMALis required.Quoted 4 lines
Quoted 3 lines
The purpose of the condition [*] here is to prevent from enabling boost when thermal for Exynos is not supported.
Quoted 7 lines
Quoted 1 line
Why? Can't others use it? Its not exynos specific :)
No it is not exynos specific.
For other platform one need to define:depends on CPUFREQ && (
EXYNOS_THERMAL||
<PLATFORM_SUPPORTED>_THERMAL)
Quoted 7 lines
Exactly. I don't want this kind of mess to be present here.
People selecting this feature must know what it does and dependency on a coolant is enough.
For other drivers, selecting this doesn't matter as they don't support boost.
Then it should be enough to only write:
depends on THERMAL
(since CPUFREQ is already enabled for entering this menu).
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
Quoted 5 lines · Lukasz Majewski
Then it should be enough to only write:
depends on THERMAL
(since CPUFREQ is already enabled for entering this menu).
Correct
Re: [PATCH v5 6/7] cpufreq:boost:Kconfig: Enable software managed BOOST support at Kconfig
On Wed, 17 Jul 2013 10:29:15 +0200 Viresh Kumar [email protected] wrote,
Quoted 8 lines · Lukasz Majewski
Quoted 5 lines
Then it should be enough to only write:
depends on THERMAL
(since CPUFREQ is already enabled for entering this menu).
Correct
OK.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v5 7/7 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v5 7/7] Documentation:cpufreq:boost: Update BOOST documentation
Documentation/cpu-freq/boost.txt be desirable: · line 57
Quoted 7 lines · Lukasz Majewski
Documentation/cpu-freq/boost.txt +3
-4-Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL.
For acpi-cpufreq reading the file should be always supported. And this must be mentioned in doc.
Re: [PATCH v5 7/7] Documentation:cpufreq:boost: Update BOOST documentation
On Tue, 16 Jul 2013 15:31:43 +0530 Viresh Kumar [email protected] wrote,
Quoted 11 lines · Lukasz Majewski
Quoted 7 lines
-Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL.
(quoted diff) +2
-0+The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that fileanyway will +return EINVAL.
For acpi-cpufreq reading the file should be always supported. And this must be mentioned in doc.
As fair as I've understood our previous discussion (at [*]) we have agreed about this. We only export boost attribute when it is supported by cpufreq_driver. Rafael was very clear about exporting boost attribute:
"Simple: Export it only when supported."
[*]: Re: [PATCH v4 2/7] cpufreq: Add boost frequency support in core
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v5 7/7] Documentation:cpufreq:boost: Update BOOST documentation
Quoted 8 lines · Lukasz Majewski
As fair as I've understood our previous discussion (at [*]) we have agreed about this. We only export boost attribute when it is supported by
cpufreq_driver. Rafael was very clear about exporting boost attribute:"Simple: Export it only when supported."
[*]: Re: [PATCH v4 2/7] cpufreq: Add boost frequency support in core
I don't want to search in the Archives but I am sure what we decided earlier.
Rafael Said:
"Simple: Export it only when supported."
AND
"Don't change behavior of acpi-cpufreq driver"
If you see acpi-cpufreq driver carefully, it always creates "boost" sysfs entry. If its not supported then it creates a read only entry.
So, please preserve that.
Re: [PATCH v5 7/7] Documentation:cpufreq:boost: Update BOOST documentation
On Wed, 17 Jul 2013 10:52:18 +0530 Viresh Kumar [email protected] wrote,
Quoted 6 lines · Lukasz Majewski
Quoted 5 lines
As fair as I've understood our previous discussion (at [*]) we have agreed about this. We only export boost attribute when it is supported by
cpufreq_driver. Rafael was very clear about exporting boost attribute:
Quoted 6 lines
Quoted 3 lines
"Simple: Export it only when supported."
[*]: Re: [PATCH v4 2/7] cpufreq: Add boost frequency support in core
I don't want to search in the Archives but I am sure what we decided earlier.
At v4 there was the old acpi-cpufreq.c behaviour preserved (with always exporting boost - when not supported ro, when supported rw).
Due to Rafael and Dirk comments it has been rewritten at v5:
Quoted 3 lines
Rafael Said:
"Simple: Export it only when supported."
[*]
Quoted 4 lines
AND
"Don't change behavior of acpi-cpufreq driver"
[**]
Quoted 3 lines
If you see acpi-cpufreq driver carefully, it always creates "boost" sysfs entry. If its not supported then it creates a read only entry.
For me those two statements [*] and [**] contradict:
At v5:
1. ARM - export "boost" only when supported (rw)
2. x86 - export boost only when x86 supports it (as rw). When x86 doesn't support HW boost - DO NOT export it at all.
At v4:
1. ARM - export "boost" only when supported (rw)
2. x86 - always export boost - no matter if supported or not. If not supported, then export it as ro only.
Quoted 2 lines
So, please preserve that.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v5 7/7] Documentation:cpufreq:boost: Update BOOST documentation
Quoted 29 lines · Lukasz Majewski
At v4 there was the old
acpi-cpufreq.cbehaviour preserved (with always exporting boost - when not supported ro, when supported rw).Due to Rafael and Dirk comments it has been rewritten at v5:
Quoted 3 lines
Rafael Said:
"Simple: Export it only when supported."[*]Quoted 4 lines
AND
"Don't change behavior of acpi-cpufreq driver"
[**]Quoted 3 lines
If you see acpi-cpufreq driver carefully, it always creates "boost" sysfs entry. If its not supported then it creates a read only entry.
For me those two statements [*] and [**] contradict:
At v5:
1. ARM - export "boost" only when supported (rw)
2. x86 - export boost only when x86 supports it (as rw). When x86 doesn't support HW boost - DO NOT export it at all.
Quoted 4 lines
At v4:
1. ARM - export "boost" only when supported (rw)
2. x86 - always export boost - no matter if supported or not. If not supported, then export it as ro only.
Okay, there is some confusion..
I have raised a query on your v4 mail.. lets see what people have to say.
Re: [PATCH v5 7/7] Documentation:cpufreq:boost: Update BOOST documentation
On Wed, 17 Jul 2013 13:29:26 +0530 Viresh Kumar [email protected] wrote,
Quoted 36 lines · Lukasz Majewski
Quoted 30 lines
At v4 there was the old
acpi-cpufreq.cbehaviour preserved (with always exporting boost - when not supported ro, when supported rw).Due to Rafael and Dirk comments it has been rewritten at v5:
Quoted 3 lines
Rafael Said:
"Simple: Export it only when supported."[*]Quoted 4 lines
AND
"Don't change behavior of acpi-cpufreq driver"
[**]Quoted 4 lines
If you see acpi-cpufreq driver carefully, it always creates "boost" sysfs entry. If its not supported then it creates a read only entry.
For me those two statements [*] and [**] contradict:
At v5:
1. ARM - export "boost" only when supported (rw)
2. x86 - export boost only when x86 supports it (as rw). When x86 doesn't support HW boost - DO NOT export it at all.Quoted 4 lines
At v4:
1. ARM - export "boost" only when supported (rw)
2. x86 - always export boost - no matter if supported or not. If not supported, then export it as ro only.
Quoted 4 lines
Okay, there is some confusion..
I have raised a query on your v4 mail.. lets see what people have to say.
Ok.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
On Thu, 04 Jul 2013 10:50:23 +0200, Lukasz Majewski wrote:
Dear Viresh, Rafael
Do you have any comments/feedback for me regarding those patches?
Quoted 87 lines
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos). For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The
cpufreq_driveris responsibile for settingboost_supportedflag and providingenable_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selectable only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related fields:
--boost_supported- when driver supports boosting --enable_boost- callback to function, which is necessary to
enable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- All available policies are now stored in a list.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring of target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
New patches for v5:
cpufreq:boost:Kconfig: Enable software managed BOOST support atKconfigDocumentation:cpufreq:boost: Update BOOST documentationPatches dropped at v5:
cpufreq: Calculate number of busy CPUs
cpufreq: Enable software boost only when up to one busy core is runningTested at: HW:
Exynos 4412 3.10 linux Exynos 4210 3.10 linuxCompile tested
x86_64defconfig (acpi) - help with HW (Intel Nehalem) test neededThe code has been rebased on top of kernel_pm/bleeding-edge (3.11-rc1)
Lukasz Majewski (7):
cpufreq: Store cpufreq policies in a list
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust theacpi-cpufreq.ccode to work with common
boost solution
cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Enable software managed BOOST support at
Kconfig
Documentation:cpufreq:boost: Update BOOST documentationDocumentation/cpu-freq/boost.txt | 26 ++++----- drivers/cpufreq/Kconfig | 14 +++++ drivers/cpufreq/acpi-cpufreq.c | 69 +++++++---------------- drivers/cpufreq/cpufreq.c | 115 ++++++++++++++++++++++++++++++++++++++ drivers/cpufreq/exynos-cpufreq.c | 9 ++- drivers/cpufreq/freq_table.c | 47 +++++++++++++--- drivers/thermal/thermal_core.c | 31 ++++++++++ include/linux/cpufreq.h | 13 +++++ include/linux/thermal.h | 2 + 9 files changed, 257insertions(+), 69 deletions(-)
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerQuoted 5 lines · Lukasz Majewski
On Thu, 04 Jul 2013 10:50:23 +0200, Lukasz Majewski wrote:
Dear Viresh, Rafael
Do you have any comments/feedback for me regarding those patches?
I am busy in Linaro connect this week, but will see if I can get some time to go over these.
Dear Viresh, Rafael,
Quoted 6 lines · Lukasz Majewski
Dear Viresh, Rafael
Do you have any comments/feedback for me regarding those patches?
Will you find time to review version 5 of cpufreq boost patch series?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerQuoted 10 lines · Lukasz Majewski
Dear Viresh, Rafael,
Quoted 6 lines · Lukasz Majewski
Dear Viresh, Rafael
Do you have any comments/feedback for me regarding those patches?
Will you find time to review version 5 of cpufreq boost patch series?
This is a request or an order ?? :)
Yes, I have still kept these mails in my todo list.. Don't worry they wouldn't be missed.
Hi Viresh,
Quoted 7 lines · Lukasz Majewski
Quoted 6 lines
Dear Viresh, Rafael,
Quoted 4 lines · Lukasz Majewski
Dear Viresh, Rafael
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Do you have any comments/feedback for me regarding those patches?
Will you find time to review version 5 of cpufreq boost patch series?
This is a request or an order ?? :)
It was a very polite order :-)
Quoted 3 lines
Yes, I have still kept these mails in my todo list.. Don't worry they wouldn't be missed.
OK
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
v6 cover cpufreq:boost: CPU Boost mode support
In reply to Lukasz MajewskiThis patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreq
Boost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The cpufreq_driver is responsibile for setting boost_supported flag and providing set_boost callback(if HW support is needed). For software managed boost, special Kconfig flag - CONFIG_CPU_FREQ_BOOST_SW has been defined. It will be selected only when a target platform has thermal framework properly configured.
- struct cpufreq_driver has been extended with boost related fields:
-- boost_supported - when driver supports boosting -- boost_enabled - boost state
-- set_boost - callback to function, which is necessary to
enable/disable boost
- Boost sysfs attribute (/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.
- No special spin_lock for Boost was created. The one from cpufreq core was reused.
- All available policies are now stored in a list.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
New patches for v6:
cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Tested at HW:
Exynos 4412 3.11-rc1 Linux
Intel Core i7-3770 3.11-rc1 LinuxLukasz Majewski (8):
cpufreq: Store cpufreq policies in a list
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common
boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Documentation/cpu-freq/boost.txt | 26 +++---- drivers/cpufreq/Kconfig | 3 + drivers/cpufreq/Kconfig.arm | 16 +++++ drivers/cpufreq/acpi-cpufreq.c | 87 ++++++++---------------- drivers/cpufreq/cpufreq.c | 124 +++++++++++++++++++++++++++++++++- drivers/cpufreq/exynos-cpufreq.c | 6 ++ drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- drivers/cpufreq/freq_table.c | 53 +++++++++++++-- drivers/thermal/thermal_core.c | 55 +++++++++++++++ include/linux/cpufreq.h | 26 +++++++ include/linux/thermal.h | 2 + 11 files changed, 321 insertions(+), 79 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v6 1/8 cpufreq: Store cpufreq policies in a list
Policies available in a cpufreq framework are now linked together. They are accessible via cpufreq_policy_list defined at cpufreq core.
---
Changes for v6:
- Move policy list entry delete code to __cpufreq_remove_dev()
- Protect operations on cpufreq_policy_list elements with lock
Changes for v5:
- Call list_add() only when device successfully added
Changes for v4:
- New patch
drivers/cpufreq/cpufreq.c | 9 +++++++++ include/linux/cpufreq.h | 1 + 2 files changed, 10 insertions(+)
drivers/cpufreq/cpufreq.c +9 -0
@@ -46,6 +46,7 @@ static struct cpufreq_driver *cpufreq_driver; static DEFINE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_data);static DEFINE_RWLOCK (cpufreq_driver_lock);static DEFINE_MUTEX (cpufreq_governor_lock); +static LIST_HEAD (cpufreq_policy_list);#ifdef CONFIG_HOTPLUG_CPU /* This one keeps track of the previously set governor of a removed CPU */
@@ -1054,6 +1055,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)if (ret) goto err_out_unregister; +write_lock_irqsave (&cpufreq_driver_lock, flags); +list_add (&policy->policy_list, &cpufreq_policy_list); +write_unlock_irqrestore (&cpufreq_driver_lock, flags); +kobject_uevent (&policy->kobj,KOBJ_ADD );module_put (cpufreq_driver->owner);pr_debug ("initialization complete\n" );
@@ -1202,6 +1207,10 @@ static int __cpufreq_remove_dev(struct device *dev,if (cpufreq_driver->exit) cpufreq_driver->exit (data); +write_lock_irqsave (&cpufreq_driver_lock, flags); +list_del (&data->policy_list); +write_unlock_irqrestore (&cpufreq_driver_lock, flags); +free_cpumask_var (data->related_cpus);free_cpumask_var (data->cpus);kfree (data);
include/linux/cpufreq.h +1 -0
@@ -117,6 +117,7 @@ struct cpufreq_policy {struct cpufreq_real_policy user_policy; +struct list_head policy_list;struct kobject kobj;struct completion kobj_unregister;int transition_ongoing;/* Tracks transition status */
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v6 1/8] cpufreq: Store cpufreq policies in a list
Quoted 5 lines · Lukasz Majewski
Policies available in a cpufreq framework are now linked together. They are accessible via
cpufreq_policy_listdefined at cpufreq core.Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>
Looks good but would have been better if you could have moved existing code to use this infrastructure..
For example, this code in __cpufreq_add_dev()
#ifdef CONFIG_HOTPLUG_CPU
/* Check if this cpu was hot-unplugged earlier and has siblings */
read_lock_irqsave(&cpufreq_driver_lock, flags);
for_each_online_cpu(sibling) {
---
}
read_unlock_irqrestore(&cpufreq_driver_lock, flags);#endif
Re: [PATCH v6 1/8] cpufreq: Store cpufreq policies in a list
On Fri, 26 Jul 2013 15:44:29 +0530 Viresh Kumar [email protected] wrote,
Quoted 21 lines · Lukasz Majewski
Quoted 5 lines
Policies available in a cpufreq framework are now linked together. They are accessible via
cpufreq_policy_listdefined at cpufreq core.Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>Looks good but would have been better if you could have moved existing code to use this infrastructure..
For example, this code in
__cpufreq_add_dev()#ifdef CONFIG_HOTPLUG_CPU /* Check if this cpu was hot-unplugged earlier and has siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags); for_each_online_cpu(sibling) { --- } read_unlock_irqrestore(&cpufreq_driver_lock, flags);
Quoted 1 line
#endif
Do you mean to write something like:
#ifdef CONFIG_CPU_FREQ_BOOST_SW write_lock_irqsave(&cpufreq_driver_lock, flags); list_add(&policy->policy_list, &cpufreq_policy_list); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif
Or Am I missing something?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 1/8] cpufreq: Store cpufreq policies in a list
Quoted 22 lines · Lukasz Majewski
On Fri, 26 Jul 2013 15:44:29 +0530 Viresh Kumar [email protected] wrote,
Quoted 16 lines · Lukasz Majewski
Looks good but would have been better if you could have moved existing code to use this infrastructure..
For example, this code in
__cpufreq_add_dev()#ifdef CONFIG_HOTPLUG_CPU /* Check if this cpu was hot-unplugged earlier and has siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags); for_each_online_cpu(sibling) { --- } read_unlock_irqrestore(&cpufreq_driver_lock, flags);Quoted 1 line
#endif
Do you mean to write something like:
Quoted 7 lines
#ifdef CONFIG_CPU_FREQ_BOOST_SW write_lock_irqsave(&cpufreq_driver_lock, flags); list_add(&policy->policy_list, &cpufreq_policy_list); write_unlock_irqrestore(&cpufreq_driver_lock, flags);#endif
Or Am I missing something?
I can't imaging how you though I am saying this :)
The code I mentioned actually requires to iterate through the list of available policies but was iterating over all online cpus..
And so your new infrastructure or this list can be used instead of looping for all cpus.
Re: [PATCH v6 1/8] cpufreq: Store cpufreq policies in a list
On Fri, 26 Jul 2013 16:32:34 +0530 Viresh Kumar [email protected] wrote,
Quoted 30 lines · Lukasz Majewski
Quoted 29 lines
On Fri, 26 Jul 2013 15:44:29 +0530 Viresh Kumar
[email protected] wrote,Quoted 17 lines
On 25 July 2013 22:03, Lukasz Majewski <[email protected]> wrote:
Looks good but would have been better if you could have moved existing code to use this infrastructure..
For example, this code in
__cpufreq_add_dev()#ifdef CONFIG_HOTPLUG_CPU /* Check if this cpu was hot-unplugged earlier and has siblings */ read_lock_irqsave(&cpufreq_driver_lock, flags); for_each_online_cpu(sibling) { --- } read_unlock_irqrestore(&cpufreq_driver_lock, flags);Quoted 1 line
#endif
Do you mean to write something like:
#ifdef CONFIG_CPU_FREQ_BOOST_SW write_lock_irqsave(&cpufreq_driver_lock, flags); list_add(&policy->policy_list, &cpufreq_policy_list); write_unlock_irqrestore(&cpufreq_driver_lock, flags);#endif
Quoted 4 lines
Quoted 1 line
Or Am I missing something?
I can't imaging how you though I am saying this :)
:-)
Quoted 5 lines
The code I mentioned actually requires to iterate through the list of available policies but was iterating over all online cpus..
And so your new infrastructure or this list can be used instead of looping for all cpus.
So instead of reading policies from per_cpu variables for all online cpus, you think of using the list explicitly.
Good idea, but can we first finish the boost patches? Such change can be applied on top of boost patch series as well.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 1/8] cpufreq: Store cpufreq policies in a list
Quoted 5 lines · Lukasz Majewski
So instead of reading policies from
per_cpuvariables for all online cpus, you think of using the list explicitly.Good idea, but can we first finish the boost patches? Such change can be applied on top of boost patch series as well.
Its not a problem where we do it. But making sure that we do it :) If you need to resend this patchset, then that list can be used at the place I just highlighted.. Change isn't big and so shouldn't be a problem.
Otherwise it might get missed by both of us.
PATCH v6 2/8 cpufreq: Add boost frequency support in core
In reply to Lukasz MajewskiThis commit adds boost frequency support in cpufreq core (Hardware & Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency above its normal operation limits. Such mode shall be only used for a short time.
Overclocking (boost) support is essentially provided by platform dependent cpufreq driver.
This commit unifies support for SW and HW (Intel) overclocking solutions in the core cpufreq driver. Previously the "boost" sysfs attribute was defined at acpi driver code. By default boost is disabled. One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.
It only shows up when cpufreq driver supports overclocking. Under the hood frequencies dedicated for boosting are marked with a special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table. It is the user's concern to enable/disable overclocking with a proper call to sysfs.
The cpufreq_boost_trigger_state() function is defined non static on purpose. It is used later with thermal subsystem to provide automatic enable/disable of the BOOST feature.
---
Changes for v6:
- Remove sysfs boost attribute when subsys_iterface_unregister() fails
- Move global boost_enabled variable from cpufreq.c to platform dependent struct cpufreq_driver
- pr_err() message is also printed when boost disable fails
- Call __cpufreq_governor() to force recalculation of next frequency when boost is triggered. It is needed with i.e. performance class of governors
- Change cpufreq_boost_enable_sw() -> cpufreq_boost_set_sw()
- Rename .enable_boost function pointer to .set_boost
Changes for v5:
- Rename cpufreq_boost_trigger_state_sw() to cpufreq_boost_enable_sw()
- Extent cpufreq_register_driver() to check if cpufreq driver provided boost_enable callback. If not provided, then use cpufreq_boost_enable_sw()
- Use single call to cpufreq_driver->enable_boost() with cpufreq driver provided callback or default SW boost enable routine
- Move pr_debug call to store_boost() from cpufreq_boost_trigger_state()
- Change the user_policy.max value when SW boost is toggled. It is necessary for proper operation of e.g. thermal subsystem.
- Add check if cpufreq_driver pointer is not NULL at cpufreq_boost_supported() routine
- Add EXPORT_SYMBOL_GPL for cpufreq_boost_supported() and cpufreq_boost_enabled()
- Remove extra check for cpufreq_boost_supported() at cpufreq_freq_table_cpuinfo()
- Explanation of show boost logic at show_available_freqs()
- Add cpufreq_set_boost_enabled() method to set initial value of boost_enabled global flag
Changes for v4:
- Remove boost parameter from cpufreq_frequency_table_cpuinfo() function
- Introduce cpufreq_boost_supported() method
- Use of cpufreq_boost_supported() and cpufreq_boost_enabled() to decide if frequency shall be skipped
- Rename set_boost_freq() to enable_boost()
- cpufreq_attr_available_freq() moved to freq_table.c
- Use policy list to get access to cpufreq policies
- Rename global boost flag (cpufreq_boost_enabled -> boost_enabled)
- pr_err corrected ( %sable)
- Remove sanity check at cpufreq_boost_trigger_state() entrance [to test if boost is supported]
- Use either HW (boost_enable) callback or SW managed boost
- Introduce new cpufreq_boost_trigger_state_sw() method to handle boost at SW.
- Protect boost_enabled manipulation with lock.
Changes for v3:
- Method for reading boost status
- Removal of cpufreq_frequency_table_max()
- Extent cpufreq_frequency_table_cpuinfo() to support boost parameter
- boost_supported flag added to cpufreq_driver struct
- "boost" sysfs attribute control flag removed
- One global flag describing state of the boost defined at cpufreq core
- Rename cpufreq_driver's low_level_boost field to set_boost_freq()
- Usage of cpufreq_sysfs_{remove|add}_file() routines
Changes for v2:
- Removal of cpufreq_boost structure and move its fields to cpufreq_driver structure
- Flag to indicate if global boost attribute is already defined
- Extent the pr_{err|debbug} functions to show current function names
drivers/cpufreq/cpufreq.c | 115 +++++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/freq_table.c | 53 ++++++++++++++++--- include/linux/cpufreq.h | 10 ++++ 3 files changed, 170 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +114 -1
@@ -377,6 +377,33 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);/********************************************************************* * SYSFS INTERFACE * *********************************************************************/ +ssize_t show_boost (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" , cpufreq_driver->boost_enabled); +} + +static ssize_t store_boost (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t count) +{ +int ret, enable; + + ret =sscanf (buf,"%d" , &enable); +if (ret !=1 || enable <0 || enable >1 ) +return -EINVAL ; + +if (cpufreq_boost_trigger_state (enable)) { +pr_err ("%s: Cannot %s BOOST!\n" , __func__, + enable ?"enable" :"disable" ); +return -EINVAL ; + } + +pr_debug ("%s: cpufreq BOOST %s\n" , __func__, + enable ?"enabled" :"disabled" ); + +return count; +} +define_one_global_rw (boost);static struct cpufreq_governor *__find_governor (const char *str_governor) {
@@ -1970,6 +1997,70 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { };/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (!ret) { + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled =0 ; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: BOOST cannot %s\n" , __func__, + state ?"enabled" :"disabled" ); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (cpufreq_driver) +return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
@@ -2008,9 +2099,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if boost driver provides function to enable boost - +* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&(boost.attr)); +if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
@@ -2037,6 +2144,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&(boost.attr)); err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;
@@ -2063,6 +2173,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&(boost.attr)); +unregister_hotcpu_notifier (&cpufreq_cpu_notifier);write_lock_irqsave (&cpufreq_driver_lock, flags);
drivers/cpufreq/freq_table.c +46 -7
79 lines not on this page · raw message
include/linux/cpufreq.h +10 -0
@@ -267,6 +267,11 @@ struct cpufreq_driver {int (*suspend) (struct cpufreq_policy *policy);int (*resume) (struct cpufreq_policy *policy);struct freq_attr **attr; + +/* platform specific boost support code */ +bool boost_supported; +bool boost_enabled; +int (*set_boost) (int state); };/* flags */
@@ -410,6 +415,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;#define CPUFREQ_ENTRY_INVALID ~0#define CPUFREQ_TABLE_END ~1 +#define CPUFREQ_BOOST_FREQ ~2struct cpufreq_frequency_table {unsigned int driver_data;/* driver specific data, not used by core */
@@ -429,11 +435,15 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,unsigned int relation, unsigned int *index); +int cpufreq_boost_trigger_state (int state); +int cpufreq_boost_supported (void ); +int cpufreq_boost_enabled (void );/* the following 3 funtions are for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);/* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; +extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;void cpufreq_frequency_table_get_attr (struct cpufreq_frequency_table *table,unsigned int cpu);
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
Quoted 27 lines · Lukasz Majewski
drivers/cpufreq/cpufreq.c +24
-0/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (!ret) { + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state)
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2033
Quoted 10 lines
drivers/cpufreq/cpufreq.c +10
-0+{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags);
Not sure if we should leave the lock at this point of time, as we haven't enabled boost until now.
If somebody tries to use this variable at this point of time, then it would get the wrong information about it.
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2038
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+ ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled =0 ;
should be:
cpufreq_driver->boost_enabled = !state;
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2041
Quoted 3 lines
drivers/cpufreq/cpufreq.c +3
-0+write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + pr_err("%s: BOOST cannot %s\n", __func__,
s/BOOST cannot %s/Cannot %s BOOST
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2050
Quoted 9 lines
drivers/cpufreq/cpufreq.c +9
-0+ state ? "enabled" : "disabled"); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (cpufreq_driver)
This routine is always called from places where cpufreq_driver can't be NULL..
--contd--
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2059
Quoted 9 lines
drivers/cpufreq/cpufreq.c +9
-0+return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled;
And if above check is necessary, then don't you need to check it here as well?
Quoted 8 lines
drivers/cpufreq/cpufreq.c +4
-0+} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
drivers/cpufreq/cpufreq.c int cpufreq_register_driver(struct cpufreq_driver *driver_data) · line 2104
Quoted 6 lines
drivers/cpufreq/cpufreq.c +3
-0@@ -2008,9 +2099,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if boost driver provides function to enable boost -
s/boost driver/driver
drivers/cpufreq/cpufreq.c int cpufreq_register_driver(struct cpufreq_driver *driver_data) · line 2110
Quoted 6 lines
drivers/cpufreq/cpufreq.c +6
-0+* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&(boost.attr));
You don't need braces around boost.attr.
Quoted 15 lines
drivers/cpufreq/cpufreq.c +8
-1+if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
drivers/cpufreq/cpufreq.c int cpufreq_register_driver(struct cpufreq_driver *driver_data) · line 2149
Quoted 6 lines
drivers/cpufreq/cpufreq.c +3
-0@@ -2037,6 +2144,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&(boost.attr));
same here.
drivers/cpufreq/cpufreq.c int cpufreq_unregister_driver(struct cpufreq_driver *driver) · line 2177
Quoted 9 lines
drivers/cpufreq/cpufreq.c +2
-0err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;@@ -2063,6 +2173,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&(boost.attr));
here too.
drivers/cpufreq/cpufreq.c int cpufreq_unregister_driver(struct cpufreq_driver *driver)
Quoted 9 lines
drivers/cpufreq/cpufreq.c +5
-0+unregister_hotcpu_notifier (&cpufreq_cpu_notifier);write_lock_irqsave (&cpufreq_driver_lock, flags); +static ssize_t scaling_available_frequencies_show (struct cpufreq_policy *policy, +char *buf) +{ +return show_available_freqs (policy, buf,0 );
s/0/false
drivers/cpufreq/cpufreq.c
Quoted 6 lines
drivers/cpufreq/cpufreq.c +5
-0+} +static ssize_t scaling_boost_frequencies_show (struct cpufreq_policy *policy, +char *buf) +{ +return show_available_freqs (policy, buf,1 );
s/1/true
Quoted 1 line
+}
Looks good mostly.. We Should be to get it in 3.12 :)
Re: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
On Fri, 26 Jul 2013 12:47:15 +0530 Viresh Kumar wrote,
Quoted 36 lines · Lukasz Majewski
Quoted 35 lines
drivers/cpufreq/cpufreq.c +1
-0/********************************************************************* +* BOOST *
+ *********************************************************************/drivers/cpufreq/cpufreq.c +6
-0+static int cpufreq_boost_set_sw(int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + + list_for_each_entry(policy, &cpufreq_policy_list,
policy_list) {
+freq_table=cpufreq_frequency_get_table(policy->cpu);drivers/cpufreq/cpufreq.c +2
-0+if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo(policy,
drivers/cpufreq/cpufreq.c +3
-0+ freq_table); +if (!ret) { + policy->user_policy.max =
policy->max;
+ __cpufreq_governor(policy,CPUFREQ_GOV_LIMITS);drivers/cpufreq/cpufreq.c +10
-0+ } + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags;
Quoted 8 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2033
Quoted 8 lines
drivers/cpufreq/cpufreq.c +8
-0+int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags);
^^^^^^^^^^^^^^^^^^^^ [*]
Quoted 3 lines
Not sure if we should leave the lock at this point of time, as we haven't enabled boost until now.
The problem here is with the cpufreq_driver->set_boost() call.
I tried to avoid acquiring lock at one function and release it at another (in this case cpufreq_boost_set_sw), especially since the __cpufreq_governor() acquires its own lock - good place for deadlock.
Is it OK for you to grab lock at one function (cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling __cpufreq_governor() and grab it again after its completion?
Quoted 11 lines
If somebody tries to use this variable at this point of time, then it would get the wrong information about it.
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2038
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+ ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled =0 ;should be:
cpufreq_driver->boost_enabled = !state;
For me = 0 (or = false) is more readable.
If you wish, I will change it to = !state.
Quoted 6 lines
Quoted 4 lines
+ write_unlock_irqrestore(&cpufreq_driver_lock,
flags); +
+ pr_err("%s: BOOST cannot %s\n",__func__,s/BOOST cannot %s/Cannot %s BOOST
Ok.
Quoted 13 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2050
Quoted 10 lines
drivers/cpufreq/cpufreq.c +9
-0+ state ? "enabled" : "disabled"); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (cpufreq_driver)This routine is always called from places where
cpufreq_drivercan't be NULL..
It is also called from thermal. And it happens that thermal is initialized earlier.
Then "NULL pointer dereference" happens.
Quoted 12 lines
--contd--
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2059
Quoted 9 lines
drivers/cpufreq/cpufreq.c +9
-0+return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled;
^^^^^^^^^^^^^^ [1]
Quoted 3 lines
And if above check is necessary, then don't you need to check it here as well?
Because on thermal I check first if cpufreq_boost_supported() is true. If boost is not supported then check for cpufreq_boost_enabled() is not performed.
In my opinion at [1] we don't need the if (cpufreq_driver) check. But it is up to you to decide.
Quoted 13 lines
Quoted 13 lines
drivers/cpufreq/cpufreq.c +4
-0+} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER *
*********************************************************************/drivers/cpufreq/cpufreq.c +0
-0@@ -2008,9 +2099,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags);
Quoted 6 lines
Quoted 4 lines
drivers/cpufreq/cpufreq.c +3
-0+if (cpufreq_boost_supported ()) { +/* +* Check if boost driver provides function to enable boost -
s/boost driver/driver
Ok.
Quoted 9 lines
Quoted 7 lines
drivers/cpufreq/cpufreq.c +4
-0+* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost =
cpufreq_boost_set_sw; +
+ ret = cpufreq_sysfs_create_file(&(boost.attr));You don't need braces around boost.attr.
Ok.
Quoted 14 lines
Quoted 14 lines
drivers/cpufreq/cpufreq.c +2
-0+if (ret) { + pr_err("%s: cannot register global BOOSTsysfs file\n",
drivers/cpufreq/cpufreq.c +6
-1+ __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;
Quoted 11 lines
drivers/cpufreq/cpufreq.c int cpufreq_register_driver(struct · line 2149
Quoted 9 lines
if (!(cpufreq_driver->flags & CPUFREQ_STICKY)) { int i;drivers/cpufreq/cpufreq.c +3
-0@@ -2037,6 +2144,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) return 0; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&(boost.attr));same here.
Ok.
Quoted 8 lines
Quoted 8 lines
drivers/cpufreq/cpufreq.c +0
-0err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;@@ -2063,6 +2173,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) pr_debug("unregistering driver %s\n", driver->name);
Quoted 5 lines
drivers/cpufreq/cpufreq.c int cpufreq_register_driver(struct cpufreq_driver *driver_data) · line 2149
Quoted 3 lines
drivers/cpufreq/cpufreq.c +2
-0subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&(boost.attr));here too.
Ok.
Quoted 6 lines
Quoted 5 lines
drivers/cpufreq/cpufreq.c +1
-0+unregister_hotcpu_notifier (&cpufreq_cpu_notifier);write_lock_irqsave(&cpufreq_driver_lock, flags);
Quoted 7 lines
drivers/cpufreq/cpufreq.c
Quoted 5 lines
+static
ssize_tscaling_available_frequencies_show(structcpufreq_policy*policy,drivers/cpufreq/cpufreq.c +3
-0+ char *buf) +{ +return show_available_freqs (policy, buf,0 );s/0/false
Ok.
Quoted 10 lines
drivers/cpufreq/cpufreq.c
Quoted 8 lines
drivers/cpufreq/cpufreq.c +2
-0+} +static ssize_t scaling_boost_frequencies_show(struct
cpufreq_policy*policy,drivers/cpufreq/cpufreq.c +3
-0+ char *buf) +{ +return show_available_freqs (policy, buf,1 );s/1/true
Ok.
Quoted 4 lines
Quoted 2 lines
+}
Looks good mostly.. We Should be to get it in 3.12 :)
If we agree about above comments, I will post v7 ASAP.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
Quoted 35 lines · Lukasz Majewski
On Fri, 26 Jul 2013 12:47:15 +0530 Viresh Kumar wrote,
Quoted 13 lines · Lukasz Majewski
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2033
Quoted 12 lines
drivers/cpufreq/cpufreq.c +11
-0+int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags);^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Not sure if we should leave the lock at this point of time, as we haven't enabled boost until now.
The problem here is with the
cpufreq_driver->set_boost()call.I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?Quoted 5 lines
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+ ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled =0 ;
Quoted 5 lines
Quoted 2 lines
should be:
cpufreq_driver->boost_enabled = !state;For me = 0 (or = false) is more readable.
If you wish, I will change it to = !state.
Its not about readability but logic... What if boost was enabled earlier and we are disabling it now.. and we reach here.. We need to enable boost again, whereas you are disabling it.
Quoted 10 lines
Quoted 6 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2050
Quoted 3 lines
drivers/cpufreq/cpufreq.c +3
-0+int cpufreq_boost_supported (void ) +{ +if (cpufreq_driver)This routine is always called from places where
cpufreq_drivercan't be NULL..It is also called from thermal. And it happens that thermal is initialized earlier.
Then "NULL pointer dereference" happens.
Ok.. Put a likely() around this check for cpufreq_driver..
Quoted 2 lines
In my opinion at [1] we don't need the if (
cpufreq_driver) check. But it is up to you to decide.
leave it as is.
Quoted 1 line
If we agree about above comments, I will post v7 ASAP.
Don't post it ASAP, wait for few more days for others to give comments.. And also I haven't finished reviewing it until now.
Re: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
On Fri, 26 Jul 2013 15:03:34 +0530 Viresh Kumar wrote,
Quoted 41 lines · Lukasz Majewski
Quoted 40 lines
On Fri, 26 Jul 2013 12:47:15 +0530 Viresh Kumar wrote,
Quoted 14 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2033
Quoted 11 lines · Lukasz Majewski
drivers/cpufreq/cpufreq.c +11
-0+int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags);^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Not sure if we should leave the lock at this point of time, as we haven't enabled boost until now.
The problem here is with the
cpufreq_driver->set_boost()call.I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?Quoted 7 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2038
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+ ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled =0 ;should be:
cpufreq_driver->boost_enabled = !state;
Quoted 6 lines
Quoted 2 lines
For me = 0 (or = false) is more readable.
If you wish, I will change it to = !state.Its not about readability but logic... What if boost was enabled earlier and we are disabling it now.. and we reach here.. We need to enable boost again, whereas you are disabling it.
You are right here. I will change this to = !state
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2050
Quoted 4 lines
drivers/cpufreq/cpufreq.c +3
-0+int cpufreq_boost_supported (void ) +{ +if (cpufreq_driver)This routine is always called from places where
cpufreq_drivercan't be NULL..
Quoted 5 lines
Quoted 3 lines
It is also called from thermal. And it happens that thermal is initialized earlier.
Then "NULL pointer dereference" happens.Ok.. Put a
likely()around this check forcpufreq_driver..
Ok.
Quoted 5 lines
Quoted 3 lines
In my opinion at [1] we don't need the if (
cpufreq_driver) check. But it is up to you to decide.leave it as is.
Ok.
Quoted 6 lines
Quoted 2 lines
If we agree about above comments, I will post v7 ASAP.
Don't post it ASAP, wait for few more days for others to give comments.. And also I haven't finished reviewing it until now.
Ok.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
In reply to Lukasz MajewskiQuoted 10 lines · Lukasz Majewski
The problem here is with the
cpufreq_driver->set_boost()call.I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?
Problem is not only that.. but we shouldn't call boost_set() of drivers like acpi-cpufreq with this lock..... Leave it as it is for now.. Let me see if I can think of any problems that can happen due to this.
Re: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
On Fri, 26 Jul 2013 15:06:45 +0530 Viresh Kumar wrote,
Quoted 13 lines · Lukasz Majewski
Quoted 11 lines
The problem here is with the
cpufreq_driver->set_boost()call.I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?
Quoted 4 lines
Problem is not only that.. but we shouldn't call
boost_set()of drivers like acpi-cpufreq with this lock..... Leave it as it is for now.. Let me see if I can think of any problems that can happen due to this.
Ok. No problem.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
In reply to Viresh KumarOn Fri, 26 Jul 2013 15:06:45 +0530 Viresh Kumar [email protected] wrote,
Quoted 13 lines · Lukasz Majewski
Quoted 11 lines
The problem here is with the
cpufreq_driver->set_boost()call.I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?
Quoted 4 lines
Problem is not only that.. but we shouldn't call
boost_set()of drivers like acpi-cpufreq with this lock..... Leave it as it is for now.. Let me see if I can think of any problems that can happen due to this.
Do you have any second thoughts about this? Shall I leave it as it is now?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
Quoted 2 lines · Lukasz Majewski
Do you have any second thoughts about this? Shall I leave it as it is now?
Honestly speaking I didn't had a chance to look into this.. Leave it as is, in case there is some problem we can patch it later.
Re: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
In reply to Lukasz MajewskiQuoted 52 lines · Lukasz Majewski
On Fri, 26 Jul 2013 12:47:15 +0530 Viresh Kumar wrote,
Quoted 36 lines · Lukasz Majewski
Quoted 35 lines
drivers/cpufreq/cpufreq.c +1
-0/********************************************************************* +* BOOST *
+ *********************************************************************/drivers/cpufreq/cpufreq.c +6
-0+static int cpufreq_boost_set_sw(int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + + list_for_each_entry(policy, &cpufreq_policy_list,
policy_list) {
+freq_table=cpufreq_frequency_get_table(policy->cpu);drivers/cpufreq/cpufreq.c +2
-0+if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo(policy,
drivers/cpufreq/cpufreq.c +3
-0+ freq_table); +if (!ret) { + policy->user_policy.max =
policy->max;
+ __cpufreq_governor(policy,CPUFREQ_GOV_LIMITS);drivers/cpufreq/cpufreq.c +10
-0+ } + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags;Quoted 8 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2033
Quoted 8 lines
drivers/cpufreq/cpufreq.c +8
-0+int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags);^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Not sure if we should leave the lock at this point of time, as we haven't enabled boost until now.
The problem here is with the
cpufreq_driver->set_boost()call.
Quoted 8 lines
I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?
It generally is better to avoid doing that, although it is not unheard of.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v6 2/8] cpufreq: Add boost frequency support in core
On Fri, 26 Jul 2013 14:36:08 +0200 Rafael J. Wysocki [email protected] wrote,
Quoted 61 lines · Lukasz Majewski
Quoted 60 lines
On Fri, 26 Jul 2013 12:47:15 +0530 Viresh Kumar wrote,
Quoted 39 lines
Quoted 37 lines · Lukasz Majewski
drivers/cpufreq/cpufreq.c +1
-0/********************************************************************* +* BOOST *
+ *********************************************************************/drivers/cpufreq/cpufreq.c +6
-0+static int cpufreq_boost_set_sw(int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + + list_for_each_entry(policy, &cpufreq_policy_list,
policy_list) {
+freq_table=cpufreq_frequency_get_table(policy->cpu);drivers/cpufreq/cpufreq.c +2
-0+if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo(policy,
+freq_table);drivers/cpufreq/cpufreq.c +2
-0+if (!ret) { + policy->user_policy.max =
policy->max;
+ __cpufreq_governor(policy,CPUFREQ_GOV_LIMITS);drivers/cpufreq/cpufreq.c +10
-0+ } + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags;Quoted 8 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2033
Quoted 8 lines
drivers/cpufreq/cpufreq.c +8
-0+int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags);^^^^^^^^^^^^^^^^^^^^ [*]Quoted 3 lines
Not sure if we should leave the lock at this point of time, as we haven't enabled boost until now.
The problem here is with the
cpufreq_driver->set_boost()call.I tried to avoid acquiring lock at one function and release it at another (in this case
cpufreq_boost_set_sw), especially since the__cpufreq_governor()acquires its own lock - good place for deadlock.
Quoted 7 lines
Quoted 4 lines
Is it OK for you to grab lock at one function (
cpufreq_boost_trigger_state()) and then at other function (cpufreq_boost_set_sw) release it before calling__cpufreq_governor()and grab it again after its completion?It generally is better to avoid doing that, although it is not unheard of.
In this particular case, one also needs to pass the "flags" parameter to the set_boost() function. This looks a bit unnatural to mix lock layer with the boost.
Quoted 5 lines
Thanks,
Rafael
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v6 3/8 cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Lukasz MajewskiThe Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.
The _store_boost() function has been redesigned to be used as set_boost callback.
---
Changes for v6:
- Perform acpi_cpufreq_boost_init initialization before cpufreq_driver registration
- Compile store_boost() only when CONFIG_X86_ACPI_CPUFREQ_CPB defined
- Use boost_enabled flag defined at acpi_cpufreq_driver to store information about boost state
- Instead of using cpufreq_set_boost_enabled(), modify the boost_enable in the acpi driver code
Changes for v5:
- Remove acpi-cpufreq's boost_enabled global flag and reuse one defined at cpufreq core
Changes for v4:
- add _store_boost to acpi_cpufreq_driver structure
Changes for v3:
- Bring back boost_enabled as a global flag
- Move boost_supported to cpufreq_driver structure
Changes for v2:
- Replace boost_enabled and boost_supported global flags with proper entries at struct cpufreq_driver.
- Removal of struct cpufreq_boost
drivers/cpufreq/acpi-cpufreq.c | 87 ++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 57 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +30 -57
@@ -81,7 +81,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;static struct cpufreq_driver acpi_cpufreq_driver;static unsigned int acpi_pstate_strict; -static bool boost_enabled, boost_supported;static struct msr __percpu *msrs;static bool boost_state (unsigned int cpu)
@@ -134,49 +133,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static ssize_t _store_boost (const char *buf,size_t count) +static int _store_boost (int val) { -int ret; -unsigned long val =0 ; - -if (!boost_supported) -return -EINVAL ; - - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) -return -EINVAL ; - -if ((val && boost_enabled) || (!val && !boost_enabled)) -return count; -get_online_cpus (); -boost_set_msrs (val, cpu_online_mask); -put_online_cpus (); - - boost_enabled = val;pr_debug ("Core Boosting %sabled.\n" , val ?"en" :"dis" ); -return count; -} - -static ssize_t store_global_boost (struct kobject *kobj,struct attribute *attr, -const char *buf,size_t count) -{ -return _store_boost (buf, count); -} - -static ssize_t show_global_boost (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -return sprintf (buf,"%u\n" , boost_enabled); +return 0 ; } -static struct global_attr global_boost =__ATTR (boost,0644 , - show_global_boost, - store_global_boost); -static ssize_t show_freqdomain_cpus (struct cpufreq_policy *policy,char *buf) {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);
@@ -187,15 +153,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)cpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB +static ssize_t store_boost (const char *buf,size_t count) +{ +int ret; +unsigned long val =0 ; + +if (!acpi_cpufreq_driver.boost_supported) +return -EINVAL ; + + ret =kstrtoul (buf,10 , &val); +if (ret || (val >1 )) +return -EINVAL ; + +_store_boost ((int ) val); + +return count; +} +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -return _store_boost (buf, count); +return store_boost (buf, count); }static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) { -return sprintf (buf,"%u\n" , boost_enabled); +return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled); }static struct freq_attr cpb =__ATTR (cpb,0644 , show_cpb, store_cpb);
@@ -583,7 +566,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,switch (action) {case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN : -boost_set_msrs (boost_enabled, cpumask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, cpumask);break ;case CPU_DOWN_PREPARE :
@@ -943,43 +926,34 @@ static struct cpufreq_driver acpi_cpufreq_driver = { .name = "acpi-cpufreq", .owner = THIS_MODULE, .attr = acpi_cpufreq_attr, + .set_boost = _store_boost, };static void __init acpi_cpufreq_boost_init (void ) { + acpi_cpufreq_driver.boost_supported = false;if (boot_cpu_has (X86_FEATURE_CPB ) ||boot_cpu_has (X86_FEATURE_IDA )) { msrs =msrs_alloc ();if (!msrs)return ; - boost_supported = true; - boost_enabled =boost_state (0 ); - + acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.boost_enabled =boost_state (0 );get_online_cpus ();/* Force all MSRs to the same value */ -boost_set_msrs (boost_enabled, cpu_online_mask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, + cpu_online_mask);register_cpu_notifier (&boost_nb);put_online_cpus (); - }else - global_boost.attr.mode =0444 ; - -/* We create the boost file in any case, though for systems without -* hardware support it will be read-only and hardwired to return 0. -*/ -if (cpufreq_sysfs_create_file (&(global_boost.attr))) -pr_warn (PFX "could not register global boost sysfs file\n" ); -else -pr_debug ("registered global boost sysfs file\n" ); + } } static void __exit acpi_cpufreq_boost_exit(void) { -cpufreq_sysfs_remove_file (&(global_boost.attr)); -if (msrs) {unregister_cpu_notifier (&boost_nb);
@@ -1021,12 +995,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init (); ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret; }
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v6 3/8] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
drivers/cpufreq/acpi-cpufreq.c static struct cpufreq_driver acpi_cpufreq_driver = { · line 934
Quoted 5 lines · Lukasz Majewski
drivers/cpufreq/acpi-cpufreq.c +1
-0static void __init acpi_cpufreq_boost_init (void ) { + acpi_cpufreq_driver.boost_supported = false;
Would be better if we do this in else of below if.
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 998
Quoted 9 lines
if (boot_cpu_has(X86_FEATURE_CPB) || boot_cpu_has(X86_FEATURE_IDA)) { msrs = msrs_alloc();drivers/cpufreq/acpi-cpufreq.c +1
-0@@ -1021,12 +995,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init ();
We are calling it before registering cpufreq driver. Will this have any complications?
Quoted 7 lines
drivers/cpufreq/acpi-cpufreq.c +0
-2ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret;
Re: [PATCH v6 3/8] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
On Fri, 26 Jul 2013 12:58:02 +0530 Viresh Kumar wrote,
Quoted 7 lines · Lukasz Majewski
drivers/cpufreq/acpi-cpufreq.c static struct cpufreq_driver acpi_cpufreq_driver = { · line 934
Quoted 6 lines
drivers/cpufreq/acpi-cpufreq.c +1
-0static void __init acpi_cpufreq_boost_init (void ) { + acpi_cpufreq_driver.boost_supported = false;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]
Quoted 2 lines
Would be better if we do this in else of below if.
We need to set boost_supported = false at [*] for the case when:
1. msrs_alloc fails
or
2. acpi_cpufreq is built as a module and can be inserted and removed several times. Without [*] we could end up with wrong (not false) initial state.
Quoted 10 lines
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 998
Quoted 10 lines
if (boot_cpu_has(X86_FEATURE_CPB) ||
boot_cpu_has(X86_FEATURE_IDA)) { msrs =msrs_alloc();drivers/cpufreq/acpi-cpufreq.c +1
-0@@ -1021,12 +995,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init ();
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [**]
Quoted 3 lines
We are calling it before registering cpufreq driver. Will this have any complications?
When we call [**] after the cpufreq_register_driver [***] we end up with sysfs boost attribute not exported at x86.
The boost attribute is exported at [***] only when acpi_cpufreq.boost_supported = true. However support for boost at x86 is evaluated at acpi_cpufreq_boost_init().
Quoted 8 lines
Quoted 8 lines
drivers/cpufreq/acpi-cpufreq.c +0
-2ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret;
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 3/8] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
Quoted 10 lines · Lukasz Majewski
On Fri, 26 Jul 2013 12:58:02 +0530 Viresh Kumar wrote,
Quoted 7 lines · Lukasz Majewski
drivers/cpufreq/acpi-cpufreq.c static struct cpufreq_driver acpi_cpufreq_driver = { · line 934
Quoted 6 lines
drivers/cpufreq/acpi-cpufreq.c +1
-0static void __init acpi_cpufreq_boost_init (void ) { + acpi_cpufreq_driver.boost_supported = false;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 1 line
Quoted 8 lines
Quoted 1 line
Would be better if we do this in else of below if.
We need to set
boost_supported= false at [*] for the case when:
1.msrs_allocfails
or
2.acpi_cpufreqis built as a module and can be inserted and removed several times. Without [*] we could end up with wrong (not false) initial state.
Hmm.. Now that I see the code again, we don't need to set it to false as it is a global variable and this field is already set to false..
Quoted 11 lines
Quoted 9 lines
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 998
Quoted 9 lines
if (boot_cpu_has(X86_FEATURE_CPB) ||
boot_cpu_has(X86_FEATURE_IDA)) { msrs =msrs_alloc();drivers/cpufreq/acpi-cpufreq.c +1
-0@@ -1021,12 +995,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init ();^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [**]Quoted 1 line
Quoted 8 lines
Quoted 2 lines
We are calling it before registering cpufreq driver. Will this have any complications?
When we call [**] after the
cpufreq_register_driver[***] we end up with sysfs boost attribute not exported at x86.
The boost attribute is exported at [***] only when acpi_cpufreq.boost_supported = true. However support for boost at x86 is evaluated atacpi_cpufreq_boost_init().
I understand why you moved it above cpufreq driver register. I was thinking if there can be few side effects of this..
Re: [PATCH v6 3/8] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
On Fri, 26 Jul 2013 14:54:07 +0530 Viresh Kumar [email protected] wrote,
Quoted 21 lines · Lukasz Majewski
Quoted 11 lines
On Fri, 26 Jul 2013 12:58:02 +0530 Viresh Kumar wrote,
Quoted 8 lines
drivers/cpufreq/acpi-cpufreq.c static struct cpufreq_driver acpi_cpufreq_driver = { · line 934
Quoted 6 lines · Lukasz Majewski
drivers/cpufreq/acpi-cpufreq.c +1
-0static void __init acpi_cpufreq_boost_init (void ) { + acpi_cpufreq_driver.boost_supported = false;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 1 line
Quoted 8 lines
Quoted 1 line
Would be better if we do this in else of below if.
We need to set
boost_supported= false at [*] for the case when:
1.msrs_allocfails
or
2.acpi_cpufreqis built as a module and can be inserted and removed several times. Without [*] we could end up with wrong (not false) initial state.
Quoted 2 lines
Hmm.. Now that I see the code again, we don't need to set it to false as it is a global variable and this field is already set to false..
Ok, so then I will remove this line [*].
Quoted 15 lines
Quoted 15 lines
Quoted 10 lines
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 998
Quoted 10 lines
if (boot_cpu_has(X86_FEATURE_CPB) ||
boot_cpu_has(X86_FEATURE_IDA)) { msrs =msrs_alloc();drivers/cpufreq/acpi-cpufreq.c +1
-0@@ -1021,12 +995,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init ();^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [**]Quoted 3 lines
We are calling it before registering cpufreq driver. Will this have any complications?
Quoted 8 lines
Quoted 5 lines
When we call [**] after the
cpufreq_register_driver[***] we end up with sysfs boost attribute not exported at x86.
The boost attribute is exported at [***] only when acpi_cpufreq.boost_supported = true. However support for boost at x86 is evaluated atacpi_cpufreq_boost_init().I understand why you moved it above cpufreq driver register. I was thinking if there can be few side effects of this..
As fair as I've tested it, there weren't any side effects.
Moreover the acpi_cpufreq_boost_init() mostly read state of the HW, so IMHO can be done before cpufreg_register_driver().
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v6 3/8] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Viresh KumarOn Fri, 26 Jul 2013 14:54:07 +0530 Viresh Kumar [email protected] wrote,
Quoted 21 lines · Lukasz Majewski
Quoted 11 lines
On Fri, 26 Jul 2013 12:58:02 +0530 Viresh Kumar wrote,
Quoted 8 lines
drivers/cpufreq/acpi-cpufreq.c static struct cpufreq_driver acpi_cpufreq_driver = { · line 934
Quoted 6 lines · Lukasz Majewski
drivers/cpufreq/acpi-cpufreq.c +1
-0static void __init acpi_cpufreq_boost_init (void ) { + acpi_cpufreq_driver.boost_supported = false;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 1 line
Quoted 8 lines
Quoted 1 line
Would be better if we do this in else of below if.
We need to set
boost_supported= false at [*] for the case when:
1.msrs_allocfails
or
2.acpi_cpufreqis built as a module and can be inserted and removed several times. Without [*] we could end up with wrong (not false) initial state.
Quoted 2 lines
Hmm.. Now that I see the code again, we don't need to set it to false as it is a global variable and this field is already set to false..
Ok, I will delete the line at [*].
Quoted 15 lines
Quoted 15 lines
Quoted 10 lines
drivers/cpufreq/acpi-cpufreq.c static int __init acpi_cpufreq_init(void) · line 998
Quoted 10 lines
if (boot_cpu_has(X86_FEATURE_CPB) ||
boot_cpu_has(X86_FEATURE_IDA)) { msrs =msrs_alloc();drivers/cpufreq/acpi-cpufreq.c +1
-0@@ -1021,12 +995,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init ();^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [**]Quoted 3 lines
We are calling it before registering cpufreq driver. Will this have any complications?
Quoted 8 lines
Quoted 5 lines
When we call [**] after the
cpufreq_register_driver[***] we end up with sysfs boost attribute not exported at x86.
The boost attribute is exported at [***] only when acpi_cpufreq.boost_supported = true. However support for boost at x86 is evaluated atacpi_cpufreq_boost_init().I understand why you moved it above cpufreq driver register. I was thinking if there can be few side effects of this..
Have any problem with the above change came to your mind?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 3/8] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
Quoted 1 line · Lukasz Majewski
Have any problem with the above change came to your mind?
No.
PATCH v6 4/8 thermal:boost: Automatic enable/disable of BOOST feature
In reply to Lukasz MajewskiThis patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.
---
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost related thermal_zone_device struct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used when CONFIG_CPU_FREQ is NOT defined.
Changes for v5:
- Move boost disable code from cpu_cooling.c to thermal_core.c
(to handle_non_critical_trips)
- Extent struct thermal_zone_device by adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Changes for v4:
- New patch
drivers/thermal/thermal_core.c | 55 ++++++++++++++++++++++++++++++++++++++++ include/linux/cpufreq.h | 15 +++++++++++ include/linux/thermal.h | 2 ++ 3 files changed, 72 insertions(+)
drivers/thermal/thermal_core.c +55 -0
@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h>
@@ -354,9 +355,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only +* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} +static void handle_thermal_trip (struct thermal_zone_device *tz,int trip) {enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);
@@ -455,6 +506,10 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }
include/linux/cpufreq.h +15 -0
@@ -435,9 +435,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,unsigned int relation, unsigned int *index); +#ifdef CONFIG_CPU_FREQ int cpufreq_boost_trigger_state (int state);int cpufreq_boost_supported (void );int cpufreq_boost_enabled (void ); +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following 3 funtions are for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);
include/linux/thermal.h +2 -0
@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 1 line
1.7.10.4
Re: [PATCH v6 4/8] thermal:boost: Automatic enable/disable of BOOST feature
Dear Zhang, Eduardo,
Quoted 30 lines
This patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Quoted 3 lines
Changes for v4:
- New patch
ping...
Quoted 133 lines
drivers/thermal/thermal_core.c | 55++++++++++++++++++++++++++++++++++++++++
include/linux/cpufreq.h| 15 +++++++++++include/linux/thermal.h| 2 ++ 3 files changed, 72
insertions(+)(quoted diff) +0
-0
b/drivers/thermal/thermal_core.cindex 1f02e8e..8f4be55 100644drivers/thermal/thermal_core.c +38
-0@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h> @@ -354,9 +355,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only
drivers/thermal/thermal_core.c +11
-0+* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} + static void handle_thermal_trip(struct thermal_zone_device *tz, inttrip) {
drivers/thermal/thermal_core.c +2
-0enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);@@ -455,6 +506,10 @@ static void thermal_zone_device_check(struct
work_struct*work) structthermal_zone_device*tz = container_of(work, structthermal_zone_device,drivers/thermal/thermal_core.c +4
-0poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }include/linux/cpufreq.h +15
-0@@ -435,9 +435,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, unsigned int relation, unsigned int *index); +#ifdef CONFIG_CPU_FREQ int cpufreq_boost_trigger_state (int state);int cpufreq_boost_supported (void );int cpufreq_boost_enabled (void ); +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following 3 funtions are for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);include/linux/thermal.h +2
-0@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v6 5/8 cpufreq:boost:Kconfig: Provide support for software managed BOOST
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "EXYNOS Frequency Overclocking - Software" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v6:
- CPU_FREQ_BOOST_SW [1] is now defined as "invisible" bool option.
- Platform dependent ARM_EXYNOS_CPU_FREQ_BOOST_SW config option has been added. It depends on ARM_EXYNOS_CPUFREQ options and selects EXYNOS_THERMAL with the main boost config [1].
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 3 +++ drivers/cpufreq/Kconfig.arm | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
drivers/cpufreq/Kconfig +3 -0
@@ -23,6 +23,9 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE
drivers/cpufreq/Kconfig.arm +16 -0
@@ -55,6 +55,22 @@ config ARM_EXYNOS5440_CPUFREQ different than previous exynos controllers so not using the common exynos framework. +config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + default n + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. + config ARM_HIGHBANK_CPUFREQ tristate "Calxeda Highbank-based" depends on ARCH_HIGHBANK
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v6 5/8] cpufreq:boost:Kconfig: Provide support for software managed BOOST
Quoted 2 lines · Lukasz Majewski
For safety reasons new flag -
CONFIG_CPU_FREQ_BOOST_SWhas been added. Only after selecting "EXYNOS Frequency Overclocking - Software"Kconfig
You shouldn't mention Exynos here and must do exynos stuff at the end in a separate patch. This one must be generic.
Quoted 33 lines
option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v6:
-CPU_FREQ_BOOST_SW[1] is now defined as "invisible" bool option.
- Platform dependentARM_EXYNOS_CPU_FREQ_BOOST_SWconfig option has been added. It depends onARM_EXYNOS_CPUFREQoptions and selectsEXYNOS_THERMALwith the main boost config [1].Changes for v5:
- New patchdrivers/cpufreq/Kconfig | 3 +++ drivers/cpufreq/Kconfig.arm | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)drivers/cpufreq/Kconfig +0
-0
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 5 lines
drivers/cpufreq/Kconfig +2
-0@@ -23,6 +23,9 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool
Invisible is fine but this must be disabled by default and must depend on thermal, rather than moving dependency on platform's config.
Re: [PATCH v6 5/8] cpufreq:boost:Kconfig: Provide support for software managed BOOST
On Fri, 26 Jul 2013 15:54:56 +0530 Viresh Kumar wrote,
Quoted 7 lines · Lukasz Majewski
Quoted 3 lines
For safety reasons new flag -
CONFIG_CPU_FREQ_BOOST_SWhas been added. Only after selecting "EXYNOS Frequency Overclocking - Software"KconfigYou shouldn't mention Exynos here and must do exynos stuff at the end in a separate patch. This one must be generic.
Please see below comments.
Quoted 38 lines
Quoted 38 lines
option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v6:
-CPU_FREQ_BOOST_SW[1] is now defined as "invisible" bool option.
- Platform dependentARM_EXYNOS_CPU_FREQ_BOOST_SWconfig option has been added. It depends onARM_EXYNOS_CPUFREQoptions and selectsEXYNOS_THERMALwith the main boost config [1].Changes for v5:
- New patchdrivers/cpufreq/Kconfig | 3 +++ drivers/cpufreq/Kconfig.arm | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)drivers/cpufreq/Kconfig +0
-0@@ -23,6 +23,9 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool
Quoted 6 lines
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 2 lines
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + boolInvisible is fine but this must be disabled by default and must depend on thermal, rather than moving dependency on platform's config.
The CPU_FREQ_BOOST_SW [1] is a generic flag (invisible).
I will add "default n" to it.
It shall be used at all BOOST dependent #ifdefs (generic + platform).
Also I've introduced the ARM_EXYNOS_CPU_FREQ_BOOST_SW [2] config option. The CPU_FREQ_BOOST_SW option is selected from it.
Moreover the [2] depends on ARM_EXYNOS_CPUFREQ (which prevents from accidental enable/disable). And it selects automatically the EXYNOS_THERMAL, which is much better than depending only on THERMAL [3] (the generic framework).
Depending only on [3], results at situation where SW BOOST can be enabled at x86 or ARM target with only generic THERMAL support (which doesn't protect from overheating).
So the proposed solution:
1. Defines global flag [1]
2. This flag is selected only when dependencies for more HW close flag
[2] are meet.
3. It is more natural to have Kconfig BOOST enable/disable checkbox at platform cpufreq driver (with description closer to HW).
4. Other ARCHs can easily define similar to [2] flag and by it select [1].
For me the approach proposed in this patch is more natural and provides high protection level from accidental SW boost enable.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 5/8] cpufreq:boost:Kconfig: Provide support for software managed BOOST
Quoted 6 lines · Lukasz Majewski
On Fri, 26 Jul 2013 15:54:56 +0530 Viresh Kumar wrote,
Quoted 5 lines · Lukasz Majewski
Quoted 3 lines
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + bool
Quoted 7 lines
Quoted 3 lines
Invisible is fine but this must be disabled by default and must depend on thermal, rather than moving dependency on platform's config.
The
CPU_FREQ_BOOST_SW[1] is a generic flag (invisible).I will add "default n" to it.
Leave it.. We don't need it now.. that's how these kind of config options are defined as they are disabled by default.
Quoted 3 lines
Depending only on [3], results at situation where SW BOOST can be enabled at x86 or ARM target with only generic THERMAL support (which doesn't protect from overheating).
I had a similar concern.. Currently also we aren't stopping anybody to enable boost. By selecting thermal from CPU_FREQ_BOOST_SW, atleast we are communicating this very well to developers that they need something else as well. And currently we only have thermal as a source for telling when to block boost but it can be something else too..
I never said, don't use EXYNOS_THERMAL, its good to have a dependency on it in the Exynos specific config for boost, but I wanted normal sw boost also to depend on thermal..
Re: [PATCH v6 5/8] cpufreq:boost:Kconfig: Provide support for software managed BOOST
On Mon, 29 Jul 2013 12:28:02 +0530 Viresh Kumar [email protected] wrote,
Quoted 12 lines · Lukasz Majewski
Quoted 11 lines
On Fri, 26 Jul 2013 15:54:56 +0530 Viresh Kumar wrote,
Quoted 9 lines
drivers/cpufreq/Kconfig config CPU_FREQ_TABLE · line 27
Quoted 2 lines · Lukasz Majewski
drivers/cpufreq/Kconfig +2
-0+config CPU_FREQ_BOOST_SW + boolInvisible is fine but this must be disabled by default and must depend on thermal, rather than moving dependency on platform's config.
Quoted 6 lines
Quoted 3 lines
The
CPU_FREQ_BOOST_SW[1] is a generic flag (invisible).I will add "default n" to it.
Leave it.. We don't need it now.. that's how these kind of config options are defined as they are disabled by default.
Ok. Please see below proposition.
Quoted 11 lines
Quoted 4 lines
Depending only on [3], results at situation where SW BOOST can be enabled at x86 or ARM target with only generic THERMAL support (which doesn't protect from overheating).
I had a similar concern.. Currently also we aren't stopping anybody to enable boost. By selecting thermal from
CPU_FREQ_BOOST_SW, atleast we are communicating this very well to developers that they need something else as well. And currently we only have thermal as a source for telling when to block boost but it can be something else too..
Quoted 3 lines
I never said, don't use
EXYNOS_THERMAL, its good to have a dependency on it in the Exynos specific config for boost, but I wanted normal sw boost also to depend on thermal..
1. at ./drivers/cpufreq/Kconfig:
+config CPU_FREQ_BOOST_SW
+ bool
+ depends on THERMAL
2. at ./drivers/cpufreq/Kconfig.arm:
+config ARM_EXYNOS_CPU_FREQ_BOOST_SW
+ bool "EXYNOS Frequency Overclocking - Software"
+ depends on ARM_EXYNOS_CPUFREQ
+ select CPU_FREQ_BOOST_SW
+ select EXYNOS_THERMAL
+ default n
+ help
+ This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate.
+
+ It reguires, for safe operation, thermal framework with
properly
+ defined trip points.
+
+ If in doubt, say N.
+
Shall I split this patch to two (1. and 2.) or leave it as a single one?
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 5/8] cpufreq:boost:Kconfig: Provide support for software managed BOOST
Quoted 26 lines · Lukasz Majewski
1. at
./drivers/cpufreq/Kconfig:drivers/cpufreq/Kconfig +3
-0+config CPU_FREQ_BOOST_SW + bool + depends on THERMAL2. at
./drivers/cpufreq/Kconfig.arm:drivers/cpufreq/Kconfig.arm +16
-0+config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + default n + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. +
Quoted 1 line
Shall I split this patch to two (1. and 2.) or leave it as a single one?
Looks fine.. Keep it in a single patch.
Re: [PATCH v6 5/8] cpufreq:boost:Kconfig: Provide support for software managed BOOST
On Mon, 12 Aug 2013 15:58:12 +0530 Viresh Kumar [email protected] wrote,
Quoted 8 lines
Quoted 6 lines · Lukasz Majewski
1. at
./drivers/cpufreq/Kconfig:drivers/cpufreq/Kconfig +3
-0+config CPU_FREQ_BOOST_SW + bool + depends on THERMAL
Quoted 8 lines
drivers/cpufreq/Kconfig.arm config ARM_EXYNOS5440_CPUFREQ · line 63
Quoted 8 lines
2. at
./drivers/cpufreq/Kconfig.arm:drivers/cpufreq/Kconfig.arm +6
-0+config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + default n
^^^^^^^^^^^^^^^^ I will also remove this line.
Quoted 13 lines
Quoted 13 lines
(quoted diff) +2
-0+ help + This driver supports software managed overclocking(BOOST).
drivers/cpufreq/Kconfig.arm +8
-0+ It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. +
Quoted 4 lines
Quoted 2 lines
Shall I split this patch to two (1. and 2.) or leave it as a single one?
Looks fine.. Keep it in a single patch.
Ok.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v6 6/8 cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Lukasz MajewskiThe cpufreq_driver's boost_supported flag is true only when boost support is explicitly enabled. Boost related attributes are exported only under the same condition.
---
Changes for v6:
- Replace exynos_driver.boost_supported = 1 to = true
- Protect boost attributes export with CONFIG_CPU_FREQ_BOOST_SW
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Remove low level boost code
- Move boost management code to cpufreq core code
- Use boost_supported flag to indicate if driver supports over clocking
Changes for v2:
- Removal of struct cpufreq_boost
- Removal of the CONFIG_CPU_FREQ_BOOST flag
- low_level_boost with valid address when boost is supported
drivers/cpufreq/exynos-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/exynos-cpufreq.c +6 -0
@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_CPU_FREQ_BOOST_SW + &cpufreq_freq_attr_scaling_boost_freqs, +#endifNULL , };
@@ -332,6 +335,9 @@ static int __init exynos_cpufreq_probe(struct platform_device *pdev) locking_frequency =exynos_getspeed (0 ); +#ifdef CONFIG_CPU_FREQ_BOOST_SW + exynos_driver.boost_supported = true; +#endif register_pm_notifier (&exynos_cpufreq_nb);if (cpufreq_register_driver (&exynos_driver)) {
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v6 6/8] cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy) · line 273
Quoted 9 lines · Lukasz Majewski
drivers/cpufreq/exynos-cpufreq.c +1
-0@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_CPU_FREQ_BOOST_SW
Use ARM_EXYNOS_CPU_FREQ_BOOST_SW instead.
drivers/cpufreq/exynos-cpufreq.c static int __init exynos_cpufreq_probe(struct platform_device *pdev) · line 340
Quoted 12 lines
drivers/cpufreq/exynos-cpufreq.c +5
-0+ &cpufreq_freq_attr_scaling_boost_freqs, +#endif NULL, };@@ -332,6 +335,9 @@ static int __init exynos_cpufreq_probe(struct platform_device *pdev) locking_frequency =exynos_getspeed (0 ); +#ifdef CONFIG_CPU_FREQ_BOOST_SW + exynos_driver.boost_supported = true; +#endif
So, why here and not in the definition of exynos_driver?
Quoted 6 lines
drivers/cpufreq/exynos-cpufreq.c +0
-1register_pm_notifier (&exynos_cpufreq_nb);if (cpufreq_register_driver (&exynos_driver)) { --1.7.10.4
Re: [PATCH v6 6/8] cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
On Fri, 26 Jul 2013 15:56:53 +0530 Viresh Kumar wrote,
Quoted 9 lines · Lukasz Majewski
Quoted 8 lines
(quoted diff) +0
-0
b/drivers/cpufreq/exynos-cpufreq.cindex 9ae1871..175172d9 100644drivers/cpufreq/exynos-cpufreq.c +0
-0@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
Quoted 3 lines
drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy) · line 273
Quoted 3 lines
drivers/cpufreq/exynos-cpufreq.c +1
-0static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_CPU_FREQ_BOOST_SW
^^^^^^^^^^^^^^^^^^^^^^^^^ [*]
Quoted 2 lines
Use
ARM_EXYNOS_CPU_FREQ_BOOST_SWinstead.
For the reasons explained at [PATCH v6 5/8] I would prefer to leave [*] here.
Quoted 9 lines
Quoted 9 lines
drivers/cpufreq/exynos-cpufreq.c +2
-0+ &cpufreq_freq_attr_scaling_boost_freqs, +#endif NULL, };@@ -332,6 +335,9 @@ static int __init exynos_cpufreq_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/cpufreq/exynos-cpufreq.c static int __init exynos_cpufreq_probe(struct platform_device *pdev) · line 340
Quoted 5 lines
drivers/cpufreq/exynos-cpufreq.c +3
-0locking_frequency =exynos_getspeed (0 ); +#ifdef CONFIG_CPU_FREQ_BOOST_SW + exynos_driver.boost_supported = true; +#endif So, why here and not in the definition of
exynos_driver?
Right. I will move this to struct cpufreq_driver exynos_driver.
Quoted 7 lines
Quoted 7 lines
drivers/cpufreq/exynos-cpufreq.c +0
-0register_pm_notifier (&exynos_cpufreq_nb);if (cpufreq_register_driver(&exynos_driver)) {--
1.7.10.4
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v6 6/8] cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
Quoted 15 lines · Lukasz Majewski
On Fri, 26 Jul 2013 15:56:53 +0530 Viresh Kumar wrote,
Quoted 9 lines · Lukasz Majewski
Quoted 8 lines
(quoted diff) +0
-0
b/drivers/cpufreq/exynos-cpufreq.cindex 9ae1871..175172d9 100644drivers/cpufreq/exynos-cpufreq.c +0
-0@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)Quoted 3 lines
drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy) · line 273
Quoted 3 lines
drivers/cpufreq/exynos-cpufreq.c +1
-0static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_CPU_FREQ_BOOST_SW^^^^^^^^^^^^^^^^^^^^^^^^^ [*]Quoted 1 line
Quoted 4 lines
Quoted 1 line
Use
ARM_EXYNOS_CPU_FREQ_BOOST_SWinstead.For the reasons explained at [PATCH v6 5/8] I would prefer to leave [*] here.
I don't see how that reasoning fit here.
This is exynos code and you must use exynos specific boost Kconfig option here.. Otherwise It might be enabled without Exynos specific option, if somebody else has selected CONFIG_CPU_FREQ_BOOST_SW in
a multi platform kernel,
Re: [PATCH v6 6/8] cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Viresh KumarOn Fri, 26 Jul 2013 15:56:53 +0530 Viresh Kumar [email protected] wrote,
Quoted 9 lines · Lukasz Majewski
Quoted 8 lines
(quoted diff) +0
-0
b/drivers/cpufreq/exynos-cpufreq.cindex 9ae1871..175172d9 100644drivers/cpufreq/exynos-cpufreq.c +0
-0@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)
Quoted 5 lines
drivers/cpufreq/exynos-cpufreq.c static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy) · line 273
Quoted 3 lines
drivers/cpufreq/exynos-cpufreq.c +1
-0static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_CPU_FREQ_BOOST_SWUse
ARM_EXYNOS_CPU_FREQ_BOOST_SWinstead.
Ok, the ARM_EXYNOS_CPU_FREQ_BOOST_SW looks more appropriate here.
Quoted 9 lines
Quoted 9 lines
drivers/cpufreq/exynos-cpufreq.c +2
-0+ &cpufreq_freq_attr_scaling_boost_freqs, +#endif NULL, };@@ -332,6 +335,9 @@ static int __init exynos_cpufreq_probe(struct platform_device *pdev)
Quoted 7 lines
drivers/cpufreq/exynos-cpufreq.c static int __init exynos_cpufreq_probe(struct platform_device *pdev) · line 340
Quoted 5 lines
drivers/cpufreq/exynos-cpufreq.c +3
-0locking_frequency =exynos_getspeed (0 ); +#ifdef CONFIG_CPU_FREQ_BOOST_SW + exynos_driver.boost_supported = true; +#endif So, why here and not in the definition of
exynos_driver?
Ok, I will move the above code to struct cpufreq_driver exynos_driver
Quoted 7 lines
Quoted 7 lines
drivers/cpufreq/exynos-cpufreq.c +0
-0register_pm_notifier (&exynos_cpufreq_nb);if (cpufreq_register_driver(&exynos_driver)) {--
1.7.10.4
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v6 7/8 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v6:
- None
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
PATCH v6 8/8 cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
In reply to Lukasz MajewskiSpecial driver data flag (CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.
---
Changes for v6:
- New patch
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/exynos4x12-cpufreq.c +1 -1
@@ -32,7 +32,7 @@ static unsigned int exynos4x12_volt_table[] = { };static struct cpufreq_frequency_table exynos4x12_freq_table[] = { - {L0 ,CPUFREQ_ENTRY_INVALID }, + {CPUFREQ_BOOST_FREQ ,1500 *1000 }, {L1 ,1400 *1000 }, {L2 ,1300 *1000 }, {L3 ,1200 *1000 },
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerQuoted 41 lines · Lukasz Majewski
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. Thecpufreq_driveris responsibile for settingboost_supportedflag and providingset_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selected only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related fields:
--boost_supported- when driver supports boosting --boost_enabled- boost state
--set_boost- callback to function, which is necessary to
enable/disable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- All available policies are now stored in a list.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Quoted 6 lines
New patches for v6:
cpufreq:exynos4x12: Change L0 driver data toCPUFREQ_BOOST_FREQTested at HW:
Exynos 4412 3.11-rc1 Linux Intel Core i7-3770 3.11-rc1 Linux
I am done with review of this patchset now and should say pretty much comfortable with it now..
v7 cover cpufreq:boost: CPU Boost mode support
In reply to Lukasz MajewskiThis patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreq
Boost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The cpufreq_driver is responsibile for setting boost_supported flag and providing set_boost callback(if HW support is needed). For software managed boost, special Kconfig flag - CONFIG_CPU_FREQ_BOOST_SW has been defined. It will be selected only when a target platform has thermal framework properly configured.
- struct cpufreq_driver has been extended with boost related fields:
-- boost_supported - when driver supports boosting -- boost_enabled - boost state
-- set_boost - callback to function, which is necessary to
enable/disable boost
- Boost sysfs attribute (/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.
- No special spin_lock for Boost was created. The one from cpufreq core was reused.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc4 Linux
Intel Core i7-3770 3.11-rc4 LinuxAbove patches were posted on top of linux_pm/linux-next with following patches applied:
cpufreq: exynos5440: Fix to skip when new frequency same as current
cpufreq: fix EXYNOS drivers selection
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common
boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Documentation/cpu-freq/boost.txt | 26 ++++---- drivers/cpufreq/Kconfig | 4 ++ drivers/cpufreq/Kconfig.arm | 15 +++++ drivers/cpufreq/acpi-cpufreq.c | 86 +++++++++---------------- drivers/cpufreq/cpufreq.c | 115 +++++++++++++++++++++++++++++++++- drivers/cpufreq/exynos-cpufreq.c | 6 ++ drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- drivers/cpufreq/freq_table.c | 53 +++++++++++++--- drivers/thermal/thermal_core.c | 55 ++++++++++++++++ include/linux/cpufreq.h | 26 +++++++- include/linux/thermal.h | 2 + 11 files changed, 310 insertions(+), 80 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v7 1/7 cpufreq: Add boost frequency support in core
This commit adds boost frequency support in cpufreq core (Hardware & Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency above its normal operation limits. Such mode shall be only used for a short time.
Overclocking (boost) support is essentially provided by platform dependent cpufreq driver.
This commit unifies support for SW and HW (Intel) overclocking solutions in the core cpufreq driver. Previously the "boost" sysfs attribute was defined at acpi driver code. By default boost is disabled. One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.
It only shows up when cpufreq driver supports overclocking. Under the hood frequencies dedicated for boosting are marked with a special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table. It is the user's concern to enable/disable overclocking with a proper call to sysfs.
The cpufreq_boost_trigger_state() function is defined non static on purpose. It is used later with thermal subsystem to provide automatic enable/disable of the BOOST feature.
---
Changes for v7:
- Properly change cpufreq_driver->boost_enabled when set_boost() fails (=0 to =!state)
- Add likely() around cpufreq_driver
- Remove parenthesis around boost.attr
Changes for v6:
- Remove sysfs boost attribute when subsys_iterface_unregister() fails
- Move global boost_enabled variable from cpufreq.c to platform dependent struct cpufreq_driver
- pr_err() message is also printed when boost disable fails
- Call __cpufreq_governor() to force recalculation of next frequency when boost is triggered. It is needed with i.e. performance class of governors
- Change cpufreq_boost_enable_sw() -> cpufreq_boost_set_sw()
- Rename .enable_boost function pointer to .set_boost
Changes for v5:
- Rename cpufreq_boost_trigger_state_sw() to cpufreq_boost_enable_sw()
- Extent cpufreq_register_driver() to check if cpufreq driver provided boost_enable callback. If not provided, then use cpufreq_boost_enable_sw()
- Use single call to cpufreq_driver->enable_boost() with cpufreq driver provided callback or default SW boost enable routine
- Move pr_debug call to store_boost() from cpufreq_boost_trigger_state()
- Change the user_policy.max value when SW boost is toggled. It is necessary for proper operation of e.g. thermal subsystem.
- Add check if cpufreq_driver pointer is not NULL at cpufreq_boost_supported() routine
- Add EXPORT_SYMBOL_GPL for cpufreq_boost_supported() and cpufreq_boost_enabled()
- Remove extra check for cpufreq_boost_supported() at cpufreq_freq_table_cpuinfo()
- Explanation of show boost logic at show_available_freqs()
- Add cpufreq_set_boost_enabled() method to set initial value of boost_enabled global flag
Changes for v4:
- Remove boost parameter from cpufreq_frequency_table_cpuinfo() function
- Introduce cpufreq_boost_supported() method
- Use of cpufreq_boost_supported() and cpufreq_boost_enabled() to decide if frequency shall be skipped
- Rename set_boost_freq() to enable_boost()
- cpufreq_attr_available_freq() moved to freq_table.c
- Use policy list to get access to cpufreq policies
- Rename global boost flag (cpufreq_boost_enabled -> boost_enabled)
- pr_err corrected ( %sable)
- Remove sanity check at cpufreq_boost_trigger_state() entrance [to test if boost is supported]
- Use either HW (boost_enable) callback or SW managed boost
- Introduce new cpufreq_boost_trigger_state_sw() method to handle boost at SW.
- Protect boost_enabled manipulation with lock.
Changes for v3:
- Method for reading boost status
- Removal of cpufreq_frequency_table_max()
- Extent cpufreq_frequency_table_cpuinfo() to support boost parameter
- boost_supported flag added to cpufreq_driver struct
- "boost" sysfs attribute control flag removed
- One global flag describing state of the boost defined at cpufreq core
- Rename cpufreq_driver's low_level_boost field to set_boost_freq()
- Usage of cpufreq_sysfs_{remove|add}_file() routines
Changes for v2:
- Removal of cpufreq_boost structure and move its fields to cpufreq_driver structure
- Flag to indicate if global boost attribute is already defined
- Extent the pr_{err|debbug} functions to show current function names
drivers/cpufreq/cpufreq.c | 115 +++++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/freq_table.c | 53 ++++++++++++++++--- include/linux/cpufreq.h | 10 ++++ 3 files changed, 170 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +114 -1
@@ -345,6 +345,33 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);/********************************************************************* * SYSFS INTERFACE * *********************************************************************/ +ssize_t show_boost (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" , cpufreq_driver->boost_enabled); +} + +static ssize_t store_boost (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t count) +{ +int ret, enable; + + ret =sscanf (buf,"%d" , &enable); +if (ret !=1 || enable <0 || enable >1 ) +return -EINVAL ; + +if (cpufreq_boost_trigger_state (enable)) { +pr_err ("%s: Cannot %s BOOST!\n" , __func__, + enable ?"enable" :"disable" ); +return -EINVAL ; + } + +pr_debug ("%s: cpufreq BOOST %s\n" , __func__, + enable ?"enabled" :"disabled" ); + +return count; +} +define_one_global_rw (boost);static struct cpufreq_governor *__find_governor (const char *str_governor) {
@@ -2036,6 +2063,70 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { };/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (!ret) { + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enabled" :"disabled" ); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (likely (cpufreq_driver)) +return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
@@ -2074,9 +2165,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if driver provides function to enable boost - +* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&boost.attr); +if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
@@ -2103,6 +2210,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;
@@ -2129,6 +2239,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); +unregister_hotcpu_notifier (&cpufreq_cpu_notifier);down_write (&cpufreq_rwsem);
drivers/cpufreq/freq_table.c +46 -7
79 lines not on this page · raw message
include/linux/cpufreq.h +10 -0
@@ -209,6 +209,11 @@ struct cpufreq_driver {int (*suspend) (struct cpufreq_policy *policy);int (*resume) (struct cpufreq_policy *policy);struct freq_attr **attr; + +/* platform specific boost support code */ +bool boost_supported; +bool boost_enabled; +int (*set_boost) (int state); };/* flags */
@@ -381,6 +386,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;#define CPUFREQ_ENTRY_INVALID ~0#define CPUFREQ_TABLE_END ~1 +#define CPUFREQ_BOOST_FREQ ~2struct cpufreq_frequency_table {unsigned int driver_data;/* driver specific data, not used by core */
@@ -402,12 +408,16 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +int cpufreq_boost_trigger_state (int state); +int cpufreq_boost_supported (void ); +int cpufreq_boost_enabled (void );/* the following funtion is for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);/* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; +extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;void cpufreq_frequency_table_get_attr (struct cpufreq_frequency_table *table,unsigned int cpu);void cpufreq_frequency_table_put_attr (unsigned int cpu);
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
Some minor nitpicking, nothing much :)
Quoted 6 lines · Lukasz Majewski
drivers/cpufreq/cpufreq.c +5
-0+static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ;
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2082
Quoted 10 lines
drivers/cpufreq/cpufreq.c +10
-0+ +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (!ret) { + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + }
In case ret wasn't 0 (i.e. we failed), we should print an error message and break
our loop ?
Quoted 16 lines
drivers/cpufreq/cpufreq.c +16
-0+ } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state;
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2108
Quoted 10 lines
drivers/cpufreq/cpufreq.c +10
-0+write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enabled" :"disabled" );
s/enabled/enable and s/disabled/disable
Quoted 5 lines
drivers/cpufreq/cpufreq.c +5
-0+ } + +return ret; +} +
Re: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
On Mon, 26 Aug 2013 10:58:53 +0530 Viresh Kumar [email protected] wrote,
Quoted 1 line
Some minor nitpicking, nothing much :)
Is there any chance to pull those corrected patches to v3.12?
Quoted 20 lines
Quoted 17 lines · Lukasz Majewski
drivers/cpufreq/cpufreq.c +7
-0+static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + + list_for_each_entry(policy, &cpufreq_policy_list,
policy_list) {
+freq_table=cpufreq_frequency_get_table(policy->cpu);drivers/cpufreq/cpufreq.c +2
-0+if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo(policy,
drivers/cpufreq/cpufreq.c +3
-0+ freq_table); +if (!ret) { + policy->user_policy.max =
Quoted 8 lines
Quoted 4 lines
policy->max;
+ __cpufreq_governor(policy,CPUFREQ_GOV_LIMITS);
+ }In case ret wasn't 0 (i.e. we failed), we should print an error message and break
our loop ?
After your comments I think, that this code could be rewritten:
list_for_each_entry(policy, &cpufreq_policy_list, policy_list) {
freq_table = cpufreq_frequency_get_table(policy->cpu);
if (freq_table) {
ret = cpufreq_frequency_table_cpuinfo(policy,
freq_table);
if (ret) {
pr_err("%s: Policy frequency update
failed\n")
break;
}
policy->user_policy.max = policy->max;
__cpufreq_governor(policy,CPUFREQ_GOV_LIMITS);
}
}
return ret;
}Quoted 21 lines
Quoted 21 lines
drivers/cpufreq/cpufreq.c +20
-0+ } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) {
Quoted 8 lines
drivers/cpufreq/cpufreq.c static struct notifier_block __refdata cpufreq_cpu_notifier = { · line 2108
Quoted 6 lines
drivers/cpufreq/cpufreq.c +3
-0+write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; + write_unlock_irqrestore(&cpufreq_driver_lock,flags); +
drivers/cpufreq/cpufreq.c +2
-0+pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enabled" :"disabled" );s/enabled/enable and s/disabled/disable
Ok.
Quoted 6 lines
Quoted 6 lines
drivers/cpufreq/cpufreq.c +5
-0+ } + +return ret; +} +
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Viresh Kumar
maintainerRe: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
Quoted 5 lines · Lukasz Majewski
On Mon, 26 Aug 2013 10:58:53 +0530 Viresh Kumar [email protected] wrote,
Quoted 1 line
Some minor nitpicking, nothing much :)
Is there any chance to pull those corrected patches to v3.12?
Only Rafael can decide :)
Quoted 11 lines
After your comments I think, that this code could be rewritten:
list_for_each_entry(policy, &cpufreq_policy_list, policy_list) { freq_table = cpufreq_frequency_get_table(policy->cpu); if (freq_table) { ret = cpufreq_frequency_table_cpuinfo(policy, freq_table); if (ret) { pr_err("%s: Policy frequency update failed\n")
Don't break strings into multiple lines even if they cross 80 columns.. And you missed __func__ :)
Quoted 10 lines
break;
}
policy->user_policy.max = policy->max;
__cpufreq_governor(policy,CPUFREQ_GOV_LIMITS);
}
}
return ret;
}Re: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
On Mon, 26 Aug 2013 12:36:47 +0530 Viresh Kumar [email protected] wrote,
Quoted 9 lines
Quoted 5 lines · Lukasz Majewski
On Mon, 26 Aug 2013 10:58:53 +0530 Viresh Kumar
[email protected] wrote,Quoted 1 line
Some minor nitpicking, nothing much :)
Is there any chance to pull those corrected patches to v3.12?
Only Rafael can decide :)
:-)
Quoted 13 lines
Quoted 4 lines
After your comments I think, that this code could be rewritten:
Quoted 8 lines
list_for_each_entry(policy,
&cpufreq_policy_list,policy_list) {freq_table=cpufreq_frequency_get_table(policy->cpu); if (freq_table) {
ret =cpufreq_frequency_table_cpuinfo(policy, freq_table); if (ret) { pr_err("%s: Policy frequency update failed\n")
Quoted 2 lines
Don't break strings into multiple lines even if they cross 80 columns.. And you missed
__func__:)
C code which turned into the pseudo code :-).
Quoted 16 lines
Quoted 11 lines
break; } policy->user_policy.max = policy->max; __cpufreq_governor(policy,CPUFREQ_GOV_LIMITS); } } return ret; }--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
Quoted 6 lines · Lukasz Majewski
On Mon, 26 Aug 2013 12:36:47 +0530 Viresh Kumar [email protected] wrote,
Quoted 4 lines
Quoted 2 lines · Lukasz Majewski
On Mon, 26 Aug 2013 10:58:53 +0530 Viresh Kumar
[email protected] wrote,
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Some minor nitpicking, nothing much :)
Is there any chance to pull those corrected patches to v3.12?
Only Rafael can decide :)
:-)
Well, 3.11 is a week away and the 3.12 merge window will open then.
Honestly, I'd prefer this stuff to spend a couple of weeks in linux-next before pushing it to Linus, so this means 3.13 I'm afraid.
Thanks,
Rafael
Viresh Kumar
maintainerRe: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
Quoted 11 lines · Rafael J. Wysocki
Quoted 10 lines · Lukasz Majewski
On Mon, 26 Aug 2013 12:36:47 +0530 Viresh Kumar [email protected] wrote,
Quoted 8 lines
Quoted 5 lines · Lukasz Majewski
On Mon, 26 Aug 2013 10:58:53 +0530 Viresh Kumar
[email protected] wrote,Quoted 1 line
Some minor nitpicking, nothing much :)
Is there any chance to pull those corrected patches to v3.12?
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Only Rafael can decide :)
:-)
Well, 3.11 is a week away and the 3.12 merge window will open then.
Honestly, I'd prefer this stuff to spend a couple of weeks in linux-next before pushing it to Linus, so this means 3.13 I'm afraid.
+1
Re: [PATCH v7 1/7] cpufreq: Add boost frequency support in core
On Mon, 26 Aug 2013 19:30:07 +0530 Viresh Kumar [email protected] wrote,
Quoted 16 lines · Rafael J. Wysocki
Quoted 15 lines · Lukasz Majewski
Quoted 13 lines
On Mon, 26 Aug 2013 12:36:47 +0530 Viresh Kumar
[email protected] wrote,Quoted 9 lines
Quoted 5 lines · Lukasz Majewski
On Mon, 26 Aug 2013 10:58:53 +0530 Viresh Kumar
[email protected] wrote,Quoted 1 line
Some minor nitpicking, nothing much :)
Is there any chance to pull those corrected patches to v3.12?
Only Rafael can decide :)
:-)
Quoted 7 lines
Quoted 5 lines
Well, 3.11 is a week away and the 3.12 merge window will open then.
Honestly, I'd prefer this stuff to spend a couple of weeks in linux-next before pushing it to Linus, so this means 3.13 I'm afraid.
+1
Ok. I understand.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v7 2/7 cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Lukasz MajewskiThe Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.
The _store_boost() function has been redesigned to be used as set_boost callback.
---
Changes for v7:
- Remove superfluous acpi_cpufreq_driver.boost_supported = false at acpi_cpufreq_boost_init()
Changes for v6:
- Perform acpi_cpufreq_boost_init initialization before cpufreq_driver registration
- Compile store_boost() only when CONFIG_X86_ACPI_CPUFREQ_CPB defined
- Use boost_enabled flag defined at acpi_cpufreq_driver to store information about boost state
- Instead of using cpufreq_set_boost_enabled(), modify the boost_enable in the acpi driver code
Changes for v5:
- Remove acpi-cpufreq's boost_enabled global flag and reuse one defined at cpufreq core
Changes for v4:
- add _store_boost to acpi_cpufreq_driver structure
Changes for v3:
- Bring back boost_enabled as a global flag
- Move boost_supported to cpufreq_driver structure
Changes for v2:
- Replace boost_enabled and boost_supported global flags with proper entries at struct cpufreq_driver.
- Removal of struct cpufreq_boost
drivers/cpufreq/acpi-cpufreq.c | 86 ++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 57 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +29 -57
@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;static struct cpufreq_driver acpi_cpufreq_driver;static unsigned int acpi_pstate_strict; -static bool boost_enabled, boost_supported;static struct msr __percpu *msrs;static bool boost_state (unsigned int cpu)
@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static ssize_t _store_boost (const char *buf,size_t count) +static int _store_boost (int val) { -int ret; -unsigned long val =0 ; - -if (!boost_supported) -return -EINVAL ; - - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) -return -EINVAL ; - -if ((val && boost_enabled) || (!val && !boost_enabled)) -return count; -get_online_cpus (); -boost_set_msrs (val, cpu_online_mask); -put_online_cpus (); - - boost_enabled = val;pr_debug ("Core Boosting %sabled.\n" , val ?"en" :"dis" ); -return count; -} - -static ssize_t store_global_boost (struct kobject *kobj,struct attribute *attr, -const char *buf,size_t count) -{ -return _store_boost (buf, count); -} - -static ssize_t show_global_boost (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -return sprintf (buf,"%u\n" , boost_enabled); +return 0 ; } -static struct global_attr global_boost =__ATTR (boost,0644 , - show_global_boost, - store_global_boost); -static ssize_t show_freqdomain_cpus (struct cpufreq_policy *policy,char *buf) {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);
@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)cpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB +static ssize_t store_boost (const char *buf,size_t count) +{ +int ret; +unsigned long val =0 ; + +if (!acpi_cpufreq_driver.boost_supported) +return -EINVAL ; + + ret =kstrtoul (buf,10 , &val); +if (ret || (val >1 )) +return -EINVAL ; + +_store_boost ((int ) val); + +return count; +} +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -return _store_boost (buf, count); +return store_boost (buf, count); }static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) { -return sprintf (buf,"%u\n" , boost_enabled); +return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled); }static struct freq_attr cpb =__ATTR (cpb,0644 , show_cpb, store_cpb);
@@ -582,7 +565,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,switch (action) {case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN : -boost_set_msrs (boost_enabled, cpumask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, cpumask);break ;case CPU_DOWN_PREPARE :
@@ -937,6 +920,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, + .set_boost = _store_boost, };static void __init acpi_cpufreq_boost_init (void )
@@ -947,33 +931,22 @@ static void __init acpi_cpufreq_boost_init(void)if (!msrs)return ; - boost_supported = true; - boost_enabled =boost_state (0 ); - + acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.boost_enabled =boost_state (0 );get_online_cpus ();/* Force all MSRs to the same value */ -boost_set_msrs (boost_enabled, cpu_online_mask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, + cpu_online_mask);register_cpu_notifier (&boost_nb);put_online_cpus (); - }else - global_boost.attr.mode =0444 ; - -/* We create the boost file in any case, though for systems without -* hardware support it will be read-only and hardwired to return 0. -*/ -if (cpufreq_sysfs_create_file (&(global_boost.attr))) -pr_warn (PFX "could not register global boost sysfs file\n" ); -else -pr_debug ("registered global boost sysfs file\n" ); + } } static void __exit acpi_cpufreq_boost_exit(void) { -cpufreq_sysfs_remove_file (&(global_boost.attr)); -if (msrs) {unregister_cpu_notifier (&boost_nb);
@@ -1015,12 +988,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init (); ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret; }
Signature · 1 line
1.7.10.4
Re: [PATCH v7 2/7] cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
Quoted 10 lines · Lukasz Majewski
The Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (
/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.The
_store_boost()function has been redesigned to be used asset_boostcallback.
Quoted 7 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v7:
- Remove superfluous acpi_cpufreq_driver.boost_supported = false atacpi_cpufreq_boost_init()
PATCH v7 3/7 thermal:boost: Automatic enable/disable of BOOST feature
In reply to Lukasz MajewskiThis patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.
---
Changes for v7:
- None
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost related thermal_zone_device struct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used when CONFIG_CPU_FREQ is NOT defined.
Changes for v5:
- Move boost disable code from cpu_cooling.c to thermal_core.c
(to handle_non_critical_trips)
- Extent struct thermal_zone_device by adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Changes for v4:
- New patch
drivers/thermal/thermal_core.c | 55 ++++++++++++++++++++++++++++++++++++++++ include/linux/cpufreq.h | 16 +++++++++++- include/linux/thermal.h | 2 ++ 3 files changed, 72 insertions(+), 1 deletion(-)
drivers/thermal/thermal_core.c +55 -0
@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h>
@@ -354,9 +355,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only +* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} +static void handle_thermal_trip (struct thermal_zone_device *tz,int trip) {enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);
@@ -455,6 +506,10 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }
include/linux/cpufreq.h +15 -1
@@ -408,10 +408,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +#ifdef CONFIG_CPU_FREQ int cpufreq_boost_trigger_state (int state);int cpufreq_boost_supported (void );int cpufreq_boost_enabled (void ); - +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following funtion is for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);
include/linux/thermal.h +2 -0
@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 1 line
1.7.10.4
Viresh Kumar
maintainerRe: [PATCH v7 3/7] thermal:boost: Automatic enable/disable of BOOST feature
Quoted 17 lines · Lukasz Majewski
include/linux/cpufreq.h +5
-1@@ -408,10 +408,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +#ifdef CONFIG_CPU_FREQ int cpufreq_boost_trigger_state (int state);int cpufreq_boost_supported (void );int cpufreq_boost_enabled (void ); - +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ;
include/linux/cpufreq.h int cpufreq_frequency_table_target(struct cpufreq_policy *policy, · line 428
Quoted 10 lines
include/linux/cpufreq.h +10
-0+} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif
I almost gave an Ack before I saw this :) This should be moved to the first patch I believe..
Re: [PATCH v7 3/7] thermal:boost: Automatic enable/disable of BOOST feature
On Mon, 26 Aug 2013 11:03:51 +0530 Viresh Kumar [email protected] wrote,
Quoted 25 lines
Quoted 23 lines · Lukasz Majewski
include/linux/cpufreq.h +0
-0@@ -408,10 +408,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy, void cpufreq_frequency_table_update_policy_cpu(struct
cpufreq_policy*policy);ssize_tcpufreq_show_cpus(const struct cpumask *mask, char *buf); +#ifdefCONFIG_CPU_FREQ
intcpufreq_boost_trigger_state(int state);
intcpufreq_boost_supported(void);
intcpufreq_boost_enabled(void);include/linux/cpufreq.h +9
-1- +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +}
Quoted 8 lines
include/linux/cpufreq.h int cpufreq_frequency_table_target(struct cpufreq_policy *policy, · line 428
Quoted 5 lines
include/linux/cpufreq.h +5
-0+static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif I almost gave an Ack before I saw this :) This should be moved to the first patch I believe..
Ok, I will move it there.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v7 4/7 cpufreq:boost:Kconfig: Provide support for software managed BOOST
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "EXYNOS Frequency Overclocking - Software" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v7:
- Remove superfluous "default n" definition
- Generic CPU_FREQ_BOOST_SW depends on THERMAL
Changes for v6:
- CPU_FREQ_BOOST_SW [1] is now defined as "invisible" bool option.
- Platform dependent ARM_EXYNOS_CPU_FREQ_BOOST_SW config option has been added. It depends on ARM_EXYNOS_CPUFREQ options and selects EXYNOS_THERMAL with the main boost config [1].
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 4 ++++ drivers/cpufreq/Kconfig.arm | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
drivers/cpufreq/Kconfig +4 -0
@@ -23,6 +23,10 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool + depends on THERMAL + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE
drivers/cpufreq/Kconfig.arm +15 -0
@@ -67,6 +67,21 @@ config ARM_EXYNOS5440_CPUFREQ If in doubt, say N. +config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. + config ARM_HIGHBANK_CPUFREQ tristate "Calxeda Highbank-based" depends on ARCH_HIGHBANK
Signature · 1 line
1.7.10.4
Re: [PATCH v7 4/7] cpufreq:boost:Kconfig: Provide support for software managed BOOST
Quoted 13 lines · Lukasz Majewski
For safety reasons new flag -
CONFIG_CPU_FREQ_BOOST_SWhas been added. Only after selecting "EXYNOS Frequency Overclocking - Software"Kconfigoption the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
Quoted 7 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v7:
- Remove superfluous "default n" definition
- GenericCPU_FREQ_BOOST_SWdepends on THERMAL
PATCH v7 5/7 cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Lukasz MajewskiThe cpufreq_driver's boost_supported flag is true only when boost support is explicitly enabled. Boost related attributes are exported only under the same condition.
---
Changes for v7:
- Replace CONFIG_CPU_FREQ_BOOST_SW with CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
- Move boost_supported initialization to struct cpufreq_driver exynos_driver
Changes for v6:
- Replace exynos_driver.boost_supported = 1 to = true
- Protect boost attributes export with CONFIG_CPU_FREQ_BOOST_SW
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Remove low level boost code
- Move boost management code to cpufreq core code
- Use boost_supported flag to indicate if driver supports over clocking
Changes for v2:
- Removal of struct cpufreq_boost
- Removal of the CONFIG_CPU_FREQ_BOOST flag
- low_level_boost with valid address when boost is supported
drivers/cpufreq/exynos-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/exynos-cpufreq.c +6 -0
@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + &cpufreq_freq_attr_scaling_boost_freqs, +#endifNULL , };
@@ -282,6 +285,9 @@ static struct cpufreq_driver exynos_driver = { .exit = exynos_cpufreq_cpu_exit, .name = "exynos_cpufreq", .attr = exynos_cpufreq_attr, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + .boost_supported = true, +#endif #ifdef CONFIG_PM .suspend = exynos_cpufreq_suspend, .resume = exynos_cpufreq_resume,
Signature · 1 line
1.7.10.4
Re: [PATCH v7 5/7] cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
Quoted 11 lines · Lukasz Majewski
The cpufreq_driver's
boost_supportedflag is true only when boost support is explicitly enabled. Boost related attributes are exported only under the same condition.Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v7:
- ReplaceCONFIG_CPU_FREQ_BOOST_SWwithCONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
- Moveboost_supportedinitialization to structcpufreq_driverexynos_driver
PATCH v7 6/7 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v7:
- None
Changes for v6:
- None
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
Re: [PATCH v7 6/7] Documentation:cpufreq:boost: Update BOOST documentation
Quoted 9 lines · Lukasz Majewski
Since the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v7:
- None
PATCH v7 7/7 cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
In reply to Lukasz MajewskiSpecial driver data flag (CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.
---
Changes for v7:
- None
Changes for v6:
- New patch
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/exynos4x12-cpufreq.c +1 -1
@@ -32,7 +32,7 @@ static unsigned int exynos4x12_volt_table[] = { };static struct cpufreq_frequency_table exynos4x12_freq_table[] = { - {L0 ,CPUFREQ_ENTRY_INVALID }, + {CPUFREQ_BOOST_FREQ ,1500 *1000 }, {L1 ,1400 *1000 }, {L2 ,1300 *1000 }, {L3 ,1200 *1000 },
Signature · 1 line
1.7.10.4
Re: [PATCH v7 7/7] cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Quoted 11 lines · Lukasz Majewski
Special driver data flag (
CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v7:
- None
Viresh Kumar
maintainerQuoted 49 lines · Lukasz Majewski
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. Thecpufreq_driveris responsibile for settingboost_supportedflag and providingset_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selected only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related fields:
--boost_supported- when driver supports boosting --boost_enabled- boost state
--set_boost- callback to function, which is necessary to
enable/disable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc4 Linux Intel Core i7-3770 3.11-rc4 LinuxAbove patches were posted on top of linux_pm/linux-next with following patches applied:
cpufreq: exynos5440: Fix to skip when new frequency same as current
cpufreq: fix EXYNOS drivers selection
Quoted 10 lines
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust theacpi-cpufreq.ccode to work with common
boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data toCPUFREQ_BOOST_FREQ
Hi Lukasz,
I haven't found time yet to go through this series.. I want to do a deep/careful review this time as these are almost the final patches.
Will try to get over them by the end of this week..
--
viresh
On Mon, 19 Aug 2013 12:08:26 +0530 Viresh Kumar [email protected] wrote,
Quoted 66 lines
Quoted 53 lines · Lukasz Majewski
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos). For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. Thecpufreq_driveris responsibile for settingboost_supportedflag and providingset_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selected only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related fields:
--boost_supported- when driver supports boosting --boost_enabled- boost state
--set_boost- callback to function, which is necessary to
enable/disable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc4 Linux Intel Core i7-3770 3.11-rc4 LinuxAbove patches were posted on top of linux_pm/linux-next with following patches applied:
cpufreq: exynos5440: Fix to skip when new frequency same as current
cpufreq: fix EXYNOS drivers selectionQuoted 10 lines
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust theacpi-cpufreq.ccode to work with
common boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data toCPUFREQ_BOOST_FREQ
Quoted 2 lines
Hi Lukasz,
Hi Viresh,
Quoted 1 line
I haven't found time yet to go through this series..
I've just started wondering if I had send those patches correctly :-).
Quoted 2 lines
I want to do a
deep/careful review this time as these are almost the final patches.
Ok.
Quoted 2 lines
Will try to get over them by the end of this week..
Ok, I understand.
Quoted 8 lines
--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Quoted 80 lines · Lukasz Majewski
On Mon, 19 Aug 2013 12:08:26 +0530 Viresh Kumar [email protected] wrote,
Quoted 66 lines
Quoted 53 lines · Lukasz Majewski
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos). For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. Thecpufreq_driveris responsibile for settingboost_supportedflag and providingset_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selected only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related fields:
--boost_supported- when driver supports boosting --boost_enabled- boost state
--set_boost- callback to function, which is necessary to
enable/disable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc4 Linux Intel Core i7-3770 3.11-rc4 LinuxAbove patches were posted on top of linux_pm/linux-next with following patches applied:
cpufreq: exynos5440: Fix to skip when new frequency same as current
cpufreq: fix EXYNOS drivers selectionQuoted 10 lines
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust theacpi-cpufreq.ccode to work with
common boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data toCPUFREQ_BOOST_FREQQuoted 2 lines
Hi Lukasz,
Hi Viresh,
Quoted 1 line
I haven't found time yet to go through this series..
I've just started wondering if I had send those patches correctly :-).
Quoted 2 lines
I want to do a
deep/careful review this time as these are almost the final patches.
Quoted 6 lines
Ok.
Quoted 2 lines
Will try to get over them by the end of this week..
Ok, I understand.
Do I assume correctly that this stuff has been tested on ACPI-compatible x86 with acpi-cpufreq and everything has worked correctly there?
Rafael
On Tue, 20 Aug 2013 01:29:20 +0200 Rafael J. Wysocki [email protected] wrote,
Quoted 89 lines · Lukasz Majewski
Quoted 88 lines
On Mon, 19 Aug 2013 12:08:26 +0530 Viresh Kumar
[email protected] wrote,Quoted 67 lines
Quoted 53 lines · Lukasz Majewski
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos). For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. Thecpufreq_driveris responsibile for settingboost_supportedflag and providingset_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selected only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related
fields: --boost_supported- when driver supports boosting
--boost_enabled- boost state
--set_boost- callback to function, which is necessary
to enable/disable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc4 Linux Intel Core i7-3770 3.11-rc4 LinuxAbove patches were posted on top of linux_pm/linux-next with following patches applied:
cpufreq: exynos5440: Fix to skip when new frequency same as current cpufreq: fix EXYNOS drivers selection
Quoted 11 lines
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust theacpi-cpufreq.ccode to work with
common boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed
BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data toCPUFREQ_BOOST_FREQQuoted 2 lines
Hi Lukasz,
Hi Viresh,
Quoted 1 line
I haven't found time yet to go through this series..
I've just started wondering if I had send those patches correctly :-).
Quoted 3 lines
I want to do a
deep/careful review this time as these are almost the final patches.Ok.
Quoted 2 lines
Will try to get over them by the end of this week..
Quoted 8 lines
Quoted 1 line
Ok, I understand.
Do I assume correctly that this stuff has been tested on ACPI-compatible x86 with acpi-cpufreq and everything has worked correctly there?
Rafael
Hi Rafael,
Following test configuration/test case (x86):
- DELL OptiPlex 9010 Intel Core i7-3770
- Linux repo: [kernel_pm_http/bleeding-edge] [kernel_pm_http/linux-next]
SHA1: a238ea5e20be7bea2b1fc951a024ecce770306b5 with v7 applied on top
- Linux version: 3.11-rc4 (patches v7) and 3.11-rc1 (v6)
- Ubuntu 11.10 (make bzImage + make all when module was needed)
- config_ubuntu_3_11 (the default one for ubuntu)
- KConfig:
1. Disabled intel_pstate driver
2. Enabled ACPI-Prosessor P state driver
3. Legacy cpb sysfs knob support for AMD CPUs ON/OFF (which is a part of acpi-cpufreq.c driver).
- acpi-cpufreq driver was build as a module or was embedded in kernel (tested with modprobe -i / -r => no dmesg error|warning output)
- I was able to read/write (echo 0/1
Quoted 1 line
/sys/devices/system/cpu/cpufreq/boost) => no output at dmesg -
system was working stable.
Toolchain: gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
Since I'm mostly working with ARM (exynos4412) and major work was done with cpufreq core (and x86 related work was to move common code to cpufreq core) tests mostly have been performed on ARM.
Tests on ARM:
- Stress tests with up to 4 scripts running to enable/disable boost sysfs attribute with random time interval (gzip < /dev/urandom
Quoted 1 line
/dev/null).
- Test to overheat the ARM target and look if boost+thermal cools down the device and enables boost again.
- LAB governor (which was already posted to ML) to boost when power envelope allows it.
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Quoted 131 lines · Lukasz Majewski
On Tue, 20 Aug 2013 01:29:20 +0200 Rafael J. Wysocki [email protected] wrote,
Quoted 89 lines · Lukasz Majewski
Quoted 88 lines
On Mon, 19 Aug 2013 12:08:26 +0530 Viresh Kumar
[email protected] wrote,Quoted 67 lines
Quoted 53 lines · Lukasz Majewski
This patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreqBoost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos). For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. Thecpufreq_driveris responsibile for settingboost_supportedflag and providingset_boostcallback(if HW support is needed). For software managed boost, specialKconfigflag -CONFIG_CPU_FREQ_BOOST_SWhas been defined. It will be selected only when a target platform has thermal framework properly configured.- struct
cpufreq_driverhas been extended with boost related
fields: --boost_supported- when driver supports boosting
--boost_enabled- boost state
--set_boost- callback to function, which is necessary
to enable/disable boost- Boost sysfs attribute (
/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.- No special
spin_lockfor Boost was created. The one from cpufreq core was reused.- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc4 Linux Intel Core i7-3770 3.11-rc4 LinuxAbove patches were posted on top of linux_pm/linux-next with following patches applied:
cpufreq: exynos5440: Fix to skip when new frequency same as current cpufreq: fix EXYNOS drivers selection
Quoted 11 lines
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust theacpi-cpufreq.ccode to work with
common boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed
BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data toCPUFREQ_BOOST_FREQQuoted 2 lines
Hi Lukasz,
Hi Viresh,
Quoted 1 line
I haven't found time yet to go through this series..
I've just started wondering if I had send those patches correctly :-).
Quoted 3 lines
I want to do a
deep/careful review this time as these are almost the final patches.Ok.
Quoted 2 lines
Will try to get over them by the end of this week..
Quoted 8 lines
Quoted 1 line
Ok, I understand.
Do I assume correctly that this stuff has been tested on ACPI-compatible x86 with acpi-cpufreq and everything has worked correctly there?
Rafael
Hi Rafael,
Following test configuration/test case (x86):
- DELL OptiPlex 9010 Intel Core i7-3770
- Linux repo: [kernel_pm_http/bleeding-edge] [kernel_pm_http/linux-next]SHA1: a238ea5e20be7bea2b1fc951a024ecce770306b5 with v7 applied on top- Linux version: 3.11-rc4 (patches v7) and 3.11-rc1 (v6)
- Ubuntu 11.10 (make bzImage + make all when module was needed)
-config_ubuntu_3_11(the default one for ubuntu)
- KConfig:
1. Disabledintel_pstatedriver
2. Enabled ACPI-Prosessor P state driver
3. Legacy cpb sysfs knob support for AMD CPUs ON/OFF (which is a part ofacpi-cpufreq.cdriver).- acpi-cpufreq driver was build as a module or was embedded in kernel (tested with modprobe -i / -r => no dmesg error|warning output)
- I was able to read/write (echo 0/1
Quoted 1 line
/sys/devices/system/cpu/cpufreq/boost) => no output at dmesg -system was working stable.
Toolchain: gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
Since I'm mostly working with ARM (exynos4412) and major work was done with cpufreq core (and x86 related work was to move common code to cpufreq core) tests mostly have been performed on ARM.
Quoted 8 lines
Tests on ARM:
- Stress tests with up to 4 scripts running to enable/disable boost sysfs attribute with random time interval (gzip </dev/urandomQuoted 1 line
/dev/null).- Test to overheat the ARM target and look if boost+thermal cools down the device and enables boost again.
- LAB governor (which was already posted to ML) to boost when power envelope allows it.
Great, thanks a lot for the info!
Rafael
v8 cover cpufreq:boost: CPU Boost mode support
In reply to Lukasz MajewskiThis patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreq
Boost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The cpufreq_driver is responsibile for setting boost_supported flag and providing set_boost callback(if HW support is needed). For software managed boost, special Kconfig flag - CONFIG_CPU_FREQ_BOOST_SW has been defined. It will be selected only when a target platform has thermal framework properly configured.
- struct cpufreq_driver has been extended with boost related fields:
-- boost_supported - when driver supports boosting -- boost_enabled - boost state
-- set_boost - callback to function, which is necessary to
enable/disable boost
- Boost sysfs attribute (/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.
- No special spin_lock for Boost was created. The one from cpufreq core was reused.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.11-rc6 Linux
Intel Core i7-3770 3.11-rc6 LinuxAbove patches were posted on top of linux_pm/linux-next (SHA1: 68327ee544d74f20bb6179637971912e5e78811c)
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common
boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Documentation/cpu-freq/boost.txt | 26 ++++---- drivers/cpufreq/Kconfig | 4 ++ drivers/cpufreq/Kconfig.arm | 15 +++++ drivers/cpufreq/acpi-cpufreq.c | 86 +++++++++---------------- drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++- drivers/cpufreq/exynos-cpufreq.c | 6 ++ drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- drivers/cpufreq/freq_table.c | 53 +++++++++++++-- drivers/thermal/thermal_core.c | 55 ++++++++++++++++ include/linux/cpufreq.h | 25 +++++++ include/linux/thermal.h | 2 + 11 files changed, 313 insertions(+), 79 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v8 1/7 cpufreq: Add boost frequency support in core
This commit adds boost frequency support in cpufreq core (Hardware & Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency above its normal operation limits. Such mode shall be only used for a short time.
Overclocking (boost) support is essentially provided by platform dependent cpufreq driver.
This commit unifies support for SW and HW (Intel) overclocking solutions in the core cpufreq driver. Previously the "boost" sysfs attribute was defined at acpi driver code. By default boost is disabled. One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.
It only shows up when cpufreq driver supports overclocking. Under the hood frequencies dedicated for boosting are marked with a special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table. It is the user's concern to enable/disable overclocking with a proper call to sysfs.
The cpufreq_boost_trigger_state() function is defined non static on purpose. It is used later with thermal subsystem to provide automatic enable/disable of the BOOST feature.
---
Changes for v8:
- Correction of error message at cpufreq_boost_trigger_state() function
- Rewrite the cpufreq_boost_set_sw() function to print error message and break the loop when policy adjustment fails
Changes for v7:
- Properly change cpufreq_driver->boost_enabled when set_boost() fails (=0 to =!state)
- Add likely() around cpufreq_driver
- Remove parenthesis around boost.attr
Changes for v6:
- Remove sysfs boost attribute when subsys_iterface_unregister() fails
- Move global boost_enabled variable from cpufreq.c to platform dependent struct cpufreq_driver
- pr_err() message is also printed when boost disable fails
- Call __cpufreq_governor() to force recalculation of next frequency when boost is triggered. It is needed with i.e. performance class of governors
- Change cpufreq_boost_enable_sw() -> cpufreq_boost_set_sw()
- Rename .enable_boost function pointer to .set_boost
Changes for v5:
- Rename cpufreq_boost_trigger_state_sw() to cpufreq_boost_enable_sw()
- Extent cpufreq_register_driver() to check if cpufreq driver provided boost_enable callback. If not provided, then use cpufreq_boost_enable_sw()
- Use single call to cpufreq_driver->enable_boost() with cpufreq driver provided callback or default SW boost enable routine
- Move pr_debug call to store_boost() from cpufreq_boost_trigger_state()
- Change the user_policy.max value when SW boost is toggled. It is necessary for proper operation of e.g. thermal subsystem.
- Add check if cpufreq_driver pointer is not NULL at cpufreq_boost_supported() routine
- Add EXPORT_SYMBOL_GPL for cpufreq_boost_supported() and cpufreq_boost_enabled()
- Remove extra check for cpufreq_boost_supported() at cpufreq_freq_table_cpuinfo()
- Explanation of show boost logic at show_available_freqs()
- Add cpufreq_set_boost_enabled() method to set initial value of boost_enabled global flag
Changes for v4:
- Remove boost parameter from cpufreq_frequency_table_cpuinfo() function
- Introduce cpufreq_boost_supported() method
- Use of cpufreq_boost_supported() and cpufreq_boost_enabled() to decide if frequency shall be skipped
- Rename set_boost_freq() to enable_boost()
- cpufreq_attr_available_freq() moved to freq_table.c
- Use policy list to get access to cpufreq policies
- Rename global boost flag (cpufreq_boost_enabled -> boost_enabled)
- pr_err corrected ( %sable)
- Remove sanity check at cpufreq_boost_trigger_state() entrance [to test if boost is supported]
- Use either HW (boost_enable) callback or SW managed boost
- Introduce new cpufreq_boost_trigger_state_sw() method to handle boost at SW.
- Protect boost_enabled manipulation with lock.
Changes for v3:
- Method for reading boost status
- Removal of cpufreq_frequency_table_max()
- Extent cpufreq_frequency_table_cpuinfo() to support boost parameter
- boost_supported flag added to cpufreq_driver struct
- "boost" sysfs attribute control flag removed
- One global flag describing state of the boost defined at cpufreq core
- Rename cpufreq_driver's low_level_boost field to set_boost_freq()
- Usage of cpufreq_sysfs_{remove|add}_file() routines
Changes for v2:
- Removal of cpufreq_boost structure and move its fields to cpufreq_driver structure
- Flag to indicate if global boost attribute is already defined
- Extent the pr_{err|debbug} functions to show current function names
drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/freq_table.c | 53 ++++++++++++++++--- include/linux/cpufreq.h | 25 +++++++++ 3 files changed, 188 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +117 -1
@@ -344,6 +344,33 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);/********************************************************************* * SYSFS INTERFACE * *********************************************************************/ +ssize_t show_boost (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" , cpufreq_driver->boost_enabled); +} + +static ssize_t store_boost (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t count) +{ +int ret, enable; + + ret =sscanf (buf,"%d" , &enable); +if (ret !=1 || enable <0 || enable >1 ) +return -EINVAL ; + +if (cpufreq_boost_trigger_state (enable)) { +pr_err ("%s: Cannot %s BOOST!\n" , __func__, + enable ?"enable" :"disable" ); +return -EINVAL ; + } + +pr_debug ("%s: cpufreq BOOST %s\n" , __func__, + enable ?"enabled" :"disabled" ); + +return count; +} +define_one_global_rw (boost);static struct cpufreq_governor *__find_governor (const char *str_governor) {
@@ -2010,6 +2037,73 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { };/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (ret) { +pr_err ("%s: Policy frequency update failed\n" , + __func__); +break ; + } + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enable" :"disable" ); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (likely (cpufreq_driver)) +return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
@@ -2048,9 +2142,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if driver provides function to enable boost - +* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&boost.attr); +if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
@@ -2077,6 +2187,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;
@@ -2103,6 +2216,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); +unregister_hotcpu_notifier (&cpufreq_cpu_notifier);down_write (&cpufreq_rwsem);
drivers/cpufreq/freq_table.c +46 -7
79 lines not on this page · raw message
include/linux/cpufreq.h +25 -0
@@ -209,6 +209,11 @@ struct cpufreq_driver {int (*suspend) (struct cpufreq_policy *policy);int (*resume) (struct cpufreq_policy *policy);struct freq_attr **attr; + +/* platform specific boost support code */ +bool boost_supported; +bool boost_enabled; +int (*set_boost) (int state); };/* flags */
@@ -381,6 +386,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;#define CPUFREQ_ENTRY_INVALID ~0#define CPUFREQ_TABLE_END ~1 +#define CPUFREQ_BOOST_FREQ ~2struct cpufreq_frequency_table {unsigned int driver_data;/* driver specific data, not used by core */
@@ -403,11 +409,30 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +#ifdef CONFIG_CPU_FREQ +int cpufreq_boost_trigger_state (int state); +int cpufreq_boost_supported (void ); +int cpufreq_boost_enabled (void ); +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following funtion is for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);/* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; +extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;void cpufreq_frequency_table_get_attr (struct cpufreq_frequency_table *table,unsigned int cpu);void cpufreq_frequency_table_put_attr (unsigned int cpu);
Signature · 1 line
1.7.10.4
PATCH v8 2/7 cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Lukasz MajewskiThe Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.
The _store_boost() function has been redesigned to be used as set_boost callback.
---
Changes for v8:
- None
Changes for v7:
- Remove superfluous acpi_cpufreq_driver.boost_supported = false at acpi_cpufreq_boost_init()
Changes for v6:
- Perform acpi_cpufreq_boost_init initialization before cpufreq_driver registration
- Compile store_boost() only when CONFIG_X86_ACPI_CPUFREQ_CPB defined
- Use boost_enabled flag defined at acpi_cpufreq_driver to store information about boost state
- Instead of using cpufreq_set_boost_enabled(), modify the boost_enable in the acpi driver code
Changes for v5:
- Remove acpi-cpufreq's boost_enabled global flag and reuse one defined at cpufreq core
Changes for v4:
- add _store_boost to acpi_cpufreq_driver structure
Changes for v3:
- Bring back boost_enabled as a global flag
- Move boost_supported to cpufreq_driver structure
Changes for v2:
- Replace boost_enabled and boost_supported global flags with proper entries at struct cpufreq_driver.
- Removal of struct cpufreq_boost
drivers/cpufreq/acpi-cpufreq.c | 86 ++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 57 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +29 -57
@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;static struct cpufreq_driver acpi_cpufreq_driver;static unsigned int acpi_pstate_strict; -static bool boost_enabled, boost_supported;static struct msr __percpu *msrs;static bool boost_state (unsigned int cpu)
@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static ssize_t _store_boost (const char *buf,size_t count) +static int _store_boost (int val) { -int ret; -unsigned long val =0 ; - -if (!boost_supported) -return -EINVAL ; - - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) -return -EINVAL ; - -if ((val && boost_enabled) || (!val && !boost_enabled)) -return count; -get_online_cpus (); -boost_set_msrs (val, cpu_online_mask); -put_online_cpus (); - - boost_enabled = val;pr_debug ("Core Boosting %sabled.\n" , val ?"en" :"dis" ); -return count; -} - -static ssize_t store_global_boost (struct kobject *kobj,struct attribute *attr, -const char *buf,size_t count) -{ -return _store_boost (buf, count); -} - -static ssize_t show_global_boost (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -return sprintf (buf,"%u\n" , boost_enabled); +return 0 ; } -static struct global_attr global_boost =__ATTR (boost,0644 , - show_global_boost, - store_global_boost); -static ssize_t show_freqdomain_cpus (struct cpufreq_policy *policy,char *buf) {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);
@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)cpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB +static ssize_t store_boost (const char *buf,size_t count) +{ +int ret; +unsigned long val =0 ; + +if (!acpi_cpufreq_driver.boost_supported) +return -EINVAL ; + + ret =kstrtoul (buf,10 , &val); +if (ret || (val >1 )) +return -EINVAL ; + +_store_boost ((int ) val); + +return count; +} +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -return _store_boost (buf, count); +return store_boost (buf, count); }static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) { -return sprintf (buf,"%u\n" , boost_enabled); +return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled); }cpufreq_freq_attr_rw (cpb);
@@ -582,7 +565,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,switch (action) {case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN : -boost_set_msrs (boost_enabled, cpumask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, cpumask);break ;case CPU_DOWN_PREPARE :
@@ -937,6 +920,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, + .set_boost = _store_boost, };static void __init acpi_cpufreq_boost_init (void )
@@ -947,33 +931,22 @@ static void __init acpi_cpufreq_boost_init(void)if (!msrs)return ; - boost_supported = true; - boost_enabled =boost_state (0 ); - + acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.boost_enabled =boost_state (0 );get_online_cpus ();/* Force all MSRs to the same value */ -boost_set_msrs (boost_enabled, cpu_online_mask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, + cpu_online_mask);register_cpu_notifier (&boost_nb);put_online_cpus (); - }else - global_boost.attr.mode =0444 ; - -/* We create the boost file in any case, though for systems without -* hardware support it will be read-only and hardwired to return 0. -*/ -if (cpufreq_sysfs_create_file (&(global_boost.attr))) -pr_warn (PFX "could not register global boost sysfs file\n" ); -else -pr_debug ("registered global boost sysfs file\n" ); + } } static void __exit acpi_cpufreq_boost_exit(void) { -cpufreq_sysfs_remove_file (&(global_boost.attr)); -if (msrs) {unregister_cpu_notifier (&boost_nb);
@@ -1015,12 +988,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init (); ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret; }
Signature · 1 line
1.7.10.4
PATCH v8 3/7 thermal:boost: Automatic enable/disable of BOOST feature
In reply to Lukasz MajewskiThis patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.
---
Changes for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) to cpufreq.h at cpufreq core support commit
Changes for v7:
- None
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost related thermal_zone_device struct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used when CONFIG_CPU_FREQ is NOT defined.
Changes for v5:
- Move boost disable code from cpu_cooling.c to thermal_core.c
(to handle_non_critical_trips)
- Extent struct thermal_zone_device by adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Changes for v4:
- New patch
drivers/thermal/thermal_core.c | 55 ++++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 57 insertions(+)
drivers/thermal/thermal_core.c +55 -0
@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h>
@@ -354,9 +355,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only +* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} +static void handle_thermal_trip (struct thermal_zone_device *tz,int trip) {enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);
@@ -455,6 +506,10 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }
include/linux/thermal.h +2 -0
@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 1 line
1.7.10.4
PATCH v8 4/7 cpufreq:boost:Kconfig: Provide support for software managed BOOST
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "EXYNOS Frequency Overclocking - Software" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v8:
- None
Changes for v7:
- Remove superfluous "default n" definition
- Generic CPU_FREQ_BOOST_SW depends on THERMAL
Changes for v6:
- CPU_FREQ_BOOST_SW [1] is now defined as "invisible" bool option.
- Platform dependent ARM_EXYNOS_CPU_FREQ_BOOST_SW config option has been added. It depends on ARM_EXYNOS_CPUFREQ options and selects EXYNOS_THERMAL with the main boost config [1].
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 4 ++++ drivers/cpufreq/Kconfig.arm | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
drivers/cpufreq/Kconfig +4 -0
@@ -23,6 +23,10 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool + depends on THERMAL + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE
drivers/cpufreq/Kconfig.arm +15 -0
@@ -67,6 +67,21 @@ config ARM_EXYNOS5440_CPUFREQ If in doubt, say N. +config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. + config ARM_HIGHBANK_CPUFREQ tristate "Calxeda Highbank-based" depends on ARCH_HIGHBANK
Signature · 1 line
1.7.10.4
PATCH v8 5/7 cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Lukasz MajewskiThe cpufreq_driver's boost_supported flag is true only when boost support is explicitly enabled. Boost related attributes are exported only under the same condition.
---
Changes for v8:
- None
Changes for v7:
- Replace CONFIG_CPU_FREQ_BOOST_SW with CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
- Move boost_supported initialization to struct cpufreq_driver exynos_driver
Changes for v6:
- Replace exynos_driver.boost_supported = 1 to = true
- Protect boost attributes export with CONFIG_CPU_FREQ_BOOST_SW
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Remove low level boost code
- Move boost management code to cpufreq core code
- Use boost_supported flag to indicate if driver supports over clocking
Changes for v2:
- Removal of struct cpufreq_boost
- Removal of the CONFIG_CPU_FREQ_BOOST flag
- low_level_boost with valid address when boost is supported
drivers/cpufreq/exynos-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/exynos-cpufreq.c +6 -0
@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + &cpufreq_freq_attr_scaling_boost_freqs, +#endifNULL , };
@@ -282,6 +285,9 @@ static struct cpufreq_driver exynos_driver = { .exit = exynos_cpufreq_cpu_exit, .name = "exynos_cpufreq", .attr = exynos_cpufreq_attr, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + .boost_supported = true, +#endif #ifdef CONFIG_PM .suspend = exynos_cpufreq_suspend, .resume = exynos_cpufreq_resume,
Signature · 1 line
1.7.10.4
PATCH v8 6/7 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- None
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
PATCH v8 7/7 cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
In reply to Lukasz MajewskiSpecial driver data flag (CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.
---
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- New patch
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/exynos4x12-cpufreq.c +1 -1
@@ -32,7 +32,7 @@ static unsigned int exynos4x12_volt_table[] = { };static struct cpufreq_frequency_table exynos4x12_freq_table[] = { - {L0 ,CPUFREQ_ENTRY_INVALID }, + {CPUFREQ_BOOST_FREQ ,1500 *1000 }, {L1 ,1400 *1000 }, {L2 ,1300 *1000 }, {L3 ,1200 *1000 },
Signature · 1 line
1.7.10.4
v8 cover cpufreq:boost: CPU Boost mode support
In reply to Lukasz MajewskiThis patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreq
Boost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The cpufreq_driver is responsibile for setting boost_supported flag and providing set_boost callback(if HW support is needed). For software managed boost, special Kconfig flag - CONFIG_CPU_FREQ_BOOST_SW has been defined. It will be selected only when a target platform has thermal framework properly configured.
- struct cpufreq_driver has been extended with boost related fields:
-- boost_supported - when driver supports boosting -- boost_enabled - boost state
-- set_boost - callback to function, which is necessary to
enable/disable boost
- Boost sysfs attribute (/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.
- No special spin_lock for Boost was created. The one from cpufreq core was reused.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 (TRATS2) 3.12-rc1 Linux
Intel Core i7-3770 3.12-rc1 LinuxAbove patches were posted on top of linux_pm/linux-next
SHA1: cf8bc6460f2137412081ba26d18932f20cb856fd
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common
boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Documentation/cpu-freq/boost.txt | 26 ++++---- drivers/cpufreq/Kconfig | 4 ++ drivers/cpufreq/Kconfig.arm | 15 +++++ drivers/cpufreq/acpi-cpufreq.c | 86 +++++++++---------------- drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++- drivers/cpufreq/exynos-cpufreq.c | 6 ++ drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- drivers/cpufreq/freq_table.c | 53 +++++++++++++-- drivers/thermal/thermal_core.c | 55 ++++++++++++++++ include/linux/cpufreq.h | 25 +++++++ include/linux/thermal.h | 2 + 11 files changed, 313 insertions(+), 79 deletions(-)
Signature · 1 line
1.7.10.4
PATCH RESEND v8 1/7 cpufreq: Add boost frequency support in core
This commit adds boost frequency support in cpufreq core (Hardware & Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency above its normal operation limits. Such mode shall be only used for a short time.
Overclocking (boost) support is essentially provided by platform dependent cpufreq driver.
This commit unifies support for SW and HW (Intel) overclocking solutions in the core cpufreq driver. Previously the "boost" sysfs attribute was defined at acpi driver code. By default boost is disabled. One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.
It only shows up when cpufreq driver supports overclocking. Under the hood frequencies dedicated for boosting are marked with a special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table. It is the user's concern to enable/disable overclocking with a proper call to sysfs.
The cpufreq_boost_trigger_state() function is defined non static on purpose. It is used later with thermal subsystem to provide automatic enable/disable of the BOOST feature.
---
Changes for v8:
- Correction of error message at cpufreq_boost_trigger_state() function
- Rewrite the cpufreq_boost_set_sw() function to print error message and break the loop when policy adjustment fails
Changes for v7:
- Properly change cpufreq_driver->boost_enabled when set_boost() fails (=0 to =!state)
- Add likely() around cpufreq_driver
- Remove parenthesis around boost.attr
Changes for v6:
- Remove sysfs boost attribute when subsys_iterface_unregister() fails
- Move global boost_enabled variable from cpufreq.c to platform dependent struct cpufreq_driver
- pr_err() message is also printed when boost disable fails
- Call __cpufreq_governor() to force recalculation of next frequency when boost is triggered. It is needed with i.e. performance class of governors
- Change cpufreq_boost_enable_sw() -> cpufreq_boost_set_sw()
- Rename .enable_boost function pointer to .set_boost
Changes for v5:
- Rename cpufreq_boost_trigger_state_sw() to cpufreq_boost_enable_sw()
- Extent cpufreq_register_driver() to check if cpufreq driver provided boost_enable callback. If not provided, then use cpufreq_boost_enable_sw()
- Use single call to cpufreq_driver->enable_boost() with cpufreq driver provided callback or default SW boost enable routine
- Move pr_debug call to store_boost() from cpufreq_boost_trigger_state()
- Change the user_policy.max value when SW boost is toggled. It is necessary for proper operation of e.g. thermal subsystem.
- Add check if cpufreq_driver pointer is not NULL at cpufreq_boost_supported() routine
- Add EXPORT_SYMBOL_GPL for cpufreq_boost_supported() and cpufreq_boost_enabled()
- Remove extra check for cpufreq_boost_supported() at cpufreq_freq_table_cpuinfo()
- Explanation of show boost logic at show_available_freqs()
- Add cpufreq_set_boost_enabled() method to set initial value of boost_enabled global flag
Changes for v4:
- Remove boost parameter from cpufreq_frequency_table_cpuinfo() function
- Introduce cpufreq_boost_supported() method
- Use of cpufreq_boost_supported() and cpufreq_boost_enabled() to decide if frequency shall be skipped
- Rename set_boost_freq() to enable_boost()
- cpufreq_attr_available_freq() moved to freq_table.c
- Use policy list to get access to cpufreq policies
- Rename global boost flag (cpufreq_boost_enabled -> boost_enabled)
- pr_err corrected ( %sable)
- Remove sanity check at cpufreq_boost_trigger_state() entrance [to test if boost is supported]
- Use either HW (boost_enable) callback or SW managed boost
- Introduce new cpufreq_boost_trigger_state_sw() method to handle boost at SW.
- Protect boost_enabled manipulation with lock.
Changes for v3:
- Method for reading boost status
- Removal of cpufreq_frequency_table_max()
- Extent cpufreq_frequency_table_cpuinfo() to support boost parameter
- boost_supported flag added to cpufreq_driver struct
- "boost" sysfs attribute control flag removed
- One global flag describing state of the boost defined at cpufreq core
- Rename cpufreq_driver's low_level_boost field to set_boost_freq()
- Usage of cpufreq_sysfs_{remove|add}_file() routines
Changes for v2:
- Removal of cpufreq_boost structure and move its fields to cpufreq_driver structure
- Flag to indicate if global boost attribute is already defined
- Extent the pr_{err|debbug} functions to show current function names
drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/freq_table.c | 53 ++++++++++++++++--- include/linux/cpufreq.h | 25 +++++++++ 3 files changed, 188 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +117 -1
@@ -344,6 +344,33 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);/********************************************************************* * SYSFS INTERFACE * *********************************************************************/ +ssize_t show_boost (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" , cpufreq_driver->boost_enabled); +} + +static ssize_t store_boost (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t count) +{ +int ret, enable; + + ret =sscanf (buf,"%d" , &enable); +if (ret !=1 || enable <0 || enable >1 ) +return -EINVAL ; + +if (cpufreq_boost_trigger_state (enable)) { +pr_err ("%s: Cannot %s BOOST!\n" , __func__, + enable ?"enable" :"disable" ); +return -EINVAL ; + } + +pr_debug ("%s: cpufreq BOOST %s\n" , __func__, + enable ?"enabled" :"disabled" ); + +return count; +} +define_one_global_rw (boost);static struct cpufreq_governor *__find_governor (const char *str_governor) {
@@ -2010,6 +2037,73 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { };/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (ret) { +pr_err ("%s: Policy frequency update failed\n" , + __func__); +break ; + } + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enable" :"disable" ); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (likely (cpufreq_driver)) +return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
@@ -2048,9 +2142,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if driver provides function to enable boost - +* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&boost.attr); +if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
@@ -2077,6 +2187,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;
@@ -2103,6 +2216,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); +unregister_hotcpu_notifier (&cpufreq_cpu_notifier);down_write (&cpufreq_rwsem);
drivers/cpufreq/freq_table.c +46 -7
79 lines not on this page · raw message
include/linux/cpufreq.h +25 -0
@@ -209,6 +209,11 @@ struct cpufreq_driver {int (*suspend) (struct cpufreq_policy *policy);int (*resume) (struct cpufreq_policy *policy);struct freq_attr **attr; + +/* platform specific boost support code */ +bool boost_supported; +bool boost_enabled; +int (*set_boost) (int state); };/* flags */
@@ -381,6 +386,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;#define CPUFREQ_ENTRY_INVALID ~0#define CPUFREQ_TABLE_END ~1 +#define CPUFREQ_BOOST_FREQ ~2struct cpufreq_frequency_table {unsigned int driver_data;/* driver specific data, not used by core */
@@ -403,11 +409,30 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +#ifdef CONFIG_CPU_FREQ +int cpufreq_boost_trigger_state (int state); +int cpufreq_boost_supported (void ); +int cpufreq_boost_enabled (void ); +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following funtion is for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);/* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; +extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs;void cpufreq_frequency_table_get_attr (struct cpufreq_frequency_table *table,unsigned int cpu);void cpufreq_frequency_table_put_attr (unsigned int cpu);
Signature · 1 line
1.7.10.4
PATCH RESEND v8 2/7 cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Lukasz MajewskiThe Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.
The _store_boost() function has been redesigned to be used as set_boost callback.
---
Changes for v8:
- None
Changes for v7:
- Remove superfluous acpi_cpufreq_driver.boost_supported = false at acpi_cpufreq_boost_init()
Changes for v6:
- Perform acpi_cpufreq_boost_init initialization before cpufreq_driver registration
- Compile store_boost() only when CONFIG_X86_ACPI_CPUFREQ_CPB defined
- Use boost_enabled flag defined at acpi_cpufreq_driver to store information about boost state
- Instead of using cpufreq_set_boost_enabled(), modify the boost_enable in the acpi driver code
Changes for v5:
- Remove acpi-cpufreq's boost_enabled global flag and reuse one defined at cpufreq core
Changes for v4:
- add _store_boost to acpi_cpufreq_driver structure
Changes for v3:
- Bring back boost_enabled as a global flag
- Move boost_supported to cpufreq_driver structure
Changes for v2:
- Replace boost_enabled and boost_supported global flags with proper entries at struct cpufreq_driver.
- Removal of struct cpufreq_boost
drivers/cpufreq/acpi-cpufreq.c | 86 ++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 57 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +29 -57
@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;static struct cpufreq_driver acpi_cpufreq_driver;static unsigned int acpi_pstate_strict; -static bool boost_enabled, boost_supported;static struct msr __percpu *msrs;static bool boost_state (unsigned int cpu)
@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static ssize_t _store_boost (const char *buf,size_t count) +static int _store_boost (int val) { -int ret; -unsigned long val =0 ; - -if (!boost_supported) -return -EINVAL ; - - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) -return -EINVAL ; - -if ((val && boost_enabled) || (!val && !boost_enabled)) -return count; -get_online_cpus (); -boost_set_msrs (val, cpu_online_mask); -put_online_cpus (); - - boost_enabled = val;pr_debug ("Core Boosting %sabled.\n" , val ?"en" :"dis" ); -return count; -} - -static ssize_t store_global_boost (struct kobject *kobj,struct attribute *attr, -const char *buf,size_t count) -{ -return _store_boost (buf, count); -} - -static ssize_t show_global_boost (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -return sprintf (buf,"%u\n" , boost_enabled); +return 0 ; } -static struct global_attr global_boost =__ATTR (boost,0644 , - show_global_boost, - store_global_boost); -static ssize_t show_freqdomain_cpus (struct cpufreq_policy *policy,char *buf) {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);
@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)cpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB +static ssize_t store_boost (const char *buf,size_t count) +{ +int ret; +unsigned long val =0 ; + +if (!acpi_cpufreq_driver.boost_supported) +return -EINVAL ; + + ret =kstrtoul (buf,10 , &val); +if (ret || (val >1 )) +return -EINVAL ; + +_store_boost ((int ) val); + +return count; +} +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -return _store_boost (buf, count); +return store_boost (buf, count); }static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) { -return sprintf (buf,"%u\n" , boost_enabled); +return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled); }cpufreq_freq_attr_rw (cpb);
@@ -582,7 +565,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,switch (action) {case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN : -boost_set_msrs (boost_enabled, cpumask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, cpumask);break ;case CPU_DOWN_PREPARE :
@@ -937,6 +920,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, + .set_boost = _store_boost, };static void __init acpi_cpufreq_boost_init (void )
@@ -947,33 +931,22 @@ static void __init acpi_cpufreq_boost_init(void)if (!msrs)return ; - boost_supported = true; - boost_enabled =boost_state (0 ); - + acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.boost_enabled =boost_state (0 );get_online_cpus ();/* Force all MSRs to the same value */ -boost_set_msrs (boost_enabled, cpu_online_mask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, + cpu_online_mask);register_cpu_notifier (&boost_nb);put_online_cpus (); - }else - global_boost.attr.mode =0444 ; - -/* We create the boost file in any case, though for systems without -* hardware support it will be read-only and hardwired to return 0. -*/ -if (cpufreq_sysfs_create_file (&(global_boost.attr))) -pr_warn (PFX "could not register global boost sysfs file\n" ); -else -pr_debug ("registered global boost sysfs file\n" ); + } } static void __exit acpi_cpufreq_boost_exit(void) { -cpufreq_sysfs_remove_file (&(global_boost.attr)); -if (msrs) {unregister_cpu_notifier (&boost_nb);
@@ -1015,12 +988,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init (); ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret; }
Signature · 1 line
1.7.10.4
PATCH RESEND v8 3/7 thermal:boost: Automatic enable/disable of BOOST feature
In reply to Lukasz MajewskiThis patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.
---
Changes for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) to cpufreq.h at cpufreq core support commit
Changes for v7:
- None
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost related thermal_zone_device struct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used when CONFIG_CPU_FREQ is NOT defined.
Changes for v5:
- Move boost disable code from cpu_cooling.c to thermal_core.c
(to handle_non_critical_trips)
- Extent struct thermal_zone_device by adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Changes for v4:
- New patch
drivers/thermal/thermal_core.c | 55 ++++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 57 insertions(+)
drivers/thermal/thermal_core.c +55 -0
@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h>
@@ -354,9 +355,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only +* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} +static void handle_thermal_trip (struct thermal_zone_device *tz,int trip) {enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);
@@ -455,6 +506,10 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }
include/linux/thermal.h +2 -0
@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 1 line
1.7.10.4
PATCH RESEND v8 4/7 cpufreq:boost:Kconfig: Provide support for software managed BOOST
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "EXYNOS Frequency Overclocking - Software" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v8:
- None
Changes for v7:
- Remove superfluous "default n" definition
- Generic CPU_FREQ_BOOST_SW depends on THERMAL
Changes for v6:
- CPU_FREQ_BOOST_SW [1] is now defined as "invisible" bool option.
- Platform dependent ARM_EXYNOS_CPU_FREQ_BOOST_SW config option has been added. It depends on ARM_EXYNOS_CPUFREQ options and selects EXYNOS_THERMAL with the main boost config [1].
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 4 ++++ drivers/cpufreq/Kconfig.arm | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
drivers/cpufreq/Kconfig +4 -0
@@ -23,6 +23,10 @@ config CPU_FREQ_TABLE config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool + depends on THERMAL + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" select CPU_FREQ_TABLE
drivers/cpufreq/Kconfig.arm +15 -0
@@ -67,6 +67,21 @@ config ARM_EXYNOS5440_CPUFREQ If in doubt, say N. +config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. + config ARM_HIGHBANK_CPUFREQ tristate "Calxeda Highbank-based" depends on ARCH_HIGHBANK
Signature · 1 line
1.7.10.4
PATCH RESEND v8 5/7 cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Lukasz MajewskiThe cpufreq_driver's boost_supported flag is true only when boost support is explicitly enabled. Boost related attributes are exported only under the same condition.
---
Changes for v8:
- None
Changes for v7:
- Replace CONFIG_CPU_FREQ_BOOST_SW with CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
- Move boost_supported initialization to struct cpufreq_driver exynos_driver
Changes for v6:
- Replace exynos_driver.boost_supported = 1 to = true
- Protect boost attributes export with CONFIG_CPU_FREQ_BOOST_SW
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Remove low level boost code
- Move boost management code to cpufreq core code
- Use boost_supported flag to indicate if driver supports over clocking
Changes for v2:
- Removal of struct cpufreq_boost
- Removal of the CONFIG_CPU_FREQ_BOOST flag
- low_level_boost with valid address when boost is supported
drivers/cpufreq/exynos-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/cpufreq/exynos-cpufreq.c +6 -0
@@ -270,6 +270,9 @@ static int exynos_cpufreq_cpu_exit(struct cpufreq_policy *policy)static struct freq_attr *exynos_cpufreq_attr[] = { &cpufreq_freq_attr_scaling_available_freqs, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + &cpufreq_freq_attr_scaling_boost_freqs, +#endifNULL , };
@@ -282,6 +285,9 @@ static struct cpufreq_driver exynos_driver = { .exit = exynos_cpufreq_cpu_exit, .name = "exynos_cpufreq", .attr = exynos_cpufreq_attr, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + .boost_supported = true, +#endif #ifdef CONFIG_PM .suspend = exynos_cpufreq_suspend, .resume = exynos_cpufreq_resume,
Signature · 1 line
1.7.10.4
PATCH RESEND v8 6/7 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- None
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
PATCH RESEND v8 7/7 cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
In reply to Lukasz MajewskiSpecial driver data flag (CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.
---
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- New patch
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/exynos4x12-cpufreq.c +1 -1
@@ -32,7 +32,7 @@ static unsigned int exynos4x12_volt_table[] = { };static struct cpufreq_frequency_table exynos4x12_freq_table[] = { - {L0 ,CPUFREQ_ENTRY_INVALID }, + {CPUFREQ_BOOST_FREQ ,1500 *1000 }, {L1 ,1400 *1000 }, {L2 ,1300 *1000 }, {L3 ,1200 *1000 },
Signature · 1 line
1.7.10.4
v9 cover cpufreq:boost: CPU Boost mode support
In reply to Lukasz MajewskiThis patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreq
Boost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The cpufreq_driver is responsibile for setting boost_supported flag and providing set_boost callback(if HW support is needed). For software managed boost, special Kconfig flag - CONFIG_CPU_FREQ_BOOST_SW has been defined. It will be selected only when a target platform has thermal framework properly configured.
- struct cpufreq_driver has been extended with boost related fields:
-- boost_supported - when driver supports boosting -- boost_enabled - boost state
-- set_boost - callback to function, which is necessary to
enable/disable boost
- Boost sysfs attribute (/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.
- No special spin_lock for Boost was created. The one from cpufreq core was reused.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. Then it starts monitoring target temperature to evaluate if boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.12-rc4 Linux
Intel Core i7-3770 3.12-rc4 LinuxAbove patches were posted on top of kernel_pm/bleeding-edge (SHA1: d06a5fe3485062acdb5552dffe3a89672e1a439d)
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common
boost solution
thermal:boost: Automatic enable/disable of BOOST feature cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
Documentation/cpu-freq/boost.txt | 26 ++++---- drivers/cpufreq/Kconfig | 4 ++ drivers/cpufreq/Kconfig.arm | 15 +++++ drivers/cpufreq/acpi-cpufreq.c | 86 +++++++++---------------- drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++- drivers/cpufreq/exynos-cpufreq.c | 3 + drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- drivers/cpufreq/freq_table.c | 56 ++++++++++++++-- drivers/thermal/thermal_core.c | 55 ++++++++++++++++ include/linux/cpufreq.h | 24 +++++++ include/linux/thermal.h | 2 + 11 files changed, 312 insertions(+), 79 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v9 1/7 cpufreq: Add boost frequency support in core
This commit adds boost frequency support in cpufreq core (Hardware & Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency above its normal operation limits. Such mode shall be only used for a short time.
Overclocking (boost) support is essentially provided by platform dependent cpufreq driver.
This commit unifies support for SW and HW (Intel) overclocking solutions in the core cpufreq driver. Previously the "boost" sysfs attribute was defined at acpi driver code. By default boost is disabled. One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.
It only shows up when cpufreq driver supports overclocking. Under the hood frequencies dedicated for boosting are marked with a special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table. It is the user's concern to enable/disable overclocking with a proper call to sysfs.
The cpufreq_boost_trigger_state() function is defined non static on purpose. It is used later with thermal subsystem to provide automatic enable/disable of the BOOST feature.
---
Changes for v9:
- Add cpufreq_freq_attr_scaling_boost_freqs to *cpufreq_generic_attr table
- Introduce CONFIG_CPU_FREQ_BOOST_SW generic config flag to show BOOST frequencies only when cpufreq driver supports boost
Changes for v8:
- Correction of error message at cpufreq_boost_trigger_state() function
- Rewrite the cpufreq_boost_set_sw() function to print error message and break the loop when policy adjustment fails
Changes for v7:
- Properly change cpufreq_driver->boost_enabled when set_boost() fails (=0 to =!state)
- Add likely() around cpufreq_driver
- Remove parenthesis around boost.attr
Changes for v6:
- Remove sysfs boost attribute when subsys_iterface_unregister() fails
- Move global boost_enabled variable from cpufreq.c to platform dependent struct cpufreq_driver
- pr_err() message is also printed when boost disable fails
- Call __cpufreq_governor() to force recalculation of next frequency when boost is triggered. It is needed with i.e. performance class of governors
- Change cpufreq_boost_enable_sw() -> cpufreq_boost_set_sw()
- Rename .enable_boost function pointer to .set_boost
Changes for v5:
- Rename cpufreq_boost_trigger_state_sw() to cpufreq_boost_enable_sw()
- Extent cpufreq_register_driver() to check if cpufreq driver provided boost_enable callback. If not provided, then use cpufreq_boost_enable_sw()
- Use single call to cpufreq_driver->enable_boost() with cpufreq driver provided callback or default SW boost enable routine
- Move pr_debug call to store_boost() from cpufreq_boost_trigger_state()
- Change the user_policy.max value when SW boost is toggled. It is necessary for proper operation of e.g. thermal subsystem.
- Add check if cpufreq_driver pointer is not NULL at cpufreq_boost_supported() routine
- Add EXPORT_SYMBOL_GPL for cpufreq_boost_supported() and cpufreq_boost_enabled()
- Remove extra check for cpufreq_boost_supported() at cpufreq_freq_table_cpuinfo()
- Explanation of show boost logic at show_available_freqs()
- Add cpufreq_set_boost_enabled() method to set initial value of boost_enabled global flag
Changes for v4:
- Remove boost parameter from cpufreq_frequency_table_cpuinfo() function
- Introduce cpufreq_boost_supported() method
- Use of cpufreq_boost_supported() and cpufreq_boost_enabled() to decide if frequency shall be skipped
- Rename set_boost_freq() to enable_boost()
- cpufreq_attr_available_freq() moved to freq_table.c
- Use policy list to get access to cpufreq policies
- Rename global boost flag (cpufreq_boost_enabled -> boost_enabled)
- pr_err corrected ( %sable)
- Remove sanity check at cpufreq_boost_trigger_state() entrance [to test if boost is supported]
- Use either HW (boost_enable) callback or SW managed boost
- Introduce new cpufreq_boost_trigger_state_sw() method to handle boost at SW.
- Protect boost_enabled manipulation with lock.
Changes for v3:
- Method for reading boost status
- Removal of cpufreq_frequency_table_max()
- Extent cpufreq_frequency_table_cpuinfo() to support boost parameter
- boost_supported flag added to cpufreq_driver struct
- "boost" sysfs attribute control flag removed
- One global flag describing state of the boost defined at cpufreq core
- Rename cpufreq_driver's low_level_boost field to set_boost_freq()
- Usage of cpufreq_sysfs_{remove|add}_file() routines
Changes for v2:
- Removal of cpufreq_boost structure and move its fields to cpufreq_driver structure
- Flag to indicate if global boost attribute is already defined
- Extent the pr_{err|debbug} functions to show current function names
drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/freq_table.c | 56 +++++++++++++++++--- include/linux/cpufreq.h | 24 +++++++++ 3 files changed, 190 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +117 -1
@@ -319,6 +319,33 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);/********************************************************************* * SYSFS INTERFACE * *********************************************************************/ +ssize_t show_boost (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" , cpufreq_driver->boost_enabled); +} + +static ssize_t store_boost (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t count) +{ +int ret, enable; + + ret =sscanf (buf,"%d" , &enable); +if (ret !=1 || enable <0 || enable >1 ) +return -EINVAL ; + +if (cpufreq_boost_trigger_state (enable)) { +pr_err ("%s: Cannot %s BOOST!\n" , __func__, + enable ?"enable" :"disable" ); +return -EINVAL ; + } + +pr_debug ("%s: cpufreq BOOST %s\n" , __func__, + enable ?"enabled" :"disabled" ); + +return count; +} +define_one_global_rw (boost);static struct cpufreq_governor *__find_governor (const char *str_governor) {
@@ -2038,6 +2065,73 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { };/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (ret) { +pr_err ("%s: Policy frequency update failed\n" , + __func__); +break ; + } + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enable" :"disable" ); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (likely (cpufreq_driver)) +return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
@@ -2076,9 +2170,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if driver provides function to enable boost - +* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&boost.attr); +if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
@@ -2105,6 +2215,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;
@@ -2131,6 +2244,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); +unregister_hotcpu_notifier (&cpufreq_cpu_notifier);down_write (&cpufreq_rwsem);
drivers/cpufreq/freq_table.c +49 -7
84 lines not on this page · raw message
include/linux/cpufreq.h +24 -0
@@ -215,6 +215,11 @@ struct cpufreq_driver {int (*suspend) (struct cpufreq_policy *policy);int (*resume) (struct cpufreq_policy *policy);struct freq_attr **attr; + +/* platform specific boost support code */ +bool boost_supported; +bool boost_enabled; +int (*set_boost) (int state); };/* flags */
@@ -403,6 +408,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;#define CPUFREQ_ENTRY_INVALID ~0#define CPUFREQ_TABLE_END ~1 +#define CPUFREQ_BOOST_FREQ ~2struct cpufreq_frequency_table {unsigned int driver_data;/* driver specific data, not used by core */
@@ -426,6 +432,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +#ifdef CONFIG_CPU_FREQ +int cpufreq_boost_trigger_state (int state); +int cpufreq_boost_supported (void ); +int cpufreq_boost_enabled (void ); +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following funtion is for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);
Signature · 1 line
1.7.10.4
PATCH v9 2/7 cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Lukasz MajewskiThe Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.
The _store_boost() function has been redesigned to be used as set_boost callback.
---
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- Remove superfluous acpi_cpufreq_driver.boost_supported = false at acpi_cpufreq_boost_init()
Changes for v6:
- Perform acpi_cpufreq_boost_init initialization before cpufreq_driver registration
- Compile store_boost() only when CONFIG_X86_ACPI_CPUFREQ_CPB defined
- Use boost_enabled flag defined at acpi_cpufreq_driver to store information about boost state
- Instead of using cpufreq_set_boost_enabled(), modify the boost_enable in the acpi driver code
Changes for v5:
- Remove acpi-cpufreq's boost_enabled global flag and reuse one defined at cpufreq core
Changes for v4:
- add _store_boost to acpi_cpufreq_driver structure
Changes for v3:
- Bring back boost_enabled as a global flag
- Move boost_supported to cpufreq_driver structure
Changes for v2:
- Replace boost_enabled and boost_supported global flags with proper entries at struct cpufreq_driver.
- Removal of struct cpufreq_boost
drivers/cpufreq/acpi-cpufreq.c | 86 ++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 57 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +29 -57
@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;static struct cpufreq_driver acpi_cpufreq_driver;static unsigned int acpi_pstate_strict; -static bool boost_enabled, boost_supported;static struct msr __percpu *msrs;static bool boost_state (unsigned int cpu)
@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static ssize_t _store_boost (const char *buf,size_t count) +static int _store_boost (int val) { -int ret; -unsigned long val =0 ; - -if (!boost_supported) -return -EINVAL ; - - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) -return -EINVAL ; - -if ((val && boost_enabled) || (!val && !boost_enabled)) -return count; -get_online_cpus (); -boost_set_msrs (val, cpu_online_mask); -put_online_cpus (); - - boost_enabled = val;pr_debug ("Core Boosting %sabled.\n" , val ?"en" :"dis" ); -return count; -} - -static ssize_t store_global_boost (struct kobject *kobj,struct attribute *attr, -const char *buf,size_t count) -{ -return _store_boost (buf, count); -} - -static ssize_t show_global_boost (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -return sprintf (buf,"%u\n" , boost_enabled); +return 0 ; } -static struct global_attr global_boost =__ATTR (boost,0644 , - show_global_boost, - store_global_boost); -static ssize_t show_freqdomain_cpus (struct cpufreq_policy *policy,char *buf) {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);
@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)cpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB +static ssize_t store_boost (const char *buf,size_t count) +{ +int ret; +unsigned long val =0 ; + +if (!acpi_cpufreq_driver.boost_supported) +return -EINVAL ; + + ret =kstrtoul (buf,10 , &val); +if (ret || (val >1 )) +return -EINVAL ; + +_store_boost ((int ) val); + +return count; +} +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -return _store_boost (buf, count); +return store_boost (buf, count); }static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) { -return sprintf (buf,"%u\n" , boost_enabled); +return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled); }cpufreq_freq_attr_rw (cpb);
@@ -573,7 +556,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,switch (action) {case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN : -boost_set_msrs (boost_enabled, cpumask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, cpumask);break ;case CPU_DOWN_PREPARE :
@@ -925,6 +908,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, + .set_boost = _store_boost, };static void __init acpi_cpufreq_boost_init (void )
@@ -935,33 +919,22 @@ static void __init acpi_cpufreq_boost_init(void)if (!msrs)return ; - boost_supported = true; - boost_enabled =boost_state (0 ); - + acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.boost_enabled =boost_state (0 );get_online_cpus ();/* Force all MSRs to the same value */ -boost_set_msrs (boost_enabled, cpu_online_mask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, + cpu_online_mask);register_cpu_notifier (&boost_nb);put_online_cpus (); - }else - global_boost.attr.mode =0444 ; - -/* We create the boost file in any case, though for systems without -* hardware support it will be read-only and hardwired to return 0. -*/ -if (cpufreq_sysfs_create_file (&(global_boost.attr))) -pr_warn (PFX "could not register global boost sysfs file\n" ); -else -pr_debug ("registered global boost sysfs file\n" ); + } } static void __exit acpi_cpufreq_boost_exit(void) { -cpufreq_sysfs_remove_file (&(global_boost.attr)); -if (msrs) {unregister_cpu_notifier (&boost_nb);
@@ -1007,12 +980,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init (); ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret; }
Signature · 1 line
1.7.10.4
PATCH v9 3/7 thermal:boost: Automatic enable/disable of BOOST feature
In reply to Lukasz MajewskiThis patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point. When device cools down, the boost is enabled again.
---
Changes for v9:
- None
Changes for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) to cpufreq.h at cpufreq core support commit
Changes for v7:
- None
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost related thermal_zone_device struct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used when CONFIG_CPU_FREQ is NOT defined.
Changes for v5:
- Move boost disable code from cpu_cooling.c to thermal_core.c
(to handle_non_critical_trips)
- Extent struct thermal_zone_device by adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Changes for v4:
- New patch
drivers/thermal/thermal_core.c | 55 ++++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 57 insertions(+)
drivers/thermal/thermal_core.c +55 -0
@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> #include <net/netlink.h> #include <net/genetlink.h>
@@ -366,9 +367,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only +* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} +static void handle_thermal_trip (struct thermal_zone_device *tz,int trip) {enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);
@@ -467,6 +518,10 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }
include/linux/thermal.h +2 -0
@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 1 line
1.7.10.4
Zhang Rui
reviewerRe: [PATCH v9 3/7] thermal:boost: Automatic enable/disable of BOOST feature
Hi, Lukasz,
thanks for the patch, sorry that I didn't look into this one earlier.
Quoted 2 lines · Lukasz Majewski
This patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
Do you mean boost is disabled if the system is in a overheating state?
Quoted 2 lines
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point.
Just FYI, the smallest trip point does not equal the trip point with lowest temperature value.
Say, here is a platform with an active trip point at 40C, and an critical trip point at 100C, you want to enable boost only if the temperature is under 30C, right?
Quoted 47 lines
When device cools down, the boost is enabled again.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c
(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Changes for v4:
- New patchdrivers/thermal/thermal_core.c | 55 ++++++++++++++++++++++++++++++++++++++++ include/linux/thermal.h | 2 ++ 2 files changed, 57 insertions(+)drivers/thermal/thermal_core.c +0
-0
drivers/thermal/thermal_core.c line 37
Quoted 4 lines
drivers/thermal/thermal_core.c +1
-0@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h>
Actually, I do not like to see this as thermal_core.c. Because it is the platform thermal driver that owns the thermal policy, e.g. it tells the thermal core to take what action at what temperature. And this cpufreq boost support should be part of the thermal policy.
For example, here is a platform that supports boost. And it has a passive trip point at 40C, which means the platform driver wants to reduce the processor frequency when the temperature at 40C. And what you're trying to add in this patch is to turn on boost mode when the temperature is under 30C, right?
If yes, then I'd prefer to
1. introduce a separate cpu cooling device that just has two cooling state, 0 means boost mode enabled, and 1 means boost mode disabled.
2. For any platform thermal driver that wants this support, introduce a new trip point (30C) to the platform thermal driver, and bind the cpufreq boost cooling device to this trip point.
And IMO, Step 1 can be an enhancement of cpufreq cooling feature. You just need to introduce two new APIs for registering/unregistering an cpu boost cooling device, without changing the current cpufreq cooling code.
Further more, cpufreq_boost_trigger_state(1) just make it possible to enter boost mode, it does not mean the cpu will be put into boost mode immediately, right? can we make it transparent to thermal core, say, always enable it when the cpu is in cooling state 0 (p0)?
thanks,
rui
Quoted 87 lines
drivers/thermal/thermal_core.c +54
-0#include <net/netlink.h> #include <net/genetlink.h> @@ -366,9 +367,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with +* 1000 ms monitoring period +* If workqueue already running - do not change its period and only +* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} +static void handle_thermal_trip (struct thermal_zone_device *tz,int trip) {enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);@@ -467,6 +518,10 @@ static void thermal_zone_device_check(struct work_struct *work) struct thermal_zone_device *tz = container_of(work, struct thermal_zone_device, poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }include/linux/thermal.h +2
-0@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Re: [PATCH v9 3/7] thermal:boost: Automatic enable/disable of BOOST feature
Hi Zhang,
Quoted 3 lines
Hi, Lukasz,
thanks for the patch, sorry that I didn't look into this one earlier.
Yes, I would _really_ appreciate _earlier_ feedback from thermal maintainers :-)
Quoted 6 lines · Lukasz Majewski
Quoted 2 lines
This patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
Do you mean boost is disabled if the system is in a overheating state?
In short - Yes.
To be more precise - the thermal here is a "safe" valve.
Its role is to provide hysteresis similar to the one available for Intel processors.
Intel does it in HW. Here I'm trying to do the same with SW for ARM.
Quoted 7 lines
Quoted 4 lines
In that moment thermal monitor workqueue is woken up and it monitors if the device temperature drops below 75% of the smallest trip point.
Just FYI, the smallest trip point does not equal the trip point with lowest temperature value.
Thermal processors to which I've looked (exynos 4/5, ste-snowball) had trip points defined monotonically with smallest value defined first.
This was the rationale for choosing thermal trip point 0.
Quoted 4 lines
Say, here is a platform with an active trip point at 40C, and an critical trip point at 100C, you want to enable boost only if the temperature is under 30C, right?
In short: no (please read below explanation).
The boost rough idea:
1. I enable boost from cpufreq (no matter what is the state of thermal)
2. If temperature is too high, then thermal interrupt would trigger and disable boost
3. If device cools down - I enable the boost again
Quoted 46 lines
Quoted 46 lines
When device cools down, the boost is enabled again.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Changes for v4:
- New patchdrivers/thermal/thermal_core.c | 55++++++++++++++++++++++++++++++++++++++++
include/linux/thermal.h| 2 ++ 2 files changed, 57
insertions(+)
Quoted 16 lines
drivers/thermal/thermal_core.c line 37
Quoted 9 lines
(quoted diff) +0
-0
b/drivers/thermal/thermal_core.cindex 4962a6a..a167ab9 100644drivers/thermal/thermal_core.c +1
-0@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> Actually, I do not like to see this as
thermal_core.c. Because it is the platform thermal driver that owns the thermal policy, e.g. it tells the thermal core to take what action at what temperature.
And this cpufreq boost support should be part of the thermal policy.
Boost is defined as policy independent at cpufreq. So I believe that it shall be also thermal policy independent. In the end thermal shall help cpufreq to not burn the device.
Quoted 6 lines
For example, here is a platform that supports boost. And it has a passive trip point at 40C, which means the platform driver wants to reduce the processor frequency when the temperature at 40C. And what you're trying to add in this patch is to turn on boost mode when the temperature is under 30C, right?
In short: yes.
I want to add code which would disable boost when detected temperature is more than 40C.
First, boost must be enabled at cpufreq. Only then it can be disabled (if temp > 40C) at thermal.
During boost disablement I also setup the thermal zone for polling (if we already poll it - no settings are changed).
The boost is re-enabled only when temperature drops to 30C AND the tz->overheated is set (which means that we are at overheated state caused by boost).
Quoted 9 lines
If yes, then I'd prefer to
1. introduce a separate cpu cooling device that just has two cooling state, 0 means boost mode enabled, and 1 means boost mode disabled.
2. For any platform thermal driver that wants this support, introduce a new trip point (30C) to the platform thermal driver,
and bind the
cpufreq boost cooling device to this trip point.
Quoted 8 lines
And IMO, Step 1 can be an enhancement of cpufreq cooling feature. You just need to introduce two new APIs for registering/unregistering an cpu boost cooling device, without changing the current cpufreq cooling code.
Further more,
cpufreq_boost_trigger_state(1)just make it possible to enter boost mode, it does not mean the cpu will be put into boost mode immediately, right?
Yes, correct.
Quoted 2 lines
can we make it transparent to thermal core, say, always enable it when the cpu is in cooling state 0 (p0)?
Thanks for presenting possible solution.
I will investigate it for boost.
Quoted 95 lines
thanks,
ruiQuoted 90 lines
drivers/thermal/thermal_core.c +35
-0#include <net/netlink.h> #include <net/genetlink.h> @@ -366,9 +367,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with
drivers/thermal/thermal_core.c +2
-0+* 1000 ms monitoring period +* If workqueue already running - do not change its period and only
drivers/thermal/thermal_core.c +11
-0+* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} + static void handle_thermal_trip(struct thermal_zone_device *tz,int trip) {
drivers/thermal/thermal_core.c +2
-0enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);@@ -467,6 +518,10 @@ static void thermal_zone_device_check(struct
work_struct*work) structthermal_zone_device*tz = container_of(work, structthermal_zone_device,drivers/thermal/thermal_core.c +4
-0poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }include/linux/thermal.h +2
-0@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Zhang, Rui
reviewerRE: [PATCH v9 3/7] thermal:boost: Automatic enable/disable of BOOST feature
Quoted 45 lines
-----Original Message-----
From: Lukasz Majewski [mailto:[email protected]]
Sent: Tuesday, October 15, 2013 11:43 PM
To: Zhang, Rui
Cc: Viresh Kumar; Rafael J. Wysocki; Eduardo Valentin; [email protected]; Linux PM list; Jonghwa Lee; Lukasz Majewski; linux-kernel; Bartlomiej Zolnierkiewicz; Myungjoo Ham; R, Durgadoss
Subject: Re: [PATCH v9 3/7] thermal:boost: Automatic enable/disable of BOOST feature
Importance: HighHi Zhang,
Quoted 3 lines
Hi, Lukasz,
thanks for the patch, sorry that I didn't look into this one earlier.
Yes, I would _really_ appreciate _earlier_ feedback from thermal maintainers :-)
Quoted 6 lines · Lukasz Majewski
Quoted 2 lines
This patch provides auto disable/enable operation for boost. When any defined trip point is passed, the boost is disabled.
Do you mean boost is disabled if the system is in a overheating state?
In short - Yes.
To be more precise - the thermal here is a "safe" valve.
Its role is to provide hysteresis similar to the one available for Intel processors.
Intel does it in HW. Here I'm trying to do the same with SW for ARM.
Quoted 2 lines
Quoted 2 lines
In that moment thermal monitor workqueue is woken up and it
monitors
Quoted 3 lines
Quoted 2 lines
if the device temperature drops below 75% of the smallest trip point.
Quoted 8 lines
Quoted 2 lines
Just FYI, the smallest trip point does not equal the trip point with lowest temperature value.
Thermal processors to which I've looked (exynos 4/5, ste-snowball) had trip points defined monotonically with smallest value defined first.
This was the rationale for choosing thermal trip point 0.
But this is not a hard rule for all thermal drivers, thus you can't make this assumption.
Quoted 81 lines
Quoted 5 lines
Say, here is a platform with an active trip point at 40C, and an critical trip point at 100C, you want to enable boost only if the temperature is under 30C, right?
In short: no (please read below explanation).
The boost rough idea:
1. I enable boost from cpufreq (no matter what is the state of thermal)
2. If temperature is too high, then thermal interrupt would trigger and disable boost 3. If device cools down - I enable the boost againQuoted 15 lines
Quoted 15 lines
When device cools down, the boost is enabled again.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitQuoted 6 lines
Quoted 6 lines
Changes for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields withmutex
Quoted 8 lines
Quoted 8 lines
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Quoted 6 lines
Quoted 6 lines
Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal usesit's
Quoted 1 line
Quoted 1 line
predefined pool delay or has woken up thermal workqueue only to
wait
Quoted 10 lines
Quoted 10 lines
until device cools down.
Changes for v4:
- New patchdrivers/thermal/thermal_core.c | 55++++++++++++++++++++++++++++++++++++++++
include/linux/thermal.h| 2 ++ 2 files changed, 57
insertions(+)Quoted 15 lines
drivers/thermal/thermal_core.c line 37
Quoted 9 lines
(quoted diff) +0
-0
b/drivers/thermal/thermal_core.cindex 4962a6a..a167ab9 100644drivers/thermal/thermal_core.c +1
-0@@ -34,6 +34,7 @@#include <linux/thermal.h> #include <linux/reboot.h> #include <linux/string.h> +#include <linux/cpufreq.h> Actually, I do not like to see this as
thermal_core.c. Because it is the platform thermal driver that owns the thermal policy, e.g. it tells the thermal core to take what action at what temperature.
And this cpufreq boost support should be part of the thermal policy.
Quoted 5 lines
Boost is defined as policy independent at cpufreq.
So I believe that
it shall be also thermal policy independent.
Boost mode support itself is policy independent, but when to use it is kind of a policy, right?
Say, if you introduce boost support in cpufreq cooling code, either as a cooling device or as a special cooling state, it is thermal policy independent, but when to use this cooling device/state is surely part of thermal policy.
Quoted 44 lines
In the end thermal shall
help cpufreq to not burn the device.Quoted 6 lines
For example, here is a platform that supports boost. And it has a passive trip point at 40C, which means the platform driver wants to reduce the processor frequency when the temperature at 40C. And what you're trying to add in this patch is to turn on boost mode when the temperature is under 30C, right?
In short: yes.
I want to add code which would disable boost when detected temperature is more than 40C.
First, boost must be enabled at cpufreq. Only then it can be disabled (if temp > 40C) at thermal.
During boost disablement I also setup the thermal zone for polling (if we already poll it - no settings are changed).
The boost is re-enabled only when temperature drops to 30C AND the
tz->overheatedis set (which means that we are at overheated state caused by boost).Quoted 9 lines
If yes, then I'd prefer to
1. introduce a separate cpu cooling device that just has two cooling state, 0 means boost mode enabled, and 1 means boost mode disabled.
2. For any platform thermal driver that wants this support, introduce a new trip point (30C) to the platform thermal driver,
and bind the
cpufreq boost cooling device to this trip point.Quoted 7 lines
And IMO, Step 1 can be an enhancement of cpufreq cooling feature. You just need to introduce two new APIs for registering/unregistering an cpu boost cooling device, without changing the current cpufreq cooling code.
Further more,
cpufreq_boost_trigger_state(1)just make it possible to enter boost mode, it does not mean the cpu will be put into boostmode
Quoted 9 lines
Quoted 1 line
immediately, right?
Yes, correct.
Quoted 2 lines
can we make it transparent to thermal core, say, always enable it when the cpu is in cooling state 0 (p0)?
Thanks for presenting possible solution.
No problem.
Thanks,
rui
Quoted 2 lines
I will investigate it for boost.
Thanks,
rui
Quoted 104 lines
Quoted 80 lines
thanks,
ruiQuoted 77 lines
drivers/thermal/thermal_core.c +35
-0#include <net/netlink.h> #include <net/genetlink.h> @@ -366,9 +367,59 @@ static void handle_critical_trips(struct thermal_zone_device *tz, } } +static int thermal_boost_enable (struct thermal_zone_device *tz) +{ +enum thermal_trend trend =get_tz_trend (tz,0 ); +long trip_temp; + +if (!tz->ops->get_trip_temp || !tz->overheated) +return -EPERM ; +if (trend ==THERMAL_TREND_RAISING || trend ==THERMAL_TREND_RAISE_FULL ) +return -EBUSY ; + + tz->ops->get_trip_temp (tz,0 , &trip_temp); +/* +* Enable boost again only when current temperature is less +* than 75% of trip_temp[0] +*/ +if ((tz->temperature + (trip_temp >>2 )) < trip_temp) { +mutex_lock (&tz->lock); + tz->overheated = false; +if (tz->boost_polling) { + tz->boost_polling = false; + tz->polling_delay =0 ; + } +mutex_unlock (&tz->lock); +cpufreq_boost_trigger_state (1 ); +return 0 ; + } +return -EBUSY ; +} + +static void thermal_boost_disable (struct thermal_zone_device *tz) +{ +cpufreq_boost_trigger_state (0 ); + +/* +* If no workqueue for monitoring is running - start one with
drivers/thermal/thermal_core.c +2
-0+* 1000 ms monitoring period +* If workqueue already running - do not change its period and only
drivers/thermal/thermal_core.c +11
-0+* test if target CPU has cooled down +*/ +mutex_lock (&tz->lock); +if (!tz->polling_delay) { + tz->boost_polling = true; + tz->polling_delay =1000 ; + } + tz->overheated = true; +mutex_unlock (&tz->lock); +} + static void handle_thermal_trip(struct thermal_zone_device *tz,int trip) {
drivers/thermal/thermal_core.c +2
-0enum thermal_trip_type type; +if (cpufreq_boost_supported () &&cpufreq_boost_enabled ()) +thermal_boost_disable (tz); tz->ops->get_trip_type (tz, trip, &type);@@ -467,6 +518,10 @@ static void thermal_zone_device_check(struct
work_struct*work) structthermal_zone_device*tz = container_of(work, structthermal_zone_device,drivers/thermal/thermal_core.c +4
-0poll_queue.work); +if (cpufreq_boost_supported ()) +if (!thermal_boost_enable (tz)) +return ; +thermal_zone_device_update (tz); }Quoted 15 lines
include/linux/thermal.h struct thermal_zone_device { · line 179
Quoted 13 lines
include/linux/thermal.h +2
-0@@ -172,6 +172,8 @@ struct thermal_zone_device {int emul_temperature;int passive;unsigned int forced_passive; +bool overheated; +bool boost_polling;const struct thermal_zone_device_ops *ops;const struct thermal_zone_params *tzp;struct thermal_governor *governor;--
Best regards,Lukasz Majewski
Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
PATCH v9 4/7 cpufreq:boost:Kconfig: Provide support for software managed BOOST
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "EXYNOS Frequency Overclocking - Software" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- Remove superfluous "default n" definition
- Generic CPU_FREQ_BOOST_SW depends on THERMAL
Changes for v6:
- CPU_FREQ_BOOST_SW [1] is now defined as "invisible" bool option.
- Platform dependent ARM_EXYNOS_CPU_FREQ_BOOST_SW config option has been added. It depends on ARM_EXYNOS_CPUFREQ options and selects EXYNOS_THERMAL with the main boost config [1].
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 4 ++++ drivers/cpufreq/Kconfig.arm | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
drivers/cpufreq/Kconfig +4 -0
@@ -20,6 +20,10 @@ if CPU_FREQ config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool + depends on THERMAL + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" default y
drivers/cpufreq/Kconfig.arm +15 -0
@@ -64,6 +64,21 @@ config ARM_EXYNOS5440_CPUFREQ If in doubt, say N. +config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. + config ARM_HIGHBANK_CPUFREQ tristate "Calxeda Highbank-based" depends on ARCH_HIGHBANK
Signature · 1 line
1.7.10.4
PATCH v9 5/7 cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Lukasz MajewskiThe cpufreq_driver's boost_supported flag is true only when boost support is explicitly enabled.
---
Changes for v9:
- The exynos_cpufreq_attr[] has been replaced by generic_cpufreq_attr[], therefore the cpufreq_freq_attr_scaling_boost_freqs is now added at freq_table.c file.
Changes for v8:
- None
Changes for v7:
- Replace CONFIG_CPU_FREQ_BOOST_SW with CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
- Move boost_supported initialization to struct cpufreq_driver exynos_driver
Changes for v6:
- Replace exynos_driver.boost_supported = 1 to = true
- Protect boost attributes export with CONFIG_CPU_FREQ_BOOST_SW
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Remove low level boost code
- Move boost management code to cpufreq core code
- Use boost_supported flag to indicate if driver supports over clocking
Changes for v2:
- Removal of struct cpufreq_boost
- Removal of the CONFIG_CPU_FREQ_BOOST flag
- low_level_boost with valid address when boost is supported
drivers/cpufreq/exynos-cpufreq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/cpufreq/exynos-cpufreq.c +3 -0
@@ -253,6 +253,9 @@ static struct cpufreq_driver exynos_driver = { .exit = cpufreq_generic_exit, .name = "exynos_cpufreq", .attr = cpufreq_generic_attr, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + .boost_supported = true, +#endif #ifdef CONFIG_PM .suspend = exynos_cpufreq_suspend, .resume = exynos_cpufreq_resume,
Signature · 1 line
1.7.10.4
PATCH v9 6/7 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- None
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
PATCH v9 7/7 cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
In reply to Lukasz MajewskiSpecial driver data flag (CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.
---
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- New patch
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/exynos4x12-cpufreq.c +1 -1
@@ -32,7 +32,7 @@ static unsigned int exynos4x12_volt_table[] = { };static struct cpufreq_frequency_table exynos4x12_freq_table[] = { - {L0 ,CPUFREQ_ENTRY_INVALID }, + {CPUFREQ_BOOST_FREQ ,1500 *1000 }, {L1 ,1400 *1000 }, {L2 ,1300 *1000 }, {L3 ,1200 *1000 },
Signature · 1 line
1.7.10.4
v10 cover cpufreq:boost: CPU Boost mode support
In reply to Lukasz MajewskiThis patch series introduces support for CPU overclocking technique called Boost.
It is a follow up of a LAB governor proposal. Boost is a LAB component:
http://thread.gmane.org/gmane.linux.kernel/1484746/match=cpufreq
Boost unifies hardware based solution (e.g. Intel Nehalem) with software oriented one (like the one done at Exynos).
For this reason cpufreq/freq_table code has been reorganized to include common code.
Important design decisions:
- Boost related code is compiled-in unconditionally to cpufreq core and disabled by default. The cpufreq_driver is responsibile for setting boost_supported flag and providing set_boost callback(if HW support is needed). For software managed boost, special Kconfig flag - CONFIG_CPU_FREQ_BOOST_SW has been defined. It will be selected only when a target platform has thermal framework properly configured.
- struct cpufreq_driver has been extended with boost related fields:
-- boost_supported - when driver supports boosting -- boost_enabled - boost state
-- set_boost - callback to function, which is necessary to
enable/disable boost
- Boost sysfs attribute (/sys/devices/system/cpu/cpufreq/boost) is visible _only_ when cpufreq driver supports Boost.
- No special spin_lock for Boost was created. The one from cpufreq core was reused.
- The Boost code doesn't rely on any policy. When boost state is changed, then the policy list is iterated and proper adjustements are done.
- To improve safety level, the thermal framework is also extended to disable software boosting, when thermal trip point is reached. After cooling down the boost can be enabled again. This emulates behaviour similar to HW managed boost (like x86)
Tested at HW:
Exynos 4412 3.12-rc7 Linux
Intel Core i7-3770 3.12-rc7 LinuxAbove patches were posted on top of kernel_pm/bleeding-edge (SHA1: acc3663ce3f9cde3a7da88fb478531c58d5ed399)
Lukasz Majewski (7):
cpufreq: Add boost frequency support in core cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common
boost solution
cpufreq:boost:Kconfig: Provide support for software managed BOOST cpufreq:exynos:Extend Exynos cpufreq driver to support boost
framework
Documentation:cpufreq:boost: Update BOOST documentation cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ thermal:exynos:boost: Automatic enable/disable of BOOST feature (at
Exynos4412)
Documentation/cpu-freq/boost.txt | 26 +++---- drivers/cpufreq/Kconfig | 4 + drivers/cpufreq/Kconfig.arm | 15 ++++ drivers/cpufreq/acpi-cpufreq.c | 86 +++++++-------------- drivers/cpufreq/cpufreq.c | 118 ++++++++++++++++++++++++++++- drivers/cpufreq/exynos-cpufreq.c | 3 + drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- drivers/cpufreq/freq_table.c | 56 ++++++++++++-- drivers/thermal/samsung/exynos_tmu_data.c | 47 ++++++++++++ include/linux/cpufreq.h | 24 ++++++ 10 files changed, 302 insertions(+), 79 deletions(-)
Signature · 1 line
1.7.10.4
PATCH v10 1/7 cpufreq: Add boost frequency support in core
This commit adds boost frequency support in cpufreq core (Hardware & Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency above its normal operation limits. Such mode shall be only used for a short time.
Overclocking (boost) support is essentially provided by platform dependent cpufreq driver.
This commit unifies support for SW and HW (Intel) overclocking solutions in the core cpufreq driver. Previously the "boost" sysfs attribute was defined at acpi driver code. By default boost is disabled. One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.
It only shows up when cpufreq driver supports overclocking. Under the hood frequencies dedicated for boosting are marked with a special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table. It is the user's concern to enable/disable overclocking with a proper call to sysfs.
The cpufreq_boost_trigger_state() function is defined non static on purpose. It is used later with thermal subsystem to provide automatic enable/disable of the BOOST feature.
---
Changes for v10:
- None
Changes for v9:
- Add cpufreq_freq_attr_scaling_boost_freqs to *cpufreq_generic_attr table
- Introduce CONFIG_CPU_FREQ_BOOST_SW generic config flag to show BOOST frequencies only when cpufreq driver supports boost
Changes for v8:
- Correction of error message at cpufreq_boost_trigger_state() function
- Rewrite the cpufreq_boost_set_sw() function to print error message and break the loop when policy adjustment fails
Changes for v7:
- Properly change cpufreq_driver->boost_enabled when set_boost() fails (=0 to =!state)
- Add likely() around cpufreq_driver
- Remove parenthesis around boost.attr
Changes for v6:
- Remove sysfs boost attribute when subsys_iterface_unregister() fails
- Move global boost_enabled variable from cpufreq.c to platform dependent struct cpufreq_driver
- pr_err() message is also printed when boost disable fails
- Call __cpufreq_governor() to force recalculation of next frequency when boost is triggered. It is needed with i.e. performance class of governors
- Change cpufreq_boost_enable_sw() -> cpufreq_boost_set_sw()
- Rename .enable_boost function pointer to .set_boost
Changes for v5:
- Rename cpufreq_boost_trigger_state_sw() to cpufreq_boost_enable_sw()
- Extent cpufreq_register_driver() to check if cpufreq driver provided boost_enable callback. If not provided, then use cpufreq_boost_enable_sw()
- Use single call to cpufreq_driver->enable_boost() with cpufreq driver provided callback or default SW boost enable routine
- Move pr_debug call to store_boost() from cpufreq_boost_trigger_state()
- Change the user_policy.max value when SW boost is toggled. It is necessary for proper operation of e.g. thermal subsystem.
- Add check if cpufreq_driver pointer is not NULL at cpufreq_boost_supported() routine
- Add EXPORT_SYMBOL_GPL for cpufreq_boost_supported() and cpufreq_boost_enabled()
- Remove extra check for cpufreq_boost_supported() at cpufreq_freq_table_cpuinfo()
- Explanation of show boost logic at show_available_freqs()
- Add cpufreq_set_boost_enabled() method to set initial value of boost_enabled global flag
Changes for v4:
- Remove boost parameter from cpufreq_frequency_table_cpuinfo() function
- Introduce cpufreq_boost_supported() method
- Use of cpufreq_boost_supported() and cpufreq_boost_enabled() to decide if frequency shall be skipped
- Rename set_boost_freq() to enable_boost()
- cpufreq_attr_available_freq() moved to freq_table.c
- Use policy list to get access to cpufreq policies
- Rename global boost flag (cpufreq_boost_enabled -> boost_enabled)
- pr_err corrected ( %sable)
- Remove sanity check at cpufreq_boost_trigger_state() entrance [to test if boost is supported]
- Use either HW (boost_enable) callback or SW managed boost
- Introduce new cpufreq_boost_trigger_state_sw() method to handle boost at SW.
- Protect boost_enabled manipulation with lock.
Changes for v3:
- Method for reading boost status
- Removal of cpufreq_frequency_table_max()
- Extent cpufreq_frequency_table_cpuinfo() to support boost parameter
- boost_supported flag added to cpufreq_driver struct
- "boost" sysfs attribute control flag removed
- One global flag describing state of the boost defined at cpufreq core
- Rename cpufreq_driver's low_level_boost field to set_boost_freq()
- Usage of cpufreq_sysfs_{remove|add}_file() routines
Changes for v2:
- Removal of cpufreq_boost structure and move its fields to cpufreq_driver structure
- Flag to indicate if global boost attribute is already defined
- Extent the pr_{err|debbug} functions to show current function names
drivers/cpufreq/cpufreq.c | 118 +++++++++++++++++++++++++++++++++++++++++- drivers/cpufreq/freq_table.c | 56 +++++++++++++++++--- include/linux/cpufreq.h | 24 +++++++++ 3 files changed, 190 insertions(+), 8 deletions(-)
drivers/cpufreq/cpufreq.c +117 -1
@@ -324,6 +324,33 @@ EXPORT_SYMBOL_GPL(cpufreq_notify_transition);/********************************************************************* * SYSFS INTERFACE * *********************************************************************/ +ssize_t show_boost (struct kobject *kobj, +struct attribute *attr,char *buf) +{ +return sprintf (buf,"%d\n" , cpufreq_driver->boost_enabled); +} + +static ssize_t store_boost (struct kobject *kobj,struct attribute *attr, +const char *buf,size_t count) +{ +int ret, enable; + + ret =sscanf (buf,"%d" , &enable); +if (ret !=1 || enable <0 || enable >1 ) +return -EINVAL ; + +if (cpufreq_boost_trigger_state (enable)) { +pr_err ("%s: Cannot %s BOOST!\n" , __func__, + enable ?"enable" :"disable" ); +return -EINVAL ; + } + +pr_debug ("%s: cpufreq BOOST %s\n" , __func__, + enable ?"enabled" :"disabled" ); + +return count; +} +define_one_global_rw (boost);static struct cpufreq_governor *__find_governor (const char *str_governor) {
@@ -2106,6 +2133,73 @@ static struct notifier_block __refdata cpufreq_cpu_notifier = { };/********************************************************************* +* BOOST * +*********************************************************************/ +static int cpufreq_boost_set_sw (int state) +{ +struct cpufreq_frequency_table *freq_table; +struct cpufreq_policy *policy; +int ret = -EINVAL ; + +list_for_each_entry (policy, &cpufreq_policy_list, policy_list) { + freq_table =cpufreq_frequency_get_table (policy->cpu); +if (freq_table) { + ret =cpufreq_frequency_table_cpuinfo (policy, + freq_table); +if (ret) { +pr_err ("%s: Policy frequency update failed\n" , + __func__); +break ; + } + policy->user_policy.max = policy->max; +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); + } + } + +return ret; +} + +int cpufreq_boost_trigger_state (int state) +{ +unsigned long flags; +int ret =0 ; + +if (cpufreq_driver->boost_enabled == state) +return 0 ; + +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + + ret = cpufreq_driver->set_boost (state); +if (ret) { +write_lock_irqsave (&cpufreq_driver_lock, flags); + cpufreq_driver->boost_enabled = !state; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); + +pr_err ("%s: Cannot %s BOOST\n" , __func__, + state ?"enable" :"disable" ); + } + +return ret; +} + +int cpufreq_boost_supported (void ) +{ +if (likely (cpufreq_driver)) +return cpufreq_driver->boost_supported; + +return 0 ; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_supported); + +int cpufreq_boost_enabled (void ) +{ +return cpufreq_driver->boost_enabled; +} +EXPORT_SYMBOL_GPL (cpufreq_boost_enabled); + +/********************************************************************* * REGISTER / UNREGISTER CPUFREQ DRIVER * *********************************************************************/
@@ -2145,9 +2239,25 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) cpufreq_driver = driver_data;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_boost_supported ()) { +/* +* Check if driver provides function to enable boost - +* if not, use cpufreq_boost_set_sw as default +*/ +if (!cpufreq_driver->set_boost) + cpufreq_driver->set_boost = cpufreq_boost_set_sw; + + ret =cpufreq_sysfs_create_file (&boost.attr); +if (ret) { +pr_err ("%s: cannot register global BOOST sysfs file\n" , + __func__); + goto err_null_driver; + } + } + ret =subsys_interface_register (&cpufreq_interface);if (ret) - goto err_null_driver; + goto err_boost_unreg;if (!(cpufreq_driver->flags &CPUFREQ_STICKY )) {int i;
@@ -2174,6 +2284,9 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)return 0 ; err_if_unreg:subsys_interface_unregister (&cpufreq_interface); +err_boost_unreg: +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); err_null_driver:write_lock_irqsave (&cpufreq_driver_lock, flags); cpufreq_driver =NULL ;
@@ -2200,6 +2313,9 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver)pr_debug ("unregistering driver %s\n" , driver->name);subsys_interface_unregister (&cpufreq_interface); +if (cpufreq_boost_supported ()) +cpufreq_sysfs_remove_file (&boost.attr); +unregister_hotcpu_notifier (&cpufreq_cpu_notifier);down_write (&cpufreq_rwsem);
drivers/cpufreq/freq_table.c +49 -7
84 lines not on this page · raw message
include/linux/cpufreq.h +24 -0
@@ -217,6 +217,11 @@ struct cpufreq_driver {int (*suspend) (struct cpufreq_policy *policy);int (*resume) (struct cpufreq_policy *policy);struct freq_attr **attr; + +/* platform specific boost support code */ +bool boost_supported; +bool boost_enabled; +int (*set_boost) (int state); };/* flags */
@@ -412,6 +417,7 @@ extern struct cpufreq_governor cpufreq_gov_conservative;#define CPUFREQ_ENTRY_INVALID ~0#define CPUFREQ_TABLE_END ~1 +#define CPUFREQ_BOOST_FREQ ~2struct cpufreq_frequency_table {unsigned int driver_data;/* driver specific data, not used by core */
@@ -435,6 +441,24 @@ int cpufreq_frequency_table_target(struct cpufreq_policy *policy,void cpufreq_frequency_table_update_policy_cpu (struct cpufreq_policy *policy);ssize_t cpufreq_show_cpus (const struct cpumask *mask,char *buf); +#ifdef CONFIG_CPU_FREQ +int cpufreq_boost_trigger_state (int state); +int cpufreq_boost_supported (void ); +int cpufreq_boost_enabled (void ); +#else +static inline int cpufreq_boost_trigger_state (int state) +{ +return 0 ; +} +static inline int cpufreq_boost_supported (void ) +{ +return 0 ; +} +static inline int cpufreq_boost_enabled (void ) +{ +return 0 ; +} +#endif /* the following funtion is for cpufreq core use only */ struct cpufreq_frequency_table *cpufreq_frequency_get_table (unsigned int cpu);
Signature · 1 line
1.7.10.4
PATCH v10 2/7 cpufreq:acpi:x86: Adjust the acpi-cpufreq.c code to work with common boost solution
In reply to Lukasz MajewskiThe Intel's hardware based boost solution driver has been changed to cooperate with common cpufreq boost framework.
The global sysfs boost attribute entry code (/sys/devices/system/cpu/cpufreq/boost) has been moved to a core cpufreq code. This attribute is now only visible, when cpufreq driver supports it.
The _store_boost() function has been redesigned to be used as set_boost callback.
---
Changes for v10:
- None
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- Remove superfluous acpi_cpufreq_driver.boost_supported = false at acpi_cpufreq_boost_init()
Changes for v6:
- Perform acpi_cpufreq_boost_init initialization before cpufreq_driver registration
- Compile store_boost() only when CONFIG_X86_ACPI_CPUFREQ_CPB defined
- Use boost_enabled flag defined at acpi_cpufreq_driver to store information about boost state
- Instead of using cpufreq_set_boost_enabled(), modify the boost_enable in the acpi driver code
Changes for v5:
- Remove acpi-cpufreq's boost_enabled global flag and reuse one defined at cpufreq core
Changes for v4:
- add _store_boost to acpi_cpufreq_driver structure
Changes for v3:
- Bring back boost_enabled as a global flag
- Move boost_supported to cpufreq_driver structure
Changes for v2:
- Replace boost_enabled and boost_supported global flags with proper entries at struct cpufreq_driver.
- Removal of struct cpufreq_boost
drivers/cpufreq/acpi-cpufreq.c | 86 ++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 57 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +29 -57
@@ -80,7 +80,6 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;static struct cpufreq_driver acpi_cpufreq_driver;static unsigned int acpi_pstate_strict; -static bool boost_enabled, boost_supported;static struct msr __percpu *msrs;static bool boost_state (unsigned int cpu)
@@ -133,49 +132,16 @@ static void boost_set_msrs(bool enable, const struct cpumask *cpumask)wrmsr_on_cpus (cpumask, msr_addr, msrs); } -static ssize_t _store_boost (const char *buf,size_t count) +static int _store_boost (int val) { -int ret; -unsigned long val =0 ; - -if (!boost_supported) -return -EINVAL ; - - ret =kstrtoul (buf,10 , &val); -if (ret || (val >1 )) -return -EINVAL ; - -if ((val && boost_enabled) || (!val && !boost_enabled)) -return count; -get_online_cpus (); -boost_set_msrs (val, cpu_online_mask); -put_online_cpus (); - - boost_enabled = val;pr_debug ("Core Boosting %sabled.\n" , val ?"en" :"dis" ); -return count; -} - -static ssize_t store_global_boost (struct kobject *kobj,struct attribute *attr, -const char *buf,size_t count) -{ -return _store_boost (buf, count); -} - -static ssize_t show_global_boost (struct kobject *kobj, -struct attribute *attr,char *buf) -{ -return sprintf (buf,"%u\n" , boost_enabled); +return 0 ; } -static struct global_attr global_boost =__ATTR (boost,0644 , - show_global_boost, - store_global_boost); -static ssize_t show_freqdomain_cpus (struct cpufreq_policy *policy,char *buf) {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);
@@ -186,15 +152,32 @@ static ssize_t show_freqdomain_cpus(struct cpufreq_policy *policy, char *buf)cpufreq_freq_attr_ro (freqdomain_cpus);#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB +static ssize_t store_boost (const char *buf,size_t count) +{ +int ret; +unsigned long val =0 ; + +if (!acpi_cpufreq_driver.boost_supported) +return -EINVAL ; + + ret =kstrtoul (buf,10 , &val); +if (ret || (val >1 )) +return -EINVAL ; + +_store_boost ((int ) val); + +return count; +} +static ssize_t store_cpb (struct cpufreq_policy *policy,const char *buf,size_t count) { -return _store_boost (buf, count); +return store_boost (buf, count); }static ssize_t show_cpb (struct cpufreq_policy *policy,char *buf) { -return sprintf (buf,"%u\n" , boost_enabled); +return sprintf (buf,"%u\n" , acpi_cpufreq_driver.boost_enabled); }cpufreq_freq_attr_rw (cpb);
@@ -554,7 +537,7 @@ static int boost_notify(struct notifier_block *nb, unsigned long action,switch (action) {case CPU_UP_PREPARE :case CPU_UP_PREPARE_FROZEN : -boost_set_msrs (boost_enabled, cpumask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, cpumask);break ;case CPU_DOWN_PREPARE :
@@ -911,6 +894,7 @@ static struct cpufreq_driver acpi_cpufreq_driver = { .resume = acpi_cpufreq_resume, .name = "acpi-cpufreq", .attr = acpi_cpufreq_attr, + .set_boost = _store_boost, };static void __init acpi_cpufreq_boost_init (void )
@@ -921,33 +905,22 @@ static void __init acpi_cpufreq_boost_init(void)if (!msrs)return ; - boost_supported = true; - boost_enabled =boost_state (0 ); - + acpi_cpufreq_driver.boost_supported = true; + acpi_cpufreq_driver.boost_enabled =boost_state (0 );get_online_cpus ();/* Force all MSRs to the same value */ -boost_set_msrs (boost_enabled, cpu_online_mask); +boost_set_msrs (acpi_cpufreq_driver.boost_enabled, + cpu_online_mask);register_cpu_notifier (&boost_nb);put_online_cpus (); - }else - global_boost.attr.mode =0444 ; - -/* We create the boost file in any case, though for systems without -* hardware support it will be read-only and hardwired to return 0. -*/ -if (cpufreq_sysfs_create_file (&(global_boost.attr))) -pr_warn (PFX "could not register global boost sysfs file\n" ); -else -pr_debug ("registered global boost sysfs file\n" ); + } } static void __exit acpi_cpufreq_boost_exit(void) { -cpufreq_sysfs_remove_file (&(global_boost.attr)); -if (msrs) {unregister_cpu_notifier (&boost_nb);
@@ -993,12 +966,11 @@ static int __init acpi_cpufreq_init(void) *iter = &cpb; }#endif +acpi_cpufreq_boost_init (); ret =cpufreq_register_driver (&acpi_cpufreq_driver);if (ret)free_acpi_perf_data (); -else -acpi_cpufreq_boost_init ();return ret; }
Signature · 1 line
1.7.10.4
PATCH v10 3/7 cpufreq:boost:Kconfig: Provide support for software managed BOOST
In reply to Lukasz MajewskiFor safety reasons new flag - CONFIG_CPU_FREQ_BOOST_SW has been added. Only after selecting "EXYNOS Frequency Overclocking - Software" Kconfig option the software managed boost is enabled. It also selects thermal subsystem to be compiled in. Thermal is necessary for disabling boost and cooling down the device when overheating detected.
Boost _MUST_NOT_ work without thermal subsystem with properly defined overheating temperatures.
This option doesn't affect x86's ACPI hardware managed boost support (i.e. Intel, AMD). In this situation boost management is embedded at hardware.
---
Changes for v10:
- None
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- Remove superfluous "default n" definition
- Generic CPU_FREQ_BOOST_SW depends on THERMAL
Changes for v6:
- CPU_FREQ_BOOST_SW [1] is now defined as "invisible" bool option.
- Platform dependent ARM_EXYNOS_CPU_FREQ_BOOST_SW config option has been added. It depends on ARM_EXYNOS_CPUFREQ options and selects EXYNOS_THERMAL with the main boost config [1].
Changes for v5:
- New patch
drivers/cpufreq/Kconfig | 4 ++++ drivers/cpufreq/Kconfig.arm | 15 +++++++++++++++ 2 files changed, 19 insertions(+)
drivers/cpufreq/Kconfig +4 -0
@@ -20,6 +20,10 @@ if CPU_FREQ config CPU_FREQ_GOV_COMMON bool +config CPU_FREQ_BOOST_SW + bool + depends on THERMAL + config CPU_FREQ_STAT tristate "CPU frequency translation statistics" default y
drivers/cpufreq/Kconfig.arm +15 -0
@@ -64,6 +64,21 @@ config ARM_EXYNOS5440_CPUFREQ If in doubt, say N. +config ARM_EXYNOS_CPU_FREQ_BOOST_SW + bool "EXYNOS Frequency Overclocking - Software" + depends on ARM_EXYNOS_CPUFREQ + select CPU_FREQ_BOOST_SW + select EXYNOS_THERMAL + help + This driver supports software managed overclocking (BOOST). + It allows usage of special frequencies for Samsung Exynos + processors if thermal conditions are appropriate. + + It reguires, for safe operation, thermal framework with properly + defined trip points. + + If in doubt, say N. + config ARM_HIGHBANK_CPUFREQ tristate "Calxeda Highbank-based" depends on ARCH_HIGHBANK
Signature · 1 line
1.7.10.4
PATCH v10 4/7 cpufreq:exynos:Extend Exynos cpufreq driver to support boost framework
In reply to Lukasz MajewskiThe cpufreq_driver's boost_supported flag is true only when boost support is explicitly enabled. Boost related attributes are exported only under the same condition.
---
Changes for v10:
- None
Changes for v9:
- The exynos_cpufreq_attr[] has been replaced by generic_cpufreq_attr[], therefore the cpufreq_freq_attr_scaling_boost_freqs is now added at freq_table.c file.
Changes for v8:
- None
Changes for v7:
- Replace CONFIG_CPU_FREQ_BOOST_SW with CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW
- Move boost_supported initialization to struct cpufreq_driver exynos_driver
Changes for v6:
- Replace exynos_driver.boost_supported = 1 to = true
- Protect boost attributes export with CONFIG_CPU_FREQ_BOOST_SW
Changes for v5:
- None
Changes for v4:
- None
Changes for v3:
- Remove low level boost code
- Move boost management code to cpufreq core code
- Use boost_supported flag to indicate if driver supports over clocking
Changes for v2:
- Removal of struct cpufreq_boost
- Removal of the CONFIG_CPU_FREQ_BOOST flag
- low_level_boost with valid address when boost is supported
drivers/cpufreq/exynos-cpufreq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/cpufreq/exynos-cpufreq.c +3 -0
@@ -226,6 +226,9 @@ static struct cpufreq_driver exynos_driver = { .exit = cpufreq_generic_exit, .name = "exynos_cpufreq", .attr = cpufreq_generic_attr, +#ifdef CONFIG_ARM_EXYNOS_CPU_FREQ_BOOST_SW + .boost_supported = true, +#endif #ifdef CONFIG_PM .suspend = exynos_cpufreq_suspend, .resume = exynos_cpufreq_resume,
Signature · 1 line
1.7.10.4
PATCH v10 5/7 Documentation:cpufreq:boost: Update BOOST documentation
In reply to Lukasz MajewskiSince the support for software and hardware controlled boosting has been added, the corresponding Documentation entry had been updated.
---
Changes for v10:
- None
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- None
Changes for v5:
- New patch
Documentation/cpu-freq/boost.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
Documentation/cpu-freq/boost.txt +13 -13
@@ -17,8 +17,8 @@ Introduction Some CPUs support a functionality to raise the operating frequency of some cores in a multi-core package if certain conditions apply, mostly if the whole chip is not fully utilized and below it's intended thermal -budget. This is done without operating system control by a combination -of hardware and firmware. +budget. The decision about boost disable/enable is made either at hardware +(e.g. x86) or software (e.g ARM). On Intel CPUs this is called "Turbo Boost", AMD calls it "Turbo-Core", in technical documentation "Core performance boost". In Linux we use the term "boost" for convenience.
@@ -48,24 +48,24 @@ be desirable: User controlled switch ---------------------- -To allow the user to toggle the boosting functionality, the acpi-cpufreq -driver exports a sysfs knob to disable it. There is a file: +To allow the user to toggle the boosting functionality, the cpufreq core +driver exports a sysfs knob to enable or disable it. There is a file: /sys/devices/system/cpu/cpufreq/boost which can either read "0" (boosting disabled) or "1" (boosting enabled). -Reading the file is always supported, even if the processor does not -support boosting. In this case the file will be read-only and always -reads as "0". Explicitly changing the permissions and writing to that -file anyway will return EINVAL. +The file is exported only when cpufreq driver supports boosting. +Explicitly changing the permissions and writing to that file anyway will +return EINVAL. On supported CPUs one can write either a "0" or a "1" into this file. This will either disable the boost functionality on all cores in the -whole system (0) or will allow the hardware to boost at will (1). +whole system (0) or will allow the software or hardware to boost at will +(1). Writing a "1" does not explicitly boost the system, but just allows the -CPU (and the firmware) to boost at their discretion. Some implementations -take external factors like the chip's temperature into account, so -boosting once does not necessarily mean that it will occur every time -even using the exact same software setup. +CPU to boost at their discretion. Some implementations take external +factors like the chip's temperature into account, so boosting once does +not necessarily mean that it will occur every time even using the exact +same software setup. AMD legacy cpb switch
Signature · 1 line
1.7.10.4
PATCH v10 6/7 cpufreq:exynos4x12: Change L0 driver data to CPUFREQ_BOOST_FREQ
In reply to Lukasz MajewskiSpecial driver data flag (CPUFREQ_BOOST_FREQ) has been added to indicate frequency, which can be only enabled for BOOST mode.
This frequency shall be used only for limited time, since it might cause target device to overheat.
---
Changes for v10:
- None
Changes for v9:
- None
Changes for v8:
- None
Changes for v7:
- None
Changes for v6:
- New patch
drivers/cpufreq/exynos4x12-cpufreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/exynos4x12-cpufreq.c +1 -1
@@ -32,7 +32,7 @@ static unsigned int exynos4x12_volt_table[] = { };static struct cpufreq_frequency_table exynos4x12_freq_table[] = { - {L0 ,CPUFREQ_ENTRY_INVALID }, + {CPUFREQ_BOOST_FREQ ,1500 *1000 }, {L1 ,1400 *1000 }, {L2 ,1300 *1000 }, {L3 ,1200 *1000 },
Signature · 1 line
1.7.10.4
PATCH v10 7/7 thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
In reply to Lukasz MajewskiThis patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis.
A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
---
Changes for v10:
- Remove boost related code from thermal_core.c
- Use already present thermal infrastructure to provide thermal hysteresis
- Introduce special set of TMU data for BOOST
Changes for v9:
- None
Changes for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) to cpufreq.h at cpufreq core support commit
Changes for v7:
- None
Changes for v6:
- Disable boost only when supported and enabled
- Protect boost related thermal_zone_device struct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used when CONFIG_CPU_FREQ is NOT defined.
Changes for v5:
- Move boost disable code from cpu_cooling.c to thermal_core.c
(to handle_non_critical_trips)
- Extent struct thermal_zone_device by adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduce boost_polling flag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Changes for v4:
- New patch
drivers/thermal/samsung/exynos_tmu_data.c | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
drivers/thermal/samsung/exynos_tmu_data.c +47 -0
@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = { .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ TMU_SUPPORT_EMUL_TIME) + +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ + TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ + TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 1 line
1.7.10.4
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hi Eduardo, Zhang,
Quoted 8 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>
Quoted 6 lines
---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide thermal
hysteresis
- Introduce special set of TMU data for BOOST
Eduardo, Zhang any comments on this patch?
Quoted 106 lines
Changes for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when
cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with
mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non
critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses
it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Changes for v4:
- New patchdrivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c(quoted diff) +0
-0@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers
exynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION|TMU_SUPPORT_TRIM_RELOAD| \TMU_SUPPORT_FALLING_TRIP|TMU_SUPPORT_READY_STATUS| \TMU_SUPPORT_EMUL_TIME)drivers/thermal/samsung/exynos_tmu_data.c +41
-0+ +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD| \
(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \drivers/thermal/samsung/exynos_tmu_data.c +5
-0+ TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
In reply to Lukasz MajewskiQuoted 4 lines · Lukasz Majewski
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis.
A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Can you please add more description why you need a different set of thermal data when boost is enabled? This is also important in case you (Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.
Quoted 39 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide thermal hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c
(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Quoted 2 lines
Changes for v4:
- New patch
Might be interesting to see the changelog for this patch only.
Quoted 70 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)drivers/thermal/samsung/exynos_tmu_data.c +47
-0@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers exynos4412_tmu_registers = { .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ TMU_SUPPORT_EMUL_TIME) + +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \ + TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ + TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hi Eduardo,
Quoted 8 lines · Lukasz Majewski
Quoted 4 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.
Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Quoted 46 lines
Quoted 46 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide thermal
hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when
cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with
mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non
critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool
flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses
it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.
Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.
If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c(quoted diff) +0
-0@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers
exynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION|TMU_SUPPORT_TRIM_RELOAD| \TMU_SUPPORT_FALLING_TRIP|TMU_SUPPORT_READY_STATUS| \TMU_SUPPORT_EMUL_TIME)drivers/thermal/samsung/exynos_tmu_data.c +41
-0+ +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \drivers/thermal/samsung/exynos_tmu_data.c +5
-0+ TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Quoted 8 lines · Lukasz Majewski
Hi Eduardo,
Quoted 6 lines · Lukasz Majewski
Quoted 4 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Quoted 6 lines
Quoted 2 lines
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
So, the difference is only the hysteresis?
Quoted 3 lines
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Ok... But still I didn't get what you needed to modify and why.. Sorry I jumped in the middle of ongoing discussion.
Quoted 7 lines
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and
freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.
Quoted 7 lines
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Well, good that it does not break anything, right?
But, My point, Lukasz, is that I am failing to understand, based on your patch and description why we need a different data definition, one for boost, other for without boost. Can you help me to get your intention with this patch properly?
Side question is what happens in runtime if user echo 0 > boost? Should we switch the data within the driver? Would we be penalizing performance with strict hysteresis while we could be allowing longer periods of high frequency usage? See what I am missing? Maybe we actually need something else a part from defining one data structure for boost other for non-boost systems.
Quoted 141 lines
Quoted 47 lines
Quoted 47 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide thermal
hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when
cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with
mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the non
critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool
flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal uses
it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c(quoted diff) +0
-0@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers
exynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION|TMU_SUPPORT_TRIM_RELOAD| \TMU_SUPPORT_FALLING_TRIP|TMU_SUPPORT_READY_STATUS| \TMU_SUPPORT_EMUL_TIME)drivers/thermal/samsung/exynos_tmu_data.c +41
-0+ +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \drivers/thermal/samsung/exynos_tmu_data.c +5
-0+ TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hi Eduardo,
Quoted 40 lines · Lukasz Majewski
Quoted 8 lines
Hi Eduardo,
Quoted 6 lines · Lukasz Majewski
Quoted 4 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Quoted 6 lines
Quoted 2 lines
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
So, the difference is only the hysteresis?
Quoted 3 lines
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Ok... But still I didn't get what you needed to modify and why.. Sorry I jumped in the middle of ongoing discussion.
Quoted 7 lines
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and
freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.Quoted 7 lines
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Quoted 6 lines
Well, good that it does not break anything, right?
But, My point, Lukasz, is that I am failing to understand, based on your patch and description why we need a different data definition, one for boost, other for without boost. Can you help me to get your intention with this patch properly?
I reduce the trigger_level[0] and set new .freq_table[0] entry. It works as follow (for BOOST):
1. Non-boost freq is 1.4 GHz on Exynos4412. BOOST is 1.5GHz. The BOOST itself is enabled by CONFIG_CPU_FREQ_BOOST_SW.
2. Exynos TMU driver reaches the lower TMU level (70 deg). Then the core thermal looks for proper frequency table (.freq_tab[0]). If the .temp_level matches the trigger_levels[0], then the frequency is reduced to .freq_clip_max = 1400 * 1000.
When the device cools down to 60 deg (trigger_levels[0] - threshold_falling), then the max freq is restored to 1.5 GHz. This is done automatically by thermal core.
For BOOST disabled we only can run with 1.4 GHz freq. For this reason the freq_tab[X] entries must be modified. Also the Exynos part of thermal requires that trigger_levels[0] is the lowest temperature trip, so I cannot add the "BOOST disable" temp level in the end of TMU_DATA_BOOST.
Quoted 2 lines
Side question is what happens in runtime if user echo 0 > boost?
As we had agreed with Rafael and Viresh, we are here mimic the HW CPUs behaviour (like Intel CPU).
When user writes 'echo 0 > boost' then at cpufreq core we switch to max freq to 1.4 GHz.
Thermal here is only for safety reasons.
Quoted 1 line
Should we switch the data within the driver?
No. When one decides to enable CONFIG_CPU_FREQ_BOOST_SW, then corresponding Exynos data are persistent.
Quoted 3 lines
Would we be penalizing
performance with strict hysteresis while we could be allowing longer periods of high frequency usage?
But the hysteresis shows up only for emergency - when we go out from allowed power envelope.
The BOOST is a component of LAB governor, which takes into account the number of running cores. The "normal" BOOST use case is a situation when at most two cores are running and other are down.
In this situation we can use BOOST to finish work faster.
Quoted 3 lines
See what I am missing? Maybe we
actually need something else a part from defining one data structure for boost other for non-boost systems.
I'm open for suggestions.
The current proposal aims to change TMU data only for target SoC - Exynos4412 in this case. I deliberately don't touch the thermal core code.
Quoted 144 lines
Quoted 142 lines
Quoted 48 lines
Quoted 48 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide
thermal hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when
cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with
mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the
non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool
flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal
uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c(quoted diff) +0
-0@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers
exynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION|TMU_SUPPORT_TRIM_RELOAD| \TMU_SUPPORT_FALLING_TRIP|TMU_SUPPORT_READY_STATUS| \TMU_SUPPORT_EMUL_TIME)drivers/thermal/samsung/exynos_tmu_data.c +41
-0+ +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \drivers/thermal/samsung/exynos_tmu_data.c +5
-0+ TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 6 lines
-- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hey Lukasz!,
Quoted 64 lines · Lukasz Majewski
Hi Eduardo,
Quoted 40 lines · Lukasz Majewski
Quoted 8 lines
Hi Eduardo,
Quoted 6 lines · Lukasz Majewski
Quoted 4 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Quoted 6 lines
Quoted 2 lines
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
So, the difference is only the hysteresis?
Quoted 3 lines
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Ok... But still I didn't get what you needed to modify and why.. Sorry I jumped in the middle of ongoing discussion.
Quoted 7 lines
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and
freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.Quoted 7 lines
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Quoted 6 lines
Well, good that it does not break anything, right?
But, My point, Lukasz, is that I am failing to understand, based on your patch and description why we need a different data definition, one for boost, other for without boost. Can you help me to get your intention with this patch properly?
I reduce the trigger_level[0] and set new .freq_table[0] entry. It works as follow (for BOOST):
1. Non-boost freq is 1.4 GHz on Exynos4412. BOOST is 1.5GHz. The BOOST itself is enabled by
CONFIG_CPU_FREQ_BOOST_SW.2. Exynos TMU driver reaches the lower TMU level (70 deg). Then the core thermal looks for proper frequency table (.freq_tab[0]). If the .temp_level matches the trigger_levels[0], then the frequency is reduced to .freq_clip_max = 1400 * 1000.
When the device cools down to 60 deg (trigger_levels[0] -
threshold_falling), then the max freq is restored to 1.5 GHz. This is done automatically by thermal core.
Quoted 5 lines
For BOOST disabled we only can run with 1.4 GHz freq. For this reason the freq_tab[X] entries must be modified. Also the Exynos part of thermal requires that trigger_levels[0] is the lowest temperature trip, so I cannot add the "BOOST disable" temp level in the end of
TMU_DATA_BOOST.
OK. The entire thing is to allow dynamic control on your speedbin frequencies, I see. What bugs me, is that this themal driver keeps another table of frequencies. Ideally, it should not care about it, but about the thermal behavior changes, meaning, say, how fast your temperature rises, when you jump from lowest opp to 1.4GHz or 1.5GHz, on host process or cold process samples.
Quoted 6 lines
Quoted 3 lines
Side question is what happens in runtime if user echo 0 > boost?
As we had agreed with Rafael and Viresh, we are here mimic the HW CPUs behaviour (like Intel CPU).
Which is fine and expected.
Quoted 2 lines
When user writes 'echo 0 > boost' then at cpufreq core we switch to max freq to 1.4 GHz.
OK.
Quoted 24 lines
Thermal here is only for safety reasons.
Quoted 1 line
Should we switch the data within the driver?
No. When one decides to enable
CONFIG_CPU_FREQ_BOOST_SW, then corresponding Exynos data are persistent.Quoted 3 lines
Would we be penalizing
performance with strict hysteresis while we could be allowing longer periods of high frequency usage?But the hysteresis shows up only for emergency - when we go out from allowed power envelope.
The BOOST is a component of LAB governor, which takes into account the number of running cores. The "normal" BOOST use case is a situation when at most two cores are running and other are down.
In this situation we can use BOOST to finish work faster.Quoted 3 lines
See what I am missing? Maybe we
actually need something else a part from defining one data structure for boost other for non-boost systems.
Quoted 5 lines
I'm open for suggestions.
The current proposal aims to change TMU data only for target SoC - Exynos4412 in this case. I deliberately don't touch the thermal core code.
In fact, I see.
I am just wondering if it makes sense to simply use the data that represents BOOST always. Wouldn't be same as in the situation where user echo 0 > boost?
Quoted 148 lines
Quoted 145 lines
Quoted 143 lines
Quoted 49 lines
Quoted 49 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide
thermal hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed when
cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields with
mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the
non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated bool
flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal
uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c(quoted diff) +0
-0@@ -167,13 +167,60 @@ static const struct exynos_tmu_registers
exynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION|TMU_SUPPORT_TRIM_RELOAD| \TMU_SUPPORT_FALLING_TRIP|TMU_SUPPORT_READY_STATUS| \TMU_SUPPORT_EMUL_TIME)drivers/thermal/samsung/exynos_tmu_data.c +41
-0+ +#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \drivers/thermal/samsung/exynos_tmu_data.c +5
-0+ TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data = { .tmu_data = { { +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hi Eduardo,
Quoted 68 lines
Hey Lukasz!,
Quoted 65 lines · Lukasz Majewski
Hi Eduardo,
Quoted 41 lines · Lukasz Majewski
Quoted 8 lines
Hi Eduardo,
Quoted 6 lines · Lukasz Majewski
Quoted 4 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Quoted 6 lines
Quoted 2 lines
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
So, the difference is only the hysteresis?
Quoted 3 lines
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Ok... But still I didn't get what you needed to modify and why.. Sorry I jumped in the middle of ongoing discussion.
Quoted 7 lines
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and
freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.Quoted 8 lines
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Quoted 6 lines
Well, good that it does not break anything, right?
But, My point, Lukasz, is that I am failing to understand, based on your patch and description why we need a different data definition, one for boost, other for without boost. Can you help me to get your intention with this patch properly?
I reduce the trigger_level[0] and set new .freq_table[0] entry. It works as follow (for BOOST):
1. Non-boost freq is 1.4 GHz on Exynos4412. BOOST is 1.5GHz. The BOOST itself is enabled by
CONFIG_CPU_FREQ_BOOST_SW.2. Exynos TMU driver reaches the lower TMU level (70 deg). Then the core thermal looks for proper frequency table (.freq_tab[0]). If the .temp_level matches the trigger_levels[0], then the frequency is reduced to .freq_clip_max = 1400 * 1000.
When the device cools down to 60 deg (trigger_levels[0] -
threshold_falling), then the max freq is restored to 1.5 GHz. This is done automatically by thermal core.
Quoted 8 lines
Quoted 5 lines
For BOOST disabled we only can run with 1.4 GHz freq. For this reason the freq_tab[X] entries must be modified. Also the Exynos part of thermal requires that trigger_levels[0] is the lowest temperature trip, so I cannot add the "BOOST disable" temp level in the end of
TMU_DATA_BOOST.OK. The entire thing is to allow dynamic control on your speedbin frequencies, I see.
Yes, correct.
Quoted 2 lines
What bugs me, is that this themal driver keeps
another table of frequencies.
Yes, it does. It is the part of thermal_cooling_conf data.
It is a very practical solution, since we can specify the threshold temperature and corresponding maximal frequency (up to 8 values).
Those values are afterwards used at exynos_bind to bind zone to cooling device.
Quoted 1 line
Ideally, it should not care about it,
The above procedure is a part of passive cooling implementation for Exynos.
Quoted 3 lines
but about the thermal behavior changes, meaning, say, how fast your temperature rises, when you jump from lowest opp to 1.4GHz or 1.5GHz, on host process or cold process samples.
Could you be more specific here? I assume that you are asking if slope of the temperature rise has been measured?
I didn't measure this value, since it depends on the work environment (number of processes running, ambient temperature, current SoC temperature, etc.) and thereof is hard to reproduce.
However, the exynos_thermal_common.c defines .get_trend callback. Unfortunately it only gives an information about the trend (rising, falling). The exact slope value is not given.
Personally I think, that the slope measurement is not relevant for the BOOST.
Quoted 46 lines
Quoted 7 lines
Quoted 4 lines
Side question is what happens in runtime if user echo 0 > boost?
As we had agreed with Rafael and Viresh, we are here mimic the HW CPUs behaviour (like Intel CPU).
Which is fine and expected.
Quoted 2 lines
When user writes 'echo 0 > boost' then at cpufreq core we switch to max freq to 1.4 GHz.
OK.
Quoted 24 lines
Thermal here is only for safety reasons.
Quoted 1 line
Should we switch the data within the driver?
No. When one decides to enable
CONFIG_CPU_FREQ_BOOST_SW, then corresponding Exynos data are persistent.Quoted 3 lines
Would we be penalizing
performance with strict hysteresis while we could be allowing longer periods of high frequency usage?But the hysteresis shows up only for emergency - when we go out from allowed power envelope.
The BOOST is a component of LAB governor, which takes into account the number of running cores. The "normal" BOOST use case is a situation when at most two cores are running and other are down. In this situation we can use BOOST to finish work faster.
Quoted 3 lines
See what I am missing? Maybe we
actually need something else a part from defining one data structure for boost other for non-boost systems.Quoted 5 lines
I'm open for suggestions.
The current proposal aims to change TMU data only for target SoC - Exynos4412 in this case. I deliberately don't touch the thermal core code.
Quoted 6 lines
In fact, I see.
I am just wondering if it makes sense to simply use the data that represents BOOST always.
Wouldn't be same as in the situation where
user echo 0 > boost?
I think I get your point here. You would like to reuse the NON BOOST value when user types echo 0 > boost.
The problem is that we would need some kind of notification from cpufreq subsystem to thermal that such change was done. This seems like an overkill, and in my opinion it is better to use thermal without such notification.
To be more specific, the thermal already implements the required functionality and we "only" need to came up with an idea how to appropriately feed data.
Quoted 151 lines
Quoted 149 lines
Quoted 146 lines
Quoted 144 lines
Quoted 50 lines
Quoted 50 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide
thermal hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed
when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields
with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the
non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated
bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal
uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c@@ -167,13 +167,60 @@ static const structexynos_tmu_registersexynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION| TMU_SUPPORT_TRIM_RELOAD | \ TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ TMU_SUPPORT_EMUL_TIME) +drivers/thermal/samsung/exynos_tmu_data.c +40
-0+#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \drivers/thermal/samsung/exynos_tmu_data.c +1
-0+ TMU_SUPPORT_EMUL_TIME)#endif #if defined(CONFIG_SOC_EXYNOS4412 )struct exynos_tmu_init_data const exynos4412_default_tmu_data= { .tmu_data = {
drivers/thermal/samsung/exynos_tmu_data.c +4
-0{ +#ifdef CONFIG_CPU_FREQ_BOOST_SW +EXYNOS4412_TMU_DATA_BOOST , +#else EXYNOS4412_TMU_DATA, +#endif .type =SOC_ARCH_EXYNOS4412 , .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hey Lukasz,
Quoted 171 lines · Lukasz Majewski
Hi Eduardo,
Quoted 68 lines
Hey Lukasz!,
Quoted 65 lines · Lukasz Majewski
Hi Eduardo,
Quoted 41 lines · Lukasz Majewski
Quoted 8 lines
Hi Eduardo,
Quoted 6 lines · Lukasz Majewski
Quoted 4 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Quoted 6 lines
Quoted 2 lines
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
So, the difference is only the hysteresis?
Quoted 3 lines
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Ok... But still I didn't get what you needed to modify and why.. Sorry I jumped in the middle of ongoing discussion.
Quoted 7 lines
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and
freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.Quoted 8 lines
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Quoted 6 lines
Well, good that it does not break anything, right?
But, My point, Lukasz, is that I am failing to understand, based on your patch and description why we need a different data definition, one for boost, other for without boost. Can you help me to get your intention with this patch properly?
I reduce the trigger_level[0] and set new .freq_table[0] entry. It works as follow (for BOOST):
1. Non-boost freq is 1.4 GHz on Exynos4412. BOOST is 1.5GHz. The BOOST itself is enabled by
CONFIG_CPU_FREQ_BOOST_SW.2. Exynos TMU driver reaches the lower TMU level (70 deg). Then the core thermal looks for proper frequency table (.freq_tab[0]). If the .temp_level matches the trigger_levels[0], then the frequency is reduced to .freq_clip_max = 1400 * 1000.
When the device cools down to 60 deg (trigger_levels[0] -
threshold_falling), then the max freq is restored to 1.5 GHz. This is done automatically by thermal core.Quoted 8 lines
Quoted 5 lines
For BOOST disabled we only can run with 1.4 GHz freq. For this reason the freq_tab[X] entries must be modified. Also the Exynos part of thermal requires that trigger_levels[0] is the lowest temperature trip, so I cannot add the "BOOST disable" temp level in the end of
TMU_DATA_BOOST.OK. The entire thing is to allow dynamic control on your speedbin frequencies, I see.
Yes, correct.
Quoted 2 lines
What bugs me, is that this themal driver keeps
another table of frequencies.Yes, it does. It is the part of
thermal_cooling_confdata.It is a very practical solution, since we can specify the threshold temperature and corresponding maximal frequency (up to 8 values).
Those values are afterwards used at
exynos_bindto bind zone to cooling device.Quoted 1 line
Ideally, it should not care about it,
The above procedure is a part of passive cooling implementation for Exynos.
Quoted 3 lines
but about the thermal behavior changes, meaning, say, how fast your temperature rises, when you jump from lowest opp to 1.4GHz or 1.5GHz, on host process or cold process samples.
Could you be more specific here? I assume that you are asking if slope of the temperature rise has been measured?
I didn't measure this value, since it depends on the work environment (number of processes running, ambient temperature, current SoC temperature, etc.) and thereof is hard to reproduce.
However, the
exynos_thermal_common.cdefines .get_trend callback. Unfortunately it only gives an information about the trend (rising, falling). The exact slope value is not given.Personally I think, that the slope measurement is not relevant for the BOOST.
Quoted 46 lines
Quoted 7 lines
Quoted 4 lines
Side question is what happens in runtime if user echo 0 > boost?
As we had agreed with Rafael and Viresh, we are here mimic the HW CPUs behaviour (like Intel CPU).
Which is fine and expected.
Quoted 2 lines
When user writes 'echo 0 > boost' then at cpufreq core we switch to max freq to 1.4 GHz.
OK.
Quoted 24 lines
Thermal here is only for safety reasons.
Quoted 1 line
Should we switch the data within the driver?
No. When one decides to enable
CONFIG_CPU_FREQ_BOOST_SW, then corresponding Exynos data are persistent.Quoted 3 lines
Would we be penalizing
performance with strict hysteresis while we could be allowing longer periods of high frequency usage?But the hysteresis shows up only for emergency - when we go out from allowed power envelope.
The BOOST is a component of LAB governor, which takes into account the number of running cores. The "normal" BOOST use case is a situation when at most two cores are running and other are down. In this situation we can use BOOST to finish work faster.
Quoted 3 lines
See what I am missing? Maybe we
actually need something else a part from defining one data structure for boost other for non-boost systems.Quoted 5 lines
I'm open for suggestions.
The current proposal aims to change TMU data only for target SoC - Exynos4412 in this case. I deliberately don't touch the thermal core code.
Quoted 6 lines
In fact, I see.
I am just wondering if it makes sense to simply use the data that represents BOOST always.
Wouldn't be same as in the situation where
user echo 0 > boost?I think I get your point here. You would like to reuse the NON BOOST value when user types echo 0 > boost.
Quoted 7 lines
The problem is that we would need some kind of notification from cpufreq subsystem to thermal that such change was done. This seems like an overkill, and in my opinion it is better to use thermal without such notification.
To be more specific, the thermal already implements the required functionality and we "only" need to came up with an idea how to appropriately feed data.
Well, the real problem is that this driver relies on data structures that duplicates cpufreq data and thermal core data. So, every time you have a new speedbin frequency, you have to update at least two - three places to make sure everything is correct.
My point is not exactly that I am suggesting to reuse the non-boost data. My point is that temperature constraints do not change if you are using boost or non-boost frequencies. Your temperature trip points will be the same, because your silicon still is gonna start to break if cross the line. And that is what I mean when I say, the thermal driver should be aware of temperature constraints, not frequencies. At most, the cooling device should be aware of frequencies, not thermal driver.
About the current patch proposal, still, would it work if you only use BOOST data? Even on non-boost devices? Apparently yes, as you use BOOST data when boost is disabled. So, that was my point here, why not using only boost data, regardless of config?
Quoted 154 lines
Quoted 152 lines
Quoted 150 lines
Quoted 147 lines
Quoted 145 lines
Quoted 51 lines
Quoted 51 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide
thermal hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed
when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields
with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only the
non critical one)
- Add stub definitions for cpufreq boost functions used whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated
bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal
uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c@@ -167,13 +167,60 @@ static const structexynos_tmu_registersexynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION| TMU_SUPPORT_TRIM_RELOAD | \ TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \ TMU_SUPPORT_EMUL_TIME) +(quoted diff) +40
-0+#define EXYNOS4412_TMU_DATA_BOOST \ + .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \(quoted diff) +1
-0+ TMU_SUPPORT_EMUL_TIME) #endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data= { .tmu_data = {
(quoted diff) +4
-0{ +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux = EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 3 lines
You have got to be excited about what you are doing. (L. Lamport) Eduardo Valentin
Re: [PATCH v10 7/7] thermal:exynos:boost: Automatic enable/disable of BOOST feature (at Exynos4412)
Hi Eduardo,
Quoted 183 lines
Hey Lukasz,
Quoted 172 lines · Lukasz Majewski
Hi Eduardo,
Quoted 69 lines
Hey Lukasz!,
Quoted 66 lines · Lukasz Majewski
Hi Eduardo,
Quoted 42 lines · Lukasz Majewski
Quoted 9 lines
Hi Eduardo,
Quoted 7 lines · Lukasz Majewski
Quoted 5 lines
This patch provides auto disable/enable operation for boost. It uses already present thermal infrastructure to provide boost hysteresis. A special set of TMU data has been defined for Exynos4412, which is only considered when BOOST is enabled.
Quoted 6 lines
Quoted 2 lines
Can you please add more description why you need a different set of thermal data when boost is enabled?
It turned out that the Thermal subsystem (after rework done for v3.12) is capable of providing hysteresis for BOOST.
So, the difference is only the hysteresis?
Quoted 3 lines
For version of the patch up to v8 I had to modify the thermal core to provide such functionality. Changes in core weren't accepted by Zhang Rui.
Ok... But still I didn't get what you needed to modify and why.. Sorry I jumped in the middle of ongoing discussion.
Quoted 7 lines
Then I've looked again to the code and it turned out that proper setting of Exynos4x12 data (like trigger levels and
freq_clip_max) can solve the problem in a much better way by using Exynos thermal interrupts.
Another advantage is that those changes are done per device.Quoted 8 lines
Quoted 3 lines
This is also important in case you
(Exynos thermal folks) would like to migrate this driver to have thermal data support in DT.Some work on this driver is ongoing (mainly done by Bartek Zolnierkiewicz). This BOOST change doesn't break anything and only extend the current thermal code. Thereof it will not break anything.
Quoted 6 lines
Well, good that it does not break anything, right?
But, My point, Lukasz, is that I am failing to understand, based on your patch and description why we need a different data definition, one for boost, other for without boost. Can you help me to get your intention with this patch properly?
I reduce the trigger_level[0] and set new .freq_table[0] entry. It works as follow (for BOOST):
1. Non-boost freq is 1.4 GHz on Exynos4412. BOOST is 1.5GHz. The BOOST itself is enabled by
CONFIG_CPU_FREQ_BOOST_SW.2. Exynos TMU driver reaches the lower TMU level (70 deg). Then the core thermal looks for proper frequency table (.freq_tab[0]). If the .temp_level matches the trigger_levels[0], then the frequency is reduced to .freq_clip_max = 1400 * 1000.
When the device cools down to 60 deg (trigger_levels[0] -
threshold_falling), then the max freq is restored to 1.5 GHz. This is done automatically by thermal core.Quoted 8 lines
Quoted 5 lines
For BOOST disabled we only can run with 1.4 GHz freq. For this reason the freq_tab[X] entries must be modified. Also the Exynos part of thermal requires that trigger_levels[0] is the lowest temperature trip, so I cannot add the "BOOST disable" temp level in the end of
TMU_DATA_BOOST.OK. The entire thing is to allow dynamic control on your speedbin frequencies, I see.
Yes, correct.
Quoted 2 lines
What bugs me, is that this themal driver keeps
another table of frequencies.Yes, it does. It is the part of
thermal_cooling_confdata.It is a very practical solution, since we can specify the threshold temperature and corresponding maximal frequency (up to 8 values).
Those values are afterwards used at
exynos_bindto bind zone to cooling device.Quoted 1 line
Ideally, it should not care about it,
The above procedure is a part of passive cooling implementation for Exynos.
Quoted 3 lines
but about the thermal behavior changes, meaning, say, how fast your temperature rises, when you jump from lowest opp to 1.4GHz or 1.5GHz, on host process or cold process samples.
Could you be more specific here? I assume that you are asking if slope of the temperature rise has been measured?
I didn't measure this value, since it depends on the work environment (number of processes running, ambient temperature, current SoC temperature, etc.) and thereof is hard to reproduce.
However, the
exynos_thermal_common.cdefines .get_trend callback. Unfortunately it only gives an information about the trend (rising, falling). The exact slope value is not given.Personally I think, that the slope measurement is not relevant for the BOOST.
Quoted 46 lines
Quoted 7 lines
Quoted 4 lines
Side question is what happens in runtime if user echo 0 > boost?
As we had agreed with Rafael and Viresh, we are here mimic the HW CPUs behaviour (like Intel CPU).
Which is fine and expected.
Quoted 2 lines
When user writes 'echo 0 > boost' then at cpufreq core we switch to max freq to 1.4 GHz.
OK.
Quoted 24 lines
Thermal here is only for safety reasons.
Quoted 1 line
Should we switch the data within the driver?
No. When one decides to enable
CONFIG_CPU_FREQ_BOOST_SW, then corresponding Exynos data are persistent.Quoted 3 lines
Would we be penalizing
performance with strict hysteresis while we could be allowing longer periods of high frequency usage?But the hysteresis shows up only for emergency - when we go out from allowed power envelope.
The BOOST is a component of LAB governor, which takes into account the number of running cores. The "normal" BOOST use case is a situation when at most two cores are running and other are down. In this situation we can use BOOST to finish work faster.
Quoted 3 lines
See what I am missing? Maybe we
actually need something else a part from defining one data structure for boost other for non-boost systems.Quoted 5 lines
I'm open for suggestions.
The current proposal aims to change TMU data only for target SoC - Exynos4412 in this case. I deliberately don't touch the thermal core code.
Quoted 6 lines
In fact, I see.
I am just wondering if it makes sense to simply use the data that represents BOOST always.
Wouldn't be same as in the situation where
user echo 0 > boost?I think I get your point here. You would like to reuse the NON BOOST value when user types echo 0 > boost.
Quoted 7 lines
The problem is that we would need some kind of notification from cpufreq subsystem to thermal that such change was done. This seems like an overkill, and in my opinion it is better to use thermal without such notification.
To be more specific, the thermal already implements the required functionality and we "only" need to came up with an idea how to appropriately feed data.
Quoted 4 lines
Well, the real problem is that this driver relies on data structures that duplicates cpufreq data and thermal core data. So, every time you have a new speedbin frequency, you have to update at least two - three places to make sure everything is correct.
Exynos thermal driver exposes such API. It was quite straightforward to use it for BOOST.
Quoted 9 lines
My point is not exactly that I am suggesting to reuse the non-boost data. My point is that temperature constraints do not change if you are using boost or non-boost frequencies. Your temperature trip points will be the same, because your silicon still is gonna start to break if cross the line. And that is what I mean when I say, the thermal driver should be aware of temperature constraints, not frequencies. At most, the cooling device should be aware of frequencies, not thermal driver.
Ok, I get it.
Quoted 5 lines
About the current patch proposal, still, would it work if you only use BOOST data? Even on non-boost devices? Apparently yes, as you use BOOST data when boost is disabled. So, that was my point here, why not using only boost data, regardless of config?
Good point. I will try to look for one Exynos data set solution.
I need to double check some issues.
Stay tunned for patch :-).
Quoted 157 lines
Quoted 155 lines
Quoted 153 lines
Quoted 151 lines
Quoted 148 lines
Quoted 146 lines
Quoted 52 lines
Quoted 52 lines
Signed-off-by Lukasz Majewski <[email protected]>Signed-off-by Myungjoo Ham <[email protected]>---
Changes for v10:
- Remove boost related code fromthermal_core.c
- Use already present thermal infrastructure to provide
thermal hysteresis
- Introduce special set of TMU data for BOOSTChanges for v9:
- NoneChanges for v8:
- Move cpufreq_boost_* stub functions definition (needed
when cpufreq is not compiled in) tocpufreq.hat cpufreq core support commitChanges for v7:
- NoneChanges for v6:
- Disable boost only when supported and enabled
- Protect boost relatedthermal_zone_devicestruct fields
with mutex
- Evaluate temperature trend during boost enable decision
- Create separate methods to handle boost enable/disable (thermal_boost_{enable|disable}) operations
- Boost is disabled at any trip point passage (not only
the non critical one)
- Add stub definitions for cpufreq boost functions used
whenCONFIG_CPU_FREQis NOT defined.Changes for v5:
- Move boost disable code fromcpu_cooling.ctothermal_core.c(tohandle_non_critical_trips)
- Extent structthermal_zone_deviceby adding overheated
bool flag
- Implement auto enable of boost after device cools down
- Introduceboost_pollingflag, which indicates if thermal
uses it's predefined pool delay or has woken up thermal workqueue only to wait until device cools down.Quoted 5 lines
Quoted 2 lines
Changes for v4:
- New patchMight be interesting to see the changelog for this patch only.
The above list presents the development state of this particular patch (thermal).
Up to v8 I had modified the thermal core. For v10 I've decided to use proper Exynos data setting.If in any doubt, please ask.
This last thermal patch of the series hinders this code to be applied to cpufreq subsystem (Viresh had acked it some time ago and I hope that he hasn't changed his mind :-) ).
Quoted 75 lines
Quoted 73 lines
drivers/thermal/samsung/exynos_tmu_data.c | 47+++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
(quoted diff) +0
-0
b/drivers/thermal/samsung/exynos_tmu_data.cindex 073c292..9346926 100644 ---a/drivers/thermal/samsung/exynos_tmu_data.c+++b/drivers/thermal/samsung/exynos_tmu_data.c@@ -167,13 +167,60 @@ static const structexynos_tmu_registersexynos4412_tmu_registers= { .features = (TMU_SUPPORT_EMULATION|TMU_SUPPORT_TRIM_RELOAD| \TMU_SUPPORT_FALLING_TRIP|TMU_SUPPORT_READY_STATUS| \TMU_SUPPORT_EMUL_TIME) + +#defineEXYNOS4412_TMU_DATA_BOOST\(quoted diff) +39
-0+ .threshold_falling = 10, \ + .trigger_levels[0] = 70, \ + .trigger_levels[1] = 85, \ + .trigger_levels[2] = 103, \ + .trigger_levels[3] = 110, \ + .trigger_enable[0] = true, \ + .trigger_enable[1] = true, \ + .trigger_enable[2] = true, \ + .trigger_enable[3] = true, \ + .trigger_type[0] = THROTTLE_ACTIVE, \ + .trigger_type[1] = THROTTLE_ACTIVE, \ + .trigger_type[2] = THROTTLE_ACTIVE, \ + .trigger_type[3] = SW_TRIP, \ + .max_trigger_level = 4, \ + .gain = 8, \ + .reference_voltage = 16, \ + .noise_cancel_mode = 4, \ + .cal_type = TYPE_ONE_POINT_TRIMMING, \ + .efuse_value = 55, \ + .min_efuse_value = 40, \ + .max_efuse_value = 100, \ + .first_point_trim = 25, \ + .second_point_trim = 85, \ + .default_temp_offset = 50, \ + .freq_tab[0] = { \ + .freq_clip_max = 1400 * 1000, \ + .temp_level = 70, \ + }, \ + .freq_tab[1] = { \ + .freq_clip_max = 800 * 1000, \ + .temp_level = 85, \ + }, \ + .freq_tab[2] = { \ + .freq_clip_max = 200 * 1000, \ + .temp_level = 103, \ + }, \ + .freq_tab_count = 3, \ + .registers = &exynos4412_tmu_registers, \ + .features = (TMU_SUPPORT_EMULATION |
TMU_SUPPORT_TRIM_RELOAD| \(quoted diff) +1
-0+ TMU_SUPPORT_FALLING_TRIP |
TMU_SUPPORT_READY_STATUS| \(quoted diff) +1
-0+ TMU_SUPPORT_EMUL_TIME) #endif #if defined(CONFIG_SOC_EXYNOS4412) struct exynos_tmu_init_data const exynos4412_default_tmu_data= { .tmu_data = {
(quoted diff) +4
-0{ +#ifdef CONFIG_CPU_FREQ_BOOST_SW + EXYNOS4412_TMU_DATA_BOOST, +#else EXYNOS4412_TMU_DATA, +#endif .type = SOC_ARCH_EXYNOS4412, .test_mux =
EXYNOS4412_MUX_ADDR_VALUE, },
Signature · 5 lines
Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group