Hi Guys,
This patchset add APIs in OPP layer to allow OPPs transitioning from
within OPP layer. Currently all OPP users need to replicate the same
code to switch between OPPs. While the same can be handled easily by
OPP-core.
The first 7 patches update the OPP core to introduce the new APIs and
the next Nine patches update cpufreq-dt for the same.
11 out of 17 are already Reviewed by Stephen, only few are left :)
I hope this is the last version of the series :)
Testing:
- Tested on exynos 5250-arndale (dual-cortex-A15)
- Tested for both Old-V1 bindings and New V2 bindings
- Tested with regulator names as: 'cpu-supply' and 'cpu0-supply'
- Tested with Unsupported supply ranges as well, to check the
opp-disable logic
V2->V3:
- Very minor updates.
- find_supply_name() doesn't return an error value now, and so its
callers don't check for it.
- And so we don't need to initialize name to NULL
Viresh Kumar (16):
PM / OPP: get/put regulators from OPP core
PM / OPP: Disable OPPs that aren't supported by the regulator
PM / OPP: Introduce dev_pm_opp_get_max_volt_latency()
PM / OPP: Introduce dev_pm_opp_get_max_transition_latency()
PM / OPP: Parse clock-latency and voltage-tolerance for v1 bindings
PM / OPP: Manage device clk
PM / OPP: Add dev_pm_opp_set_rate()
cpufreq: dt: Convert few pr_debug/err() calls to dev_dbg/err()
cpufreq: dt: Rename 'need_update' to 'opp_v1'
cpufreq: dt: OPP layers handles clock-latency for V1 bindings as well
cpufreq: dt: Pass regulator name to the OPP core
cpufreq: dt: Unsupported OPPs are already disabled
cpufreq: dt: Reuse dev_pm_opp_get_max_transition_latency()
cpufreq: dt: Use dev_pm_opp_set_rate() to switch frequency
cpufreq: dt: No need to fetch voltage-tolerance
cpufreq: dt: No need to allocate resources anymore
drivers/base/power/opp/core.c | 420 ++++++++++++++++++++++++++++++++++++++++++
drivers/base/power/opp/opp.h | 13 ++
drivers/cpufreq/cpufreq-dt.c | 300 +++++++++++-------------------
include/linux/pm_opp.h | 27 +++
4 files changed, 565 insertions(+), 195 deletions(-)
--
2.7.1.370.gb2aa7f8
On 32bits platforms "struct timeval" or "time_t" are using u32 to code the
date, this cause tools like "date" or "hwclock" failed even before setting
the RTC device if the date is superior to year 2038 (or 2106).
To avoid this problem I add one RTC test file which directly use RTC ioctl
to set and read RTC time and alarm values.
rtctest_setdate allow to set any date/time given in the command line.
On this version 2 I add check of problematics years in rtctest like suggest
by Alexandre.
Finally that had allowed me to test and fix rtc-st-lpc driver.
Benjamin Gaignard (3):
tools: timer: add rtctest_setdate
tool: timer: rtctest add check for problematic dates
rtc: st-lpc: make it robust against y2038/2106 bug
drivers/rtc/rtc-st-lpc.c | 19 ++--
tools/testing/selftests/timers/Makefile | 2 +-
tools/testing/selftests/timers/rtctest.c | 121 ++++++++++++++++++++++-
tools/testing/selftests/timers/rtctest_setdate.c | 86 ++++++++++++++++
4 files changed, 212 insertions(+), 16 deletions(-)
create mode 100644 tools/testing/selftests/timers/rtctest_setdate.c
--
1.9.1
Tree/Branch: next-20170630
Git describe: next-20170630
Commit: a70e9c77d0 Add linux-next specific files for 20170630
Build Time: 0 min 11 sec
Passed: 6 / 7 ( 85.71 %)
Failed: 1 / 7 ( 14.29 %)
Errors: 1
Warnings: 7
Section Mismatches: 0
Failed defconfigs:
arm-allmodconfig
Errors:
arm-allmodconfig
ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] undefined!
-------------------------------------------------------------------------------
defconfigs with issues (other than build errors):
2 warnings 0 mismatches : arm-multi_v5_defconfig
1 warnings 0 mismatches : arm-multi_v7_defconfig
4 warnings 0 mismatches : arm-allmodconfig
2 warnings 0 mismatches : arm-allnoconfig
1 warnings 0 mismatches : x86_64-allnoconfig
2 warnings 0 mismatches : arm-multi_v4t_defconfig
-------------------------------------------------------------------------------
Errors summary: 1
1 ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] undefined!
Warnings Summary: 7
3 ../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
3 ../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
2 ../drivers/rtc/rtc-brcmstb-waketimer.c:142:6: warning: unused variable 'ret' [-Wunused-variable]
1 ../kernel/sched/fair.c:2655:44: warning: 'struct sched_domain' declared inside parameter list will not be visible outside of this definition or declaration
1 ../include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
1 ../drivers/staging/media/imx/imx-media-of.c:216:4: warning: 'remote_np' may be used uninitialized in this function [-Wmaybe-uninitialized]
1 ../drivers/pinctrl/pinctrl-rza1.c:1260:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
===============================================================================
Detailed per-defconfig build reports below:
-------------------------------------------------------------------------------
arm-multi_v5_defconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
-------------------------------------------------------------------------------
arm-multi_v7_defconfig : PASS, 0 errors, 1 warnings, 0 section mismatches
Warnings:
../drivers/rtc/rtc-brcmstb-waketimer.c:142:6: warning: unused variable 'ret' [-Wunused-variable]
-------------------------------------------------------------------------------
arm-allmodconfig : FAIL, 1 errors, 4 warnings, 0 section mismatches
Errors:
ERROR: "__aeabi_uldivmod" [drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.ko] undefined!
Warnings:
../drivers/pinctrl/pinctrl-rza1.c:1260:5: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
../drivers/rtc/rtc-brcmstb-waketimer.c:142:6: warning: unused variable 'ret' [-Wunused-variable]
../include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
../drivers/staging/media/imx/imx-media-of.c:216:4: warning: 'remote_np' may be used uninitialized in this function [-Wmaybe-uninitialized]
-------------------------------------------------------------------------------
arm-allnoconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
-------------------------------------------------------------------------------
x86_64-allnoconfig : PASS, 0 errors, 1 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2655:44: warning: 'struct sched_domain' declared inside parameter list will not be visible outside of this definition or declaration
-------------------------------------------------------------------------------
arm-multi_v4t_defconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
-------------------------------------------------------------------------------
Passed with no errors, warnings or mismatches:
x86_64-defconfig
The transition_latency_ns represents the maximum time it can take for
the hardware to switch from/to any frequency for a CPU.
The transition_latency_ns is used currently for two purposes:
o To check if the hardware latency is over the maximum allowed for a
governor (only for ondemand and conservative (why not schedutil?)) and
to decide if the governor can be used or not.
o To calculate the sampling_rate or rate_limit for the governors by
multiplying transition_latency_ns with a constant.
The platform drivers can also set this value to CPUFREQ_ETERNAL if they
don't know this number and in that case we disallow use of ondemand and
conservative governors as the latency would be higher than the maximum
allowed for the governors.
In many cases this number is forged by the driver authors to get the
default sampling rate to a desired value. Anyway, the actual latency
values can differ from what is received from the hardware designers.
Over that, what is provided by the drivers is most likely the time it
takes to change frequency of the hardware, which doesn't account the
software overhead involved.
In order to have guarantees about this number, this patch tries to
calculate the latency dynamically at cpufreq driver registration time by
first switching to min frequency, then to the max and finally back to
the initial frequency. And the maximum of all three is used as the
target_latency. Specifically the time it takes to go from min to max
frequency (when the software runs the slowest) should be good enough,
and even if there is a delta involved then it shouldn't be a lot.
For now this patch limits this feature only for platforms which have set
the transition latency to CPUFREQ_ETERNAL. Maybe we can convert everyone
to use it in future, but lets see.
This is tested over ARM64 Hikey platform which currently sets
"clock-latency" as 500 us from DT, while with this patch the actualy
value increased to 800 us.
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
drivers/cpufreq/cpufreq.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 0e3f6496524d..478a18364b1f 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -25,6 +25,7 @@
#include <linux/kernel_stat.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/sched/clock.h>
#include <linux/slab.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
@@ -977,6 +978,66 @@ __weak struct cpufreq_governor *cpufreq_default_governor(void)
return NULL;
}
+static int find_dvfs_latency(struct cpufreq_policy *policy, unsigned long freq,
+ unsigned int *latency_ns)
+{
+ u64 time;
+ int ret;
+
+ time = local_clock();
+ ret = __cpufreq_driver_target(policy, freq, CPUFREQ_RELATION_L);
+ *latency_ns = local_clock() - time;
+
+ return ret;
+}
+
+/*
+ * Find the transition latency dynamically by:
+ * - Switching to min freq first.
+ * - Then switching to max freq.
+ * - And finally switching back to the initial freq.
+ *
+ * The maximum duration of the above three freq changes should be good enough to
+ * find the maximum transition latency for a platform.
+ */
+static void cpufreq_find_target_latency(struct cpufreq_policy *policy)
+{
+ unsigned long initial_freq = policy->cur;
+ unsigned int latency_ns, latency_max_ns;
+ int ret;
+
+ if (!has_target())
+ return;
+
+ /* Limit to drivers with latency set to CPUFREQ_ETERNAL for now */
+ if (policy->cpuinfo.transition_latency != CPUFREQ_ETERNAL)
+ return;
+
+ /* Go to min frequency first */
+ ret = find_dvfs_latency(policy, policy->cpuinfo.min_freq, &latency_ns);
+ if (ret)
+ return;
+
+ latency_max_ns = latency_ns;
+
+ /* Go to max frequency then.. */
+ ret = find_dvfs_latency(policy, policy->cpuinfo.max_freq, &latency_ns);
+ if (ret)
+ return;
+
+ latency_max_ns = max(latency_max_ns, latency_ns);
+
+ /* And finally switch back to where we started from */
+ ret = find_dvfs_latency(policy, initial_freq, &latency_ns);
+ if (ret)
+ return;
+
+ policy->cpuinfo.transition_latency = max(latency_max_ns, latency_ns);
+
+ pr_info("%s: Setting transition latency to %u ns for policy of CPU%d\n",
+ __func__, policy->cpuinfo.transition_latency, policy->cpu);
+}
+
static int cpufreq_init_policy(struct cpufreq_policy *policy)
{
struct cpufreq_governor *gov = NULL;
@@ -1246,6 +1307,8 @@ static int cpufreq_online(unsigned int cpu)
}
if (new_policy) {
+ cpufreq_find_target_latency(policy);
+
ret = cpufreq_add_dev_interface(policy);
if (ret)
goto out_exit_policy;
--
2.13.0.70.g6367777092d9
Tree/Branch: next-20170629
Git describe: next-20170629
Commit: 3fb8ba638d Add linux-next specific files for 20170629
Build Time: 0 min 10 sec
Passed: 7 / 7 (100.00 %)
Failed: 0 / 7 ( 0.00 %)
Errors: 0
Warnings: 6
Section Mismatches: 0
-------------------------------------------------------------------------------
defconfigs with issues (other than build errors):
2 warnings 0 mismatches : arm-multi_v5_defconfig
1 warnings 0 mismatches : arm-multi_v7_defconfig
3 warnings 0 mismatches : arm-allmodconfig
2 warnings 0 mismatches : arm-allnoconfig
1 warnings 0 mismatches : x86_64-allnoconfig
2 warnings 0 mismatches : arm-multi_v4t_defconfig
-------------------------------------------------------------------------------
Warnings Summary: 6
3 ../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
3 ../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
2 ../drivers/rtc/rtc-brcmstb-waketimer.c:142:6: warning: unused variable 'ret' [-Wunused-variable]
1 ../kernel/sched/fair.c:2655:44: warning: 'struct sched_domain' declared inside parameter list will not be visible outside of this definition or declaration
1 ../include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
1 ../drivers/staging/media/imx/imx-media-of.c:216:4: warning: 'remote_np' may be used uninitialized in this function [-Wmaybe-uninitialized]
===============================================================================
Detailed per-defconfig build reports below:
-------------------------------------------------------------------------------
arm-multi_v5_defconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
-------------------------------------------------------------------------------
arm-multi_v7_defconfig : PASS, 0 errors, 1 warnings, 0 section mismatches
Warnings:
../drivers/rtc/rtc-brcmstb-waketimer.c:142:6: warning: unused variable 'ret' [-Wunused-variable]
-------------------------------------------------------------------------------
arm-allmodconfig : PASS, 0 errors, 3 warnings, 0 section mismatches
Warnings:
../drivers/rtc/rtc-brcmstb-waketimer.c:142:6: warning: unused variable 'ret' [-Wunused-variable]
../drivers/staging/media/imx/imx-media-of.c:216:4: warning: 'remote_np' may be used uninitialized in this function [-Wmaybe-uninitialized]
../include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
-------------------------------------------------------------------------------
arm-allnoconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
-------------------------------------------------------------------------------
x86_64-allnoconfig : PASS, 0 errors, 1 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2655:44: warning: 'struct sched_domain' declared inside parameter list will not be visible outside of this definition or declaration
-------------------------------------------------------------------------------
arm-multi_v4t_defconfig : PASS, 0 errors, 2 warnings, 0 section mismatches
Warnings:
../kernel/sched/fair.c:2657:9: warning: 'struct sched_domain' declared inside parameter list
../kernel/sched/fair.c:2657:9: warning: its scope is only this definition or declaration, which is probably not what you want
-------------------------------------------------------------------------------
Passed with no errors, warnings or mismatches:
x86_64-defconfig