summaryrefslogtreecommitdiffstats
path: root/drivers/thermal/devfreq_cooling.c
AgeCommit message (Collapse)Author
2020-12-15thermal/drivers/devfreq_cooling: Fix the build when !ENERGY_MODELLukasz Luba
Prevent build failure if the option CONFIG_ENERGY_MODEL is not set. The devfreq cooling is able to operate without the Energy Model. Don't use dev->em_pd directly and use local pointer. Fixes: 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201215154221.8828-1-lukasz.luba@arm.com
2020-12-11thermal: devfreq_cooling: remove old power model and use EMLukasz Luba
Remove old power model and use new Energy Model to calculate the power budget. It drops static + dynamic power calculations and power table in order to use Energy Model performance domain data. This model should be easy to use and could find more users. It is also less complicated to setup the needed structures. Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201210143014.24685-5-lukasz.luba@arm.com
2020-12-11thermal: devfreq_cooling: add new registration functions with Energy ModelLukasz Luba
The Energy Model (EM) framework supports devices such as Devfreq. Create new registration function which automatically register EM for the thermal devfreq_cooling devices. This patch prepares the code for coming changes which are going to replace old power model with the new EM. Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201210143014.24685-4-lukasz.luba@arm.com
2020-12-11thermal: devfreq_cooling: use a copy of device statusLukasz Luba
Devfreq cooling needs to now the correct status of the device in order to operate. Devfreq framework can change the device status in the background. To mitigate issues make a copy of the status structure and use it for internal calculations. In addition this patch adds normalization function, which also makes sure that whatever data comes from the device, the load will be in range from 1 to 1024. Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201210143014.24685-3-lukasz.luba@arm.com
2020-12-11thermal: devfreq_cooling: change tracing function and argumentsLukasz Luba
Prepare for deleting the static and dynamic power calculation and clean the trace function. These two fields are going to be removed in the next changes. Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> # for tracing code Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20201210143014.24685-2-lukasz.luba@arm.com
2020-10-12thermal: cooling: Remove unused variable *tzzhuguangqing
1. devfreq_cooling.c: The variable *tz is not used in devfreq_cooling_get_requested_power(), devfreq_cooling_state2power() and devfreq_cooling_power2state(). 2. cpufreq_cooling.c: After 84fe2cab48590, the variable *tz is not used anymore in cpufreq_get_requested_power(), cpufreq_state2power() and cpufreq_power2state(). Remove the variable *tz. Signed-off-by: zhuguangqing <zhuguangqing@xiaomi.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200914071101.13575-1-zhuguangqing83@gmail.com
2020-07-30thermal: Update power allocator and devfreq cooling to SPDX licensingLukasz Luba
Update the license to the SPDX licensing format. Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200730165117.13998-1-lukasz.luba@arm.com
2020-04-14thermal: devfreq_cooling: Use PM QoS to set frequency limitsMatthias Kaehlcke
Now that devfreq supports limiting the frequency range of a device through PM QoS make use of it instead of disabling OPPs that should not be used. The switch from disabling OPPs to PM QoS introduces a subtle behavioral change in case of conflicting requests (min > max): PM QoS gives precedence to the MIN_FREQUENCY request, while higher OPPs disabled with dev_pm_opp_disable() would override MIN_FREQUENCY. Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200318114548.19916-4-lukasz.luba@arm.com
2020-01-27thermal: devfreq_cooling: Appease the kernel-doc deityAmit Kucheria
Fix up the following warnings with make W=1: linux.git/drivers/thermal/devfreq_cooling.c:68: warning: Function parameter or member 'capped_state' not described in 'devfreq_cooling_device' linux.git/drivers/thermal/devfreq_cooling.c:593: warning: Function parameter or member 'cdev' not described in 'devfreq_cooling_unregister' linux.git/drivers/thermal/devfreq_cooling.c:593: warning: Excess function parameter 'dfc' description in 'devfreq_cooling_unregister' Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/7059d82472fe12139fc7a3379c5b9716a23cce5c.1574242756.git.amit.kucheria@linaro.org
2017-05-05trace: thermal: add another parameter 'power' to the tracing functionLukasz Luba
This patch adds another parameter to the trace function: trace_thermal_power_devfreq_get_power(). In case when we call directly driver's code for the real power, we do not have static/dynamic_power values. Instead we get total power in the '*power' value. The 'static_power' and 'dynamic_power' are set to 0. Therefore, we have to trace that '*power' value in this scenario. CC: Steven Rostedt <rostedt@goodmis.org> CC: Ingo Molnar <mingo@redhat.com> CC: Zhang Rui <rui.zhang@intel.com> CC: Eduardo Valentin <edubezval@gmail.com> Acked-by: Javi Merino <javi.merino@kernel.org> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
2017-05-05thermal: devfreq_cooling: add new interface for direct power readLukasz Luba
This patch introduces a new interface for device drivers connected to devfreq_cooling in the thermal framework: get_real_power(). Some devices have more sophisticated methods (like power counters) to approximate the actual power that they use. In the previous implementation we had a pre-calculated power table which was then scaled by 'utilization' ('busy_time' and 'total_time' taken from devfreq 'last_status'). With this new interface the driver can provide more precise data regarding actual power to the thermal governor every time the power budget is calculated. We then use this value and calculate the real resource utilization scaling factor. Reviewed-by: Chris Diamand <chris.diamand@arm.com> Acked-by: Javi Merino <javi.merino@kernel.org> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
2017-05-05thermal: devfreq_cooling: refactor code and add get_voltage functionLukasz Luba
Move the code which gets the voltage for a given frequency. This code will be resused in few places. Acked-by: Javi Merino <javi.merino@kernel.org> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
2017-03-13thermal: devfreq: Check OPP for errorsViresh Kumar
It is possible for dev_pm_opp_find_freq_exact() to return errors. It was all fine earlier as dev_pm_opp_get_voltage() had a check within it to check for invalid OPPs, but dev_pm_opp_put() doesn't have any similar checks and the callers need to make sure OPP is valid before calling them. Also update the later dev_warn_ratelimited() to not print the error message as the OPP is guaranteed to be valid now. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2017-03-13thermal: devfreq_cooling: Replace dev_warn with dev_errViresh Kumar
There isn't much the user can do on seeing this warning, as the hardware is actually okay. dev_err suits much better here. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2017-03-13thermal: devfreq: Simplify expressionViresh Kumar
There is no need to check for IS_ERR() as we are looking for a very particular error value here. Drop the first check. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2017-03-01Merge branch 'next' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux Pull thermal management updates from Zhang Rui: - add thermal driver for R-Car Gen3 thermal sensors. - add thermal driver for ZTE' zx2967 family thermal sensors. - convert thermal ID allocation from IDR to IDA. - fix a possible NULL dereference in imx thermal driver. - fix a ti-soc-thermal driver dependency issue so that critical thermal control is still available when CPU_THERMAL is not defined. - update binding information for QorIQ thermal driver. - a couple of cleanups in thermal core, intel_powerclamp, exynos, dra752-thermal, mtk-thermal driver. * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: powerpc/mpc85xx: Update TMU device tree node for T1023/T1024 powerpc/mpc85xx: Update TMU device tree node for T1040/T1042 dt-bindings: Update QorIQ TMU thermal bindings thermal: mtk_thermal: Staticise a number of data variables thermal: arm: dra752: Remove all TSHUT related definitions thermal: arm: dra752: Remove TSHUT configuration thermal: ti-soc-thermal: Remove CPU_THERMAL Dependency from TI_THERMAL thermal: imx: Fix possible NULL dereference. thermal: exynos: Remove parsing unused samsung,tmu_cal_mode property thermal: zx2967: add thermal driver for ZTE's zx2967 family thermal: use cpumask_var_t for on-stack cpu masks dt: bindings: add documentation for zx2967 family thermal sensor thermal/intel_powerclamp: Remove set-but-not-used variables thermal: rcar_gen3_thermal: Add R-Car Gen3 thermal driver thermal: rcar_gen3_thermal: Document the R-Car Gen3 thermal: convert devfreq_cooling to use an IDA thermal: convert cpu_cooling to use an IDA thermal: convert clock cooling to use an IDA thermal core: convert ID allocation to IDA
2017-01-30PM / OPP: Update OPP users to put referenceViresh Kumar
This patch updates dev_pm_opp_find_freq_*() routines to get a reference to the OPPs returned by them. Also updates the users of dev_pm_opp_find_freq_*() routines to call dev_pm_opp_put() after they are done using the OPPs. As it is guaranteed the that OPPs wouldn't get freed while being used, the RCU read side locking present with the users isn't required anymore. Drop it as well. This patch also updates all users of devfreq_recommended_opp() which was returning an OPP received from the OPP core. Note that some of the OPP core routines have gained rcu_read_{lock|unlock}() calls, as those still use RCU specific APIs within them. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> [Devfreq] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2017-01-04thermal: convert devfreq_cooling to use an IDAMatthew Wilcox
thermal devfreq cooling does not use the ability to look up pointers by ID, so convert it from using an IDR to the more space-efficient IDA. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2016-11-23devfreq_cooling: pass a pointer to devfreq in the power model callbacksJavi Merino
When the devfreq cooling device was designed, it was an oversight not to pass a pointer to the struct devfreq as the first parameters of the callbacks. The design patterns of the kernel suggest it for a good reason. By passing a pointer to struct devfreq, the driver can register one function that works with multiple devices. With the current implementation, a driver that can work with multiple devices has to create multiple copies of the same function with different parameters so that each devfreq_cooling_device can use the appropriate one. By passing a pointer to struct devfreq, the driver can identify which device it's referring to. Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Reviewed-by: Punit Agrawal <punit.agrawal@arm.com> Reviewed-by: Ørjan Eide <orjan.eide@arm.com> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2016-09-27devfreq_cooling: no need to check state with negative numberShawn Lin
We could see that state is defined as unsigned type, so it should never be less than zero. Let' remove this check. Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2015-11-04devfreq_cooling: return on allocation failureDan Carpenter
If the allocation fails then we can't continue. Fixes: a76caf55e5b3 ('thermal: Add devfreq cooling') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2015-11-02thermal: devfreq_cooling: Make power a u64Javi Merino
The prototype of do_div() is: uint32_t do_div(uint64_t *n, uint32_t base); Make power u64 to avoid the following warning: drivers/thermal/devfreq_cooling.c: In function 'get_dynamic_power': drivers/thermal/devfreq_cooling.c:267:2: warning: comparison of distinct pointer types lacks a cast [enabled by default] drivers/thermal/devfreq_cooling.c:267:2: warning: right shift count >= width of type [enabled by default] drivers/thermal/devfreq_cooling.c:267:2: warning: passing argument 1 of '__div64_32' from incompatible pointer type [enabled by default] include/asm-generic/div64.h:35:17: note: expected 'uint64_t *' but argument is of type 'long unsigned int *' Reported-by: kbuild test robot <fengguang.wu@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2015-11-02thermal: devfreq_cooling: use a thermal_cooling_device for register and ↵Javi Merino
unregister Be consistent with what other cooling devices do and return a struct thermal_cooling_device * on register. Also, for the unregister, accept a struct thermal_cooling_device * as parameter. Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2015-10-30devfreq_cooling: add trace informationJavi Merino
Tracing is useful for debugging and performance tuning. Add similar traces to what's present in the cpu cooling device. Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Ingo Molnar <mingo@redhat.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
2015-10-30thermal: Add devfreq coolingØrjan Eide
Add a generic thermal cooling device for devfreq, that is similar to cpu_cooling. The device must use devfreq. In order to use the power extension of the cooling device, it must have registered its OPPs using the OPP library. Cc: Zhang Rui <rui.zhang@intel.com> Cc: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Javi Merino <javi.merino@arm.com> Signed-off-by: Ørjan Eide <orjan.eide@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>