thermal, OPP: move the CPU power estimation to the OPP library
Subsystems (3)
v2 cover thermal, OPP: move the CPU power estimation to the OPP library
Hi,
Currently, IPA estimates the power dissipated by a CPU at each available OPP using its capacitance (the dynamic-power-coefficient DT binding). This series relocates this per-OPP power model in the OPP core as a preparation for future changes. More specifically:
1. The current DT-based approach for power estimation will need deep changes to support SCMI-provided power values. While the thermal subsystem is not necessarily the best place to hide multiple power estimation methods, the OPP library appears to be a good candidate to implement the required platform abstraction and respect the existing design (the thermal subsystem already relies on the OPP library to provide voltages no matter where they come from -- DT or SCPI).
2. The energy models of CPUs will be needed by other clients in the future (such as the task scheduler or CPUFreq governors for example) in order to make energy-aware decisions. The relocation to the OPP library will enable code re-use and all clients will benefit form the platform abstraction mentioned previously.
As mentionned during the review of V1, this series will have a chance to get merged only when the clients (the scheduler, or the SCMI driver) depending on it are ready to be merged as well. This V2 is here for reference and addresses the main changes requested on the V1.
Changes in v2:
- Changed the OPP power estimation to be done upon OPP creation (V. Kumar)
- Updated the cover letter to motivate the choice of PM OPP (E. Valentin)
Quentin Perret (2):
PM / OPP: introduce an OPP power estimation helper
thermal: cpu_cooling: use power models from the OPP library
drivers/opp/core.c | 63 +++++++++++++++++++++++++++++++++++++++++++ drivers/opp/of.c | 13 ++++++--- drivers/opp/opp.h | 5 ++++ drivers/thermal/cpu_cooling.c | 33 +++++++---------------- include/linux/pm_opp.h | 14 ++++++++++ 5 files changed, 100 insertions(+), 28 deletions(-)
Signature · 1 line
2.15.1
PATCH v2 1/2 PM / OPP: introduce an OPP power estimation helper
The power dissipated by a CPU at a specific OPP is currently estimated by the thermal subsystem as P = C * V^2 * f, with P the power, C the CPU's capacitance, V the OPP's voltage and f the OPP's frequency. As this feature can be useful for other clients requiring energy models of CPUs, this commit introduces an equivalent power estimator directly into the OPP library, hence enabling code re-use.
--- drivers/opp/core.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/opp/of.c | 13 +++++++---- drivers/opp/opp.h | 5 ++++ include/linux/pm_opp.h | 14 +++++++++++ 4 files changed, 91 insertions(+), 4 deletions(-)
drivers/opp/core.c +63 -0
@@ -127,6 +127,24 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) }EXPORT_SYMBOL_GPL (dev_pm_opp_get_freq); +/** +* dev_pm_opp_get_power() - Gets the estimated power corresponding to an opp +* @opp: opp for which power has to be returned for +* +* Return: estimated power in mirco-watts corresponding to the opp, else +* return 0 +*/ +unsigned long dev_pm_opp_get_power (struct dev_pm_opp *opp) +{ +if (IS_ERR_OR_NULL (opp)) { +pr_err ("%s: Invalid parameters\n" , __func__); +return 0 ; + } + +return opp->power_estimate_uw; +} +EXPORT_SYMBOL_GPL (dev_pm_opp_get_power); +/** * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not * @opp: opp for which turbo mode is being verified
@@ -148,6 +166,29 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) }EXPORT_SYMBOL_GPL (dev_pm_opp_is_turbo); +/** +* dev_pm_opp_has_power() - Get the status of power values for OPPs +* @cpu_dev: CPU device for which we do this operation +* +* Return: True if the OPPs hold power estimates for the CPU +*/ +bool dev_pm_opp_has_power (struct device *cpu_dev) +{ +struct opp_table *opp_table; +bool has_power; + + opp_table =_find_opp_table (cpu_dev); +if (IS_ERR (opp_table)) +return false; + + has_power = opp_table->capacitance; + +dev_pm_opp_put_opp_table (opp_table); + +return has_power; +} +EXPORT_SYMBOL_GPL (dev_pm_opp_has_power); +/** * dev_pm_opp_get_max_clock_latency() - Get max clock latency in nanoseconds * @dev: device for which we do this operation
@@ -1112,6 +1153,8 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, goto free_opp; } +_opp_estimate_power (new_opp); +/* * Notify the changes in the availability of the operable * frequency/voltage list.
@@ -1728,6 +1771,26 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,return r; } +/** +* _opp_estimate_power() -- helper to estimate power of an OPP +* @opp: OPP for which we want to do this +* +* Estimate the power of an OPP as P = C * V^2 * f, with C the device's +* capacitance, V the OPP's voltage and f the OPP's frequency. +*/ +void _opp_estimate_power (struct dev_pm_opp *opp) +{ +unsigned long capacitance = opp->opp_table->capacitance; +unsigned long mV, KHz, uW; + +if (capacitance) { + mV = opp->supplies[0 ].u_volt /1000 ; + KHz = opp->rate /1000 ; + uW = capacitance * mV * mV * KHz /1000000000 ; + opp->power_estimate_uw = uW; + } +} +/** * dev_pm_opp_enable() - Enable a specific OPP * @dev: device for which we do this operation
drivers/opp/of.c +9 -4
@@ -55,14 +55,17 @@ void _of_init_opp_table(struct opp_table *opp_table, struct device *dev) {struct device_node *np; -/* -* Only required for backward compatibility with v1 bindings, but isn't -* harmful for other cases. And so we do it unconditionally. -*/ np =of_node_get (dev->of_node);if (np) {u32 val; +of_property_read_u32 (np,"dynamic-power-coefficient" , + &opp_table->capacitance); + +/* +* Required for backward compatibility with v1 bindings, but +* isn't harmful for other cases so we do it unconditionally. +*/ if (!of_property_read_u32 (np,"clock-latency" , &val)) opp_table->clock_latency_ns_max = val; of_property_read_u32(np, "voltage-tolerance",
@@ -336,6 +339,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, goto free_opp; } +_opp_estimate_power (new_opp); +/* OPP to select on device suspend */ if (of_property_read_bool (np,"opp-suspend" )) {if (opp_table->suspend_opp) {
drivers/opp/opp.h +5 -0
@@ -84,6 +84,8 @@ struct dev_pm_opp {unsigned long clock_latency_ns; +unsigned long power_estimate_uw; +struct opp_table *opp_table;struct device_node *np;
@@ -165,6 +167,8 @@ struct opp_table {/* For backward compatibility with v1 bindings */ unsigned int voltage_tolerance_v1; +unsigned int capacitance; +enum opp_table_access shared_opp;struct dev_pm_opp *suspend_opp;
@@ -198,6 +202,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *oint _opp_add_v1 (struct opp_table *opp_table,struct device *dev,unsigned long freq,long u_volt,bool dynamic);void _dev_pm_opp_cpumask_remove_table (const struct cpumask *cpumask,bool of);struct opp_table *_add_opp_table (struct device *dev); +void _opp_estimate_power (struct dev_pm_opp *opp);#ifdef CONFIG_OF void _of_init_opp_table (struct opp_table *opp_table,struct device *dev);
include/linux/pm_opp.h +14 -0
@@ -85,8 +85,12 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);unsigned long dev_pm_opp_get_freq (struct dev_pm_opp *opp); +unsigned long dev_pm_opp_get_power (struct dev_pm_opp *opp); +bool dev_pm_opp_is_turbo (struct dev_pm_opp *opp); +bool dev_pm_opp_has_power (struct device *cpu_dev); +int dev_pm_opp_get_opp_count (struct device *dev);unsigned long dev_pm_opp_get_max_clock_latency (struct device *dev);unsigned long dev_pm_opp_get_max_volt_latency (struct device *dev);
@@ -150,11 +154,21 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)return 0 ; } +static inline unsigned long dev_pm_opp_get_power (struct dev_pm_opp *opp) +{ +return 0 ; +} +static inline bool dev_pm_opp_is_turbo (struct dev_pm_opp *opp) {return false; } +static inline bool dev_pm_opp_has_power (struct device *cpu_dev) +{ +return false; +} +static inline int dev_pm_opp_get_opp_count (struct device *dev) {return 0 ;
Signature · 1 line
2.15.1
Re: [PATCH v2 1/2] PM / OPP: introduce an OPP power estimation helper
Quoted 12 lines · Quentin Perret
drivers/opp/core.c +12
-0+/** +* dev_pm_opp_has_power() - Get the status of power values for OPPs +* @cpu_dev: CPU device for which we do this operation +* +* Return: True if the OPPs hold power estimates for the CPU +*/ +bool dev_pm_opp_has_power (struct device *cpu_dev) +{ +struct opp_table *opp_table; +bool has_power; + + opp_table =_find_opp_table (cpu_dev);
drivers/opp/core.c bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) · line 190
Quoted 10 lines
drivers/opp/core.c +10
-0+if (IS_ERR (opp_table)) +return false; + + has_power = opp_table->capacitance; + +dev_pm_opp_put_opp_table (opp_table); + +return has_power; +} +EXPORT_SYMBOL_GPL (dev_pm_opp_has_power);
I am not sure about the worthiness of this routine right now. Users can just ask for the power and that will be 0 if it is not available.
For the thermal stuff we can just check if the right property is present or not for the device (like we used to do), if we want to avoid running extra code there.
The point is I am not sure if this will be useful to multiple users of the power numbers or not and would like to wait to see more users before adding this API.
drivers/opp/core.c int _opp_add_v1(struct opp_table *opp_table, struct device *dev, · line 1157
Quoted 9 lines
/**
*dev_pm_opp_get_max_clock_latency()- Get max clock latency in nanoseconds
* @dev: device for which we do this operationdrivers/opp/core.c +2
-0@@ -1112,6 +1153,8 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, goto free_opp; } +_opp_estimate_power (new_opp); +
Call this from _opp_add(), right after the call to ->get_pstate().
Quoted 4 lines
drivers/opp/core.c +0
-0/* * Notify the changes in the availability of the operable * frequency/voltage list.
drivers/opp/core.c static int _opp_set_availability(struct device *dev, unsigned long freq, · line 1780
Quoted 10 lines
drivers/opp/core.c +7
-0@@ -1728,6 +1771,26 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,return r; } +/** +* _opp_estimate_power() -- helper to estimate power of an OPP +* @opp: OPP for which we want to do this +* +* Estimate the power of an OPP as P = C * V^2 * f, with C the device's +* capacitance, V the OPP's voltage and f the OPP's frequency. +*/
Don't need doc style comments for internal routines.
drivers/opp/core.c static int _opp_set_availability(struct device *dev, unsigned long freq, · line 1786
Quoted 6 lines
drivers/opp/core.c +6
-0+void _opp_estimate_power (struct dev_pm_opp *opp) +{ +unsigned long capacitance = opp->opp_table->capacitance; +unsigned long mV, KHz, uW; + +if (capacitance) {
Maybe just remove the if block, the result will anyway be zero here and that may be better than having an additional conditional statement.
Quoted 37 lines
drivers/opp/core.c +7
-0+ mV = opp->supplies[0 ].u_volt /1000 ; + KHz = opp->rate /1000 ; + uW = capacitance * mV * mV * KHz /1000000000 ; + opp->power_estimate_uw = uW; + } +} +/** * dev_pm_opp_enable() - Enable a specific OPP * @dev: device for which we do this operation drivers/opp/of.c +7
-4@@ -55,14 +55,17 @@ void _of_init_opp_table(struct opp_table *opp_table, struct device *dev) {struct device_node *np; -/* -* Only required for backward compatibility with v1 bindings, but isn't -* harmful for other cases. And so we do it unconditionally. -*/ np =of_node_get (dev->of_node);if (np) {u32 val; +of_property_read_u32 (np,"dynamic-power-coefficient" , + &opp_table->capacitance); + +/* +* Required for backward compatibility with v1 bindings, but +* isn't harmful for other cases so we do it unconditionally. +*/ if (!of_property_read_u32 (np,"clock-latency" , &val)) opp_table->clock_latency_ns_max = val; of_property_read_u32(np, "voltage-tolerance",
drivers/opp/of.c static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, · line 343
Quoted 5 lines
drivers/opp/of.c +2
-0@@ -336,6 +339,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, goto free_opp; } +_opp_estimate_power (new_opp); +
This wouldn't be required after you move it to _opp_add().
Quoted 17 lines
drivers/opp/of.c +0
-0/* OPP to select on device suspend */ if (of_property_read_bool (np,"opp-suspend" )) {if (opp_table->suspend_opp) {drivers/opp/opp.h +2
-0@@ -84,6 +84,8 @@ struct dev_pm_opp {unsigned long clock_latency_ns; +unsigned long power_estimate_uw; +struct opp_table *opp_table;struct device_node *np;
drivers/opp/opp.h struct opp_table { · line 173
Quoted 7 lines
drivers/opp/opp.h +2
-0@@ -165,6 +167,8 @@ struct opp_table {/* For backward compatibility with v1 bindings */ unsigned int voltage_tolerance_v1; +unsigned int capacitance; +enum opp_table_access shared_opp;struct dev_pm_opp *suspend_opp;
There is documentation above the structure that you need to update.
Signature · 1 line
viresh
Re: [PATCH v2 1/2] PM / OPP: introduce an OPP power estimation helper
Hi Viresh,
Thanks for the feedback !
Quoted 27 lines · Viresh Kumar
Quoted 12 lines · Quentin Perret
drivers/opp/core.c +12
-0+/** +* dev_pm_opp_has_power() - Get the status of power values for OPPs +* @cpu_dev: CPU device for which we do this operation +* +* Return: True if the OPPs hold power estimates for the CPU +*/ +bool dev_pm_opp_has_power (struct device *cpu_dev) +{ +struct opp_table *opp_table; +bool has_power; + + opp_table =_find_opp_table (cpu_dev);drivers/opp/core.c bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp) · line 190
Quoted 10 lines
drivers/opp/core.c +10
-0+if (IS_ERR (opp_table)) +return false; + + has_power = opp_table->capacitance; + +dev_pm_opp_put_opp_table (opp_table); + +return has_power; +} +EXPORT_SYMBOL_GPL (dev_pm_opp_has_power);I am not sure about the worthiness of this routine right now. Users can just ask for the power and that will be 0 if it is not available.
Quoted 7 lines
For the thermal stuff we can just check if the right property is present or not for the device (like we used to do), if we want to avoid running extra code there.
The point is I am not sure if this will be useful to multiple users of the power numbers or not and would like to wait to see more users before adding this API.
Right, I see your point. I'm happy to remove this but I'm just not sure about calling of_find_property() in the thermal subsystem. The point of this series is to make the thermal subsystem use a more abstract API so checking if dynamic-power-coefficient is present is kind of against the idea.
What I suggest is to call __cpufreq_cooling_register() with has_power=true in of_cpufreq_cooling_register() and bail out from update_freq_table() cleanly whenever dev_pm_opp_get_power() returns 0 (and in this case we fallback on the has_power=false path). Does that make sense ?
Quoted 11 lines
drivers/opp/core.c int _opp_add_v1(struct opp_table *opp_table, struct device *dev, · line 1157
Quoted 9 lines
/**
*dev_pm_opp_get_max_clock_latency()- Get max clock latency in nanoseconds
* @dev: device for which we do this operationdrivers/opp/core.c +2
-0@@ -1112,6 +1153,8 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, goto free_opp; } +_opp_estimate_power (new_opp); +Call this from
_opp_add(), right after the call to ->get_pstate().
Ok.
Quoted 7 lines
Quoted 7 lines
drivers/opp/core.c +0
-0/* * Notify the changes in the availability of the operable * frequency/voltage list. @@ -1728,6 +1771,26 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,return r; }
Quoted 9 lines
drivers/opp/core.c static int _opp_set_availability(struct device *dev, unsigned long freq, · line 1780
Quoted 7 lines
drivers/opp/core.c +7
-0+/** +* _opp_estimate_power() -- helper to estimate power of an OPP +* @opp: OPP for which we want to do this +* +* Estimate the power of an OPP as P = C * V^2 * f, with C the device's +* capacitance, V the OPP's voltage and f the OPP's frequency. +*/ Don't need doc style comments for internal routines.
Some of them do have doc style comments (_opp_set_availaility() above this function for ex) so I just wanted to stay consistent.
Quoted 10 lines
drivers/opp/core.c static int _opp_set_availability(struct device *dev, unsigned long freq, · line 1786
Quoted 6 lines
drivers/opp/core.c +6
-0+void _opp_estimate_power (struct dev_pm_opp *opp) +{ +unsigned long capacitance = opp->opp_table->capacitance; +unsigned long mV, KHz, uW; + +if (capacitance) {Maybe just remove the if block, the result will anyway be zero here and that may be better than having an additional conditional statement.
Ok.
Quoted 66 lines
Quoted 38 lines
drivers/opp/core.c +7
-0+ mV = opp->supplies[0 ].u_volt /1000 ; + KHz = opp->rate /1000 ; + uW = capacitance * mV * mV * KHz /1000000000 ; + opp->power_estimate_uw = uW; + } +} +/** * dev_pm_opp_enable() - Enable a specific OPP * @dev: device for which we do this operation drivers/opp/of.c +7
-4@@ -55,14 +55,17 @@ void _of_init_opp_table(struct opp_table *opp_table, struct device *dev) {struct device_node *np; -/* -* Only required for backward compatibility with v1 bindings, but isn't -* harmful for other cases. And so we do it unconditionally. -*/ np =of_node_get (dev->of_node);if (np) {u32 val; +of_property_read_u32 (np,"dynamic-power-coefficient" , + &opp_table->capacitance); + +/* +* Required for backward compatibility with v1 bindings, but +* isn't harmful for other cases so we do it unconditionally. +*/ if (!of_property_read_u32 (np,"clock-latency" , &val)) opp_table->clock_latency_ns_max = val; of_property_read_u32(np, "voltage-tolerance",drivers/opp/of.c static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, · line 343
Quoted 5 lines
drivers/opp/of.c +2
-0@@ -336,6 +339,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, goto free_opp; } +_opp_estimate_power (new_opp); +This wouldn't be required after you move it to
_opp_add().Quoted 20 lines
drivers/opp/of.c +0
-0/* OPP to select on device suspend */ if (of_property_read_bool (np,"opp-suspend" )) {if (opp_table->suspend_opp) {drivers/opp/opp.h +2
-0@@ -84,6 +84,8 @@ struct dev_pm_opp {unsigned long clock_latency_ns; +unsigned long power_estimate_uw; +struct opp_table *opp_table;struct device_node *np;@@ -165,6 +167,8 @@ struct opp_table {/* For backward compatibility with v1 bindings */ unsigned int voltage_tolerance_v1;
Quoted 6 lines
drivers/opp/opp.h struct opp_table { · line 173
Quoted 4 lines
drivers/opp/opp.h +2
-0+unsigned int capacitance; +enum opp_table_access shared_opp;struct dev_pm_opp *suspend_opp;There is documentation above the structure that you need to update.
Right, I will update it.
Thank you very much,
Quentin
Re: [PATCH v2 1/2] PM / OPP: introduce an OPP power estimation helper
Quoted 5 lines · Quentin Perret
What I suggest is to call
__cpufreq_cooling_register()with has_power=true inof_cpufreq_cooling_register()and bail out fromupdate_freq_table()cleanly wheneverdev_pm_opp_get_power()returns 0 (and in this case we fallback on the has_power=false path). Does that make sense ?
Maybe just remove the has_power thing completely and always call update_freq_table() and let it update power to 0 ? Its anyway a one time initialization thing, wouldn't matter much.
Signature · 1 line
viresh
Re: [PATCH v2 1/2] PM / OPP: introduce an OPP power estimation helper
Quoted 10 lines · Viresh Kumar
Quoted 5 lines · Quentin Perret
What I suggest is to call
__cpufreq_cooling_register()with has_power=true inof_cpufreq_cooling_register()and bail out fromupdate_freq_table()cleanly wheneverdev_pm_opp_get_power()returns 0 (and in this case we fallback on the has_power=false path). Does that make sense ?Maybe just remove the
has_powerthing completely and always callupdate_freq_table()and let it update power to 0 ? Its anyway a one time initialization thing, wouldn't matter much.
Hmmm I just need to make sure to fallback on the right cooling_ops if update_freq_table() updated the power to 0, but yes, that should work. I'll do the change in v3.
Cheers,
Quentin
PATCH v2 2/2 thermal: cpu_cooling: use power models from the OPP library
In reply to Quentin PerretNow that the OPP library features a power estimator, the existing code in IPA can be modified to rely only on dev_pm_opp_get_power() without having to care about the dynamic-power-coefficient DT binding.
--- drivers/thermal/cpu_cooling.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-)
drivers/thermal/cpu_cooling.c +9 -24
@@ -187,7 +187,6 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,/** * update_freq_table() - Update the freq table with power numbers * @cpufreq_cdev: the cpufreq cooling device in which to update the table -* @capacitance: dynamic power coefficient for these cpus * * Update the freq table with power numbers. This table will be used in * cpu_power_to_freq() and cpu_freq_to_power() to convert between power and
@@ -197,8 +196,7 @@ static int cpufreq_thermal_notifier(struct notifier_block *nb,* Return: 0 on success, -EINVAL if there are no OPPs for any CPUs, * or -ENOMEM if we run out of memory. */ -static int update_freq_table (struct cpufreq_cooling_device *cpufreq_cdev, -u32 capacitance) +static int update_freq_table (struct cpufreq_cooling_device *cpufreq_cdev) {struct freq_table *freq_table = cpufreq_cdev->freq_table;struct dev_pm_opp *opp;
@@ -227,9 +225,6 @@ static int update_freq_table(struct cpufreq_cooling_device *cpufreq_cdev,for (i =0 ; i <= cpufreq_cdev->max_level; i++) {unsigned long freq = freq_table[i].frequency *1000 ; -u32 freq_mhz = freq_table[i].frequency /1000 ; -u64 power; -u32 voltage_mv;/* * Find ceil frequency as 'freq' may be slightly lower than OPP
@@ -242,18 +237,9 @@ static int update_freq_table(struct cpufreq_cooling_device *cpufreq_cdev,return -EINVAL ; } - voltage_mv =dev_pm_opp_get_voltage (opp) /1000 ; -dev_pm_opp_put (opp); - -/* -* Do the multiplication with MHz and millivolt so as -* to not overflow. -*/ - power = (u64 )capacitance * freq_mhz * voltage_mv * voltage_mv; -do_div (power,1000000000 ); -/* power is stored in mW */ - freq_table[i].power = power; + freq_table[i].power =dev_pm_opp_get_power (opp) /1000 ; +dev_pm_opp_put (opp); }return 0 ;
@@ -606,7 +592,7 @@ static unsigned int find_next_max(struct cpufreq_frequency_table *table,*/ static struct thermal_cooling_device *__cpufreq_cooling_register (struct device_node *np, -struct cpufreq_policy *policy,u32 capacitance) +struct cpufreq_policy *policy,bool power_model) {struct thermal_cooling_device *cdev;struct cpufreq_cooling_device *cpufreq_cdev;
@@ -675,8 +661,8 @@ __cpufreq_cooling_register(struct device_node *np,pr_debug ("%s: freq:%u KHz\n" , __func__, freq); } -if (capacitance) { - ret =update_freq_table (cpufreq_cdev, capacitance); +if (power_model) { + ret =update_freq_table (cpufreq_cdev);if (ret) { cdev =ERR_PTR (ret); goto remove_ida;
@@ -760,7 +746,7 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) {struct device_node *np =of_get_cpu_node (policy->cpu,NULL );struct thermal_cooling_device *cdev =NULL ; -u32 capacitance =0 ; +bool has_power;if (!np) { pr_err("cpu_cooling: OF node not available for cpu%d\n",
@@ -769,10 +755,9 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) }if (of_find_property (np,"#cooling-cells" ,NULL )) { -of_property_read_u32 (np,"dynamic-power-coefficient" , - &capacitance); + has_power =dev_pm_opp_has_power (get_cpu_device (policy->cpu)); - cdev =__cpufreq_cooling_register (np, policy, capacitance); + cdev =__cpufreq_cooling_register (np, policy, has_power);if (IS_ERR (cdev)) {pr_err ("cpu_cooling: cpu%d is not running as cooling device: %ld\n" , policy->cpu,PTR_ERR (cdev));
Signature · 1 line
2.15.1
Re: [PATCH v2 2/2] thermal: cpu_cooling: use power models from the OPP library
Quoted 10 lines · Quentin Perret
drivers/thermal/cpu_cooling.c +1
-1@@ -760,7 +746,7 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) {struct device_node *np =of_get_cpu_node (policy->cpu,NULL );struct thermal_cooling_device *cdev =NULL ; -u32 capacitance =0 ; +bool has_power;if (!np) { pr_err("cpu_cooling: OF node not available for cpu%d\n",
drivers/thermal/cpu_cooling.c of_cpufreq_cooling_register(struct cpufreq_policy *policy) · line 758
Quoted 6 lines
drivers/thermal/cpu_cooling.c +1
-2@@ -769,10 +755,9 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) }if (of_find_property (np,"#cooling-cells" ,NULL )) { -of_property_read_u32 (np,"dynamic-power-coefficient" , - &capacitance); + has_power =dev_pm_opp_has_power (get_cpu_device (policy->cpu));
Use of_find_property() here, as I pointed out in the other commit.
Signature · 1 line
viresh
Re: [PATCH v2 2/2] thermal: cpu_cooling: use power models from the OPP library
Quoted 13 lines · Viresh Kumar
Quoted 12 lines · Quentin Perret
drivers/thermal/cpu_cooling.c +1
-1@@ -760,7 +746,7 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) {struct device_node *np =of_get_cpu_node (policy->cpu,NULL );struct thermal_cooling_device *cdev =NULL ; -u32 capacitance =0 ; +bool has_power;if (!np) { pr_err("cpu_cooling: OF node not available for cpu%d\n",@@ -769,10 +755,9 @@ of_cpufreq_cooling_register(struct cpufreq_policy *policy) }
Quoted 6 lines
drivers/thermal/cpu_cooling.c of_cpufreq_cooling_register(struct cpufreq_policy *policy) · line 758
Quoted 4 lines
drivers/thermal/cpu_cooling.c +1
-2if (of_find_property (np,"#cooling-cells" ,NULL )) { -of_property_read_u32 (np,"dynamic-power-coefficient" , - &capacitance); + has_power =dev_pm_opp_has_power (get_cpu_device (policy->cpu));Use
of_find_property()here, as I pointed out in the other commit.
As I mentioned in the other commit, what I suggest here is to call __cpufreq_cooling_register() with has_power=true unconditionally here and to bail out from update_freq_table cleanly whenever dev_pm_opp_get_power() returns 0.
Quoted 3 lines
Signature · 2 lines
-- viresh