From bd6ee8587a7f7651685f41e7fa5f3b95f3ef9eb2 Mon Sep 17 00:00:00 2001 From: "jianxin.pan" Date: Tue, 29 May 2018 14:10:23 +0800 Subject: [PATCH] cpufreq: add core param to limit kernel boot cpufreq PD#165090: add freqmax0 and freqmax1 to limit kernel boot cpufreq add freqmax0=1000000 to bootargs, and boot freq of cluster0 will be limited to 1G. Change-Id: I5cb44727f74c574669663887473a80f87ddf61a7 Signed-off-by: jianxin.pan --- drivers/cpufreq/cpufreq.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index f06b52a0a540..bbcc7ebfb88a 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -35,6 +35,13 @@ #endif #include +#ifdef CONFIG_AMLOGIC_MODIFY +static unsigned int freqmax0; +core_param(freqmax0, freqmax0, uint, 0644); +static unsigned int freqmax1; +core_param(freqmax1, freqmax1, uint, 0644); +#endif + static LIST_HEAD(cpufreq_policy_list); static inline bool policy_is_inactive(struct cpufreq_policy *policy) @@ -1283,6 +1290,19 @@ static int cpufreq_online(unsigned int cpu) down_write(&policy->rwsem); +#ifdef CONFIG_AMLOGIC_MODIFY + if (topology_physical_package_id(cpu) == 0 && freqmax0) { + if (freqmax0 >= policy->min && freqmax0 < policy->max) + policy->max = freqmax0; + pr_notice(" freqmax0:%d, max:%d\n", freqmax0, policy->max); + } + if (topology_physical_package_id(cpu) == 1 && freqmax1) { + if (freqmax1 >= policy->min && freqmax1 < policy->max) + policy->max = freqmax1; + pr_notice(" freqmax1:%d, max:%d\n", freqmax1, policy->max); + } +#endif + if (new_policy) { /* related_cpus should at least include policy->cpus. */ cpumask_copy(policy->related_cpus, policy->cpus);