Many CPUFreq drivers for SMP system (where all cores share same clock lines), do similar stuff in their ->init() part.
This patch creates a generic routine in cpufreq core which can be used by these so that we can remove some redundant code. And later part of patchset makes other drivers use this infrastructure.
Many drivers which weren't setting policy->cpus haven't been updated as they might have separate clocks for CPUs and setting all CPUs in policy->cpus may corrupt them..
This is Sixth part of my cleanup work for CPUFreq, first five are (And obviously its rebased over them):
1: cpufreq: Introduce cpufreq_table_validate_and_show() https://lkml.org/lkml/2013/8/8/263
2: cpufreq: define generic routines for cpufreq drivers https://lkml.org/lkml/2013/8/10/48
3. CPUFreq: Implement light weight ->target(): for 3.13 https://lkml.org/lkml/2013/8/13/349
4. CPUFreq: set policy->cur in cpufreq core instead of drivers https://lkml.org/lkml/2013/8/14/288
5. CPUFreq: Move freq change notifications out of drivers https://lkml.org/lkml/2013/8/15/506
All these are pushed here: https://git.linaro.org/gitweb?p=people/vireshk/linux.git%3Ba=shortlog%3Bh=re...
Viresh Kumar (14): cpufreq: create cpufreq_generic_init() routine cpufreq: cpu0: use cpufreq_generic_init() routine cpufreq: dbx500: use cpufreq_generic_init() routine cpufreq: exynos: use cpufreq_generic_init() routine cpufreq: imx6q: use cpufreq_generic_init() routine cpufreq: kirkwood: use cpufreq_generic_init() routine cpufreq: maple: use cpufreq_generic_init() routine cpufreq: pasemi: use cpufreq_generic_init() routine cpufreq: pmac64: use cpufreq_generic_init() routine cpufreq: s3c: use cpufreq_generic_init() routine cpufreq: s5pv210: use cpufreq_generic_init() routine cpufreq: sa11x0: use cpufreq_generic_init() routine cpufreq: spear: use cpufreq_generic_init() routine cpufreq: tegra: use cpufreq_generic_init() routine
drivers/cpufreq/cpufreq-cpu0.c | 19 +------------------ drivers/cpufreq/cpufreq.c | 31 +++++++++++++++++++++++++++++++ drivers/cpufreq/dbx500-cpufreq.c | 21 +-------------------- drivers/cpufreq/exynos-cpufreq.c | 7 +------ drivers/cpufreq/exynos5440-cpufreq.c | 14 ++------------ drivers/cpufreq/imx6q-cpufreq.c | 13 +------------ drivers/cpufreq/kirkwood-cpufreq.c | 5 +---- drivers/cpufreq/maple-cpufreq.c | 9 +-------- drivers/cpufreq/pasemi-cpufreq.c | 9 +-------- drivers/cpufreq/pmac64-cpufreq.c | 9 +-------- drivers/cpufreq/s3c2416-cpufreq.c | 6 ++---- drivers/cpufreq/s3c24xx-cpufreq.c | 13 +------------ drivers/cpufreq/s3c64xx-cpufreq.c | 5 ++--- drivers/cpufreq/s5pv210-cpufreq.c | 4 +--- drivers/cpufreq/sa1100-cpufreq.c | 6 +----- drivers/cpufreq/sa1110-cpufreq.c | 6 +----- drivers/cpufreq/spear-cpufreq.c | 14 ++------------ drivers/cpufreq/tegra-cpufreq.c | 14 +++++++++----- include/linux/cpufreq.h | 3 +++ 19 files changed, 63 insertions(+), 145 deletions(-)
Many CPUFreq drivers for SMP system (where all cores share same clock lines), do similar stuff in their ->init() part.
This patch creates a generic routine in cpufreq core which can be used by these so that we can remove some redundant code.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/cpufreq.c | 31 +++++++++++++++++++++++++++++++ include/linux/cpufreq.h | 3 +++ 2 files changed, 34 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 556a8c5..5fc9c6b 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -188,6 +188,37 @@ u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy) } EXPORT_SYMBOL_GPL(get_cpu_idle_time);
+/* + * This is a generic cpufreq init() routine which can be used by cpufreq + * drivers of SMP systems. It will do following: + * - validate & show freq table passed + * - set policies transition latency + * - policy->cpus with all possible CPUs + */ +int cpufreq_generic_init(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int transition_latency) +{ + int ret; + + ret = cpufreq_table_validate_and_show(policy, table); + if (ret) { + pr_err("%s: invalid frequency table: %d\n", __func__, ret); + return ret; + } + + policy->cpuinfo.transition_latency = transition_latency; + + /* + * The driver only supports the SMP configuartion where all processors + * share the clock and voltage and clock. + */ + cpumask_setall(policy->cpus); + + return 0; +} +EXPORT_SYMBOL_GPL(cpufreq_generic_init); + struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) { struct cpufreq_policy *policy = NULL; diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index b4ad9b5..6adea26 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -424,6 +424,9 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu); int cpufreq_table_validate_and_show(struct cpufreq_policy *policy, struct cpufreq_frequency_table *table);
+int cpufreq_generic_init(struct cpufreq_policy *policy, + struct cpufreq_frequency_table *table, + unsigned int transition_latency); static inline int cpufreq_generic_exit(struct cpufreq_policy *policy) { cpufreq_frequency_table_put_attr(policy->cpu);
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Shawn Guo shawn.guo@linaro.org Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/cpufreq-cpu0.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index ddd9010..7273bfc 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c @@ -99,24 +99,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)
static int cpu0_cpufreq_init(struct cpufreq_policy *policy) { - int ret; - - ret = cpufreq_table_validate_and_show(policy, freq_table); - if (ret) { - pr_err("invalid frequency table: %d\n", ret); - return ret; - } - - policy->cpuinfo.transition_latency = transition_latency; - - /* - * The driver only supports the SMP configuartion where all processors - * share the clock and voltage and clock. Use cpufreq affected_cpus - * interface to have all CPUs scaled together. - */ - cpumask_setall(policy->cpus); - - return 0; + return cpufreq_generic_init(policy, freq_table, transition_latency); }
static struct cpufreq_driver cpu0_cpufreq_driver = {
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Linus Walleij linus.walleij@linaro.org Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/dbx500-cpufreq.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/drivers/cpufreq/dbx500-cpufreq.c b/drivers/cpufreq/dbx500-cpufreq.c index f66cb72..0e67ab9 100644 --- a/drivers/cpufreq/dbx500-cpufreq.c +++ b/drivers/cpufreq/dbx500-cpufreq.c @@ -44,26 +44,7 @@ static unsigned int dbx500_cpufreq_getspeed(unsigned int cpu)
static int dbx500_cpufreq_init(struct cpufreq_policy *policy) { - int res; - - /* get policy fields based on the table */ - res = cpufreq_table_validate_and_show(policy, freq_table); - if (res) { - pr_err("dbx500-cpufreq: Failed to read policy table\n"); - return res; - } - - /* - * FIXME : Need to take time measurement across the target() - * function with no/some/all drivers in the notification - * list. - */ - policy->cpuinfo.transition_latency = 20 * 1000; /* in ns */ - - /* policy sharing between dual CPUs */ - cpumask_setall(policy->cpus); - - return 0; + return cpufreq_generic_init(policy, freq_table, 20 * 1000); }
static struct cpufreq_driver dbx500_cpufreq_driver = {
On Wed, Aug 21, 2013 at 4:42 PM, Viresh Kumar viresh.kumar@linaro.org wrote:
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Linus Walleij linus.walleij@linaro.org Signed-off-by: Viresh Kumar viresh.kumar@linaro.org
Acked-by: Linus Walleij linus.walleij@linaro.org
Yours, Linus Walleij
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Amit Daniel Kachhap amit.daniel@samsung.com Cc: Kukjin Kim kgene.kim@samsung.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/exynos-cpufreq.c | 7 +------ drivers/cpufreq/exynos5440-cpufreq.c | 14 ++------------ 2 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c index 0f87a29..c9ae7e6 100644 --- a/drivers/cpufreq/exynos-cpufreq.c +++ b/drivers/cpufreq/exynos-cpufreq.c @@ -214,12 +214,7 @@ static struct notifier_block exynos_cpufreq_nb = {
static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) { - /* set the transition latency value */ - policy->cpuinfo.transition_latency = 100000; - - cpumask_setall(policy->cpus); - - return cpufreq_table_validate_and_show(policy, exynos_info->freq_table); + return cpufreq_generic_init(policy, exynos_info->freq_table, 100000); }
static struct cpufreq_driver exynos_driver = { diff --git a/drivers/cpufreq/exynos5440-cpufreq.c b/drivers/cpufreq/exynos5440-cpufreq.c index b9673fa..68da5f4 100644 --- a/drivers/cpufreq/exynos5440-cpufreq.c +++ b/drivers/cpufreq/exynos5440-cpufreq.c @@ -308,18 +308,8 @@ static void exynos_sort_descend_freq_table(void)
static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) { - int ret; - - ret = cpufreq_table_validate_and_show(policy, dvfs_info->freq_table); - if (ret) { - dev_err(dvfs_info->dev, "Invalid frequency table: %d\n", ret); - return ret; - } - - policy->cpuinfo.transition_latency = dvfs_info->latency; - cpumask_setall(policy->cpus); - - return 0; + return cpufreq_generic_init(policy, dvfs_info->freq_table, + dvfs_info->latency); }
static struct cpufreq_driver exynos_driver = {
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Shawn Guo shawn.guo@linaro.org Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/imx6q-cpufreq.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index f35c674..5efd9b7 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -150,18 +150,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
static int imx6q_cpufreq_init(struct cpufreq_policy *policy) { - int ret; - - ret = cpufreq_table_validate_and_show(policy, freq_table); - if (ret) { - dev_err(cpu_dev, "invalid frequency table: %d\n", ret); - return ret; - } - - policy->cpuinfo.transition_latency = transition_latency; - cpumask_setall(policy->cpus); - - return 0; + return cpufreq_generic_init(policy, freq_table, transition_latency); }
static struct cpufreq_driver imx6q_cpufreq_driver = {
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Andrew Lunn andrew@lunn.ch Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/kirkwood-cpufreq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c index fcf461e..7de4412 100644 --- a/drivers/cpufreq/kirkwood-cpufreq.c +++ b/drivers/cpufreq/kirkwood-cpufreq.c @@ -93,10 +93,7 @@ static int kirkwood_cpufreq_target(struct cpufreq_policy *policy, /* Module init and exit code */ static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy) { - /* cpuinfo and default policy values */ - policy->cpuinfo.transition_latency = 5000; /* 5uS */ - - return cpufreq_table_validate_and_show(policy, kirkwood_freq_table); + return cpufreq_generic_init(policy, kirkwood_freq_table, 5000); }
static struct cpufreq_driver kirkwood_cpufreq_driver = {
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Dmitry Eremin-Solenikov dbaryshkov@gmail.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/maple-cpufreq.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c index 45db7a2..2a2532a 100644 --- a/drivers/cpufreq/maple-cpufreq.c +++ b/drivers/cpufreq/maple-cpufreq.c @@ -141,16 +141,9 @@ static unsigned int maple_cpufreq_get_speed(unsigned int cpu)
static int maple_cpufreq_cpu_init(struct cpufreq_policy *policy) { - policy->cpuinfo.transition_latency = 12000; - /* secondary CPUs are tied to the primary one by the - * cpufreq core if in the secondary policy we tell it that - * it actually must be one policy together with all others. */ - cpumask_setall(policy->cpus); - - return cpufreq_table_validate_and_show(policy, maple_cpu_freqs); + return cpufreq_generic_init(policy, maple_cpu_freqs, 12000); }
- static struct cpufreq_driver maple_cpufreq_driver = { .name = "maple", .flags = CPUFREQ_CONST_LOOPS,
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/pasemi-cpufreq.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/cpufreq/pasemi-cpufreq.c b/drivers/cpufreq/pasemi-cpufreq.c index 4d69958..1c33136 100644 --- a/drivers/cpufreq/pasemi-cpufreq.c +++ b/drivers/cpufreq/pasemi-cpufreq.c @@ -202,20 +202,13 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy) pr_debug("%d: %d\n", i, pas_freqs[i].frequency); }
- policy->cpuinfo.transition_latency = get_gizmo_latency(); - cur_astate = get_cur_astate(policy->cpu); pr_debug("current astate is at %d\n",cur_astate);
policy->cur = pas_freqs[cur_astate].frequency; - cpumask_copy(policy->cpus, cpu_online_mask); - ppc_proc_freq = policy->cur * 1000ul;
- /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max - * are set correctly - */ - return cpufreq_table_validate_and_show(policy, pas_freqs); + return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency());
out_unmap_sdcpwr: iounmap(sdcpwr_mapbase);
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/pmac64-cpufreq.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c index 2557f16..18fecf3 100644 --- a/drivers/cpufreq/pmac64-cpufreq.c +++ b/drivers/cpufreq/pmac64-cpufreq.c @@ -321,16 +321,9 @@ static unsigned int g5_cpufreq_get_speed(unsigned int cpu)
static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy) { - policy->cpuinfo.transition_latency = transition_latency; - /* secondary CPUs are tied to the primary one by the - * cpufreq core if in the secondary policy we tell it that - * it actually must be one policy together with all others. */ - cpumask_copy(policy->cpus, cpu_online_mask); - - return cpufreq_table_validate_and_show(policy, g5_cpu_freqs); + return cpufreq_generic_init(policy, g5_cpu_freqs, transition_latency); }
- static struct cpufreq_driver g5_cpufreq_driver = { .name = "powermac", .flags = CPUFREQ_CONST_LOOPS,
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Kukjin Kim kgene.kim@samsung.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/s3c2416-cpufreq.c | 6 ++---- drivers/cpufreq/s3c24xx-cpufreq.c | 13 +------------ drivers/cpufreq/s3c64xx-cpufreq.c | 5 ++--- 3 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c index 0e13914..8d904a0 100644 --- a/drivers/cpufreq/s3c2416-cpufreq.c +++ b/drivers/cpufreq/s3c2416-cpufreq.c @@ -457,10 +457,8 @@ static int __init s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) /* Datasheet says PLL stabalisation time must be at least 300us, * so but add some fudge. (reference in LOCKCON0 register description) */ - policy->cpuinfo.transition_latency = (500 * 1000) + - s3c_freq->regulator_latency; - - ret = cpufreq_table_validate_and_show(policy, s3c_freq->freq_table); + ret = cpufreq_generic_init(policy, s3c_freq->freq_table, + (500 * 1000) + s3c_freq->regulator_latency); if (ret) goto err_freq_table;
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index e0fbaef..4850882 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c @@ -373,18 +373,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name)
static int s3c_cpufreq_init(struct cpufreq_policy *policy) { - printk(KERN_INFO "%s: initialising policy %p\n", __func__, policy); - - if (policy->cpu != 0) - return -EINVAL; - - /* feed the latency information from the cpu driver */ - policy->cpuinfo.transition_latency = cpu_cur.info->latency; - - if (ftab) - return cpufreq_table_validate_and_show(policy, ftab); - - return 0; + return cpufreq_generic_init(policy, ftab, cpu_cur.info->latency); }
static int __init s3c_cpufreq_initclks(void) diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index a983559..8b49a06 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c @@ -213,9 +213,8 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy) * the PLLs, which we don't currently) is ~300us worst case, * but add some fudge. */ - policy->cpuinfo.transition_latency = (500 * 1000) + regulator_latency; - - ret = cpufreq_table_validate_and_show(policy, s3c64xx_freq_table); + ret = cpufreq_generic_init(policy, s3c64xx_freq_table, + (500 * 1000) + regulator_latency); if (ret != 0) { pr_err("Failed to configure frequency table: %d\n", ret);
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Kukjin Kim kgene.kim@samsung.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/s5pv210-cpufreq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c index efa1080..e3973da 100644 --- a/drivers/cpufreq/s5pv210-cpufreq.c +++ b/drivers/cpufreq/s5pv210-cpufreq.c @@ -511,9 +511,7 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) s5pv210_dram_conf[1].refresh = (__raw_readl(S5P_VA_DMC1 + 0x30) * 1000); s5pv210_dram_conf[1].freq = clk_get_rate(dmc1_clk);
- policy->cpuinfo.transition_latency = 40000; - - return cpufreq_table_validate_and_show(policy, s5pv210_freq_table); + return cpufreq_generic_init(policy, s5pv210_freq_table, 40000);
out_dmc1: clk_put(dmc0_clk);
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: Russell King linux@arm.linux.org.uk Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/sa1100-cpufreq.c | 6 +----- drivers/cpufreq/sa1110-cpufreq.c | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/cpufreq/sa1100-cpufreq.c b/drivers/cpufreq/sa1100-cpufreq.c index a89c47b..623da74 100644 --- a/drivers/cpufreq/sa1100-cpufreq.c +++ b/drivers/cpufreq/sa1100-cpufreq.c @@ -197,11 +197,7 @@ static int sa1100_target(struct cpufreq_policy *policy, unsigned int ppcr)
static int __init sa1100_cpu_init(struct cpufreq_policy *policy) { - if (policy->cpu != 0) - return -EINVAL; - policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; - - return cpufreq_table_validate_and_show(policy, sa11x0_freq_table); + return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL); }
static struct cpufreq_driver sa1100_driver __refdata = { diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c index 0e52e80..2c2b2e6 100644 --- a/drivers/cpufreq/sa1110-cpufreq.c +++ b/drivers/cpufreq/sa1110-cpufreq.c @@ -306,11 +306,7 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)
static int __init sa1110_cpu_init(struct cpufreq_policy *policy) { - if (policy->cpu != 0) - return -EINVAL; - policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; - - return cpufreq_table_validate_and_show(policy, sa11x0_freq_table); + return cpufreq_generic_init(policy, sa11x0_freq_table, CPUFREQ_ETERNAL); }
/* sa1110_driver needs __refdata because it must remain after init registers
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Cc: spear-devel@list.st.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/spear-cpufreq.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index 4ad35a5..d9a8c5f 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c @@ -156,18 +156,8 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,
static int spear_cpufreq_init(struct cpufreq_policy *policy) { - int ret; - - ret = cpufreq_table_validate_and_show(policy, spear_cpufreq.freq_tbl); - if (ret) { - pr_err("cpufreq_table_validate_and_show() failed"); - return ret; - } - - policy->cpuinfo.transition_latency = spear_cpufreq.transition_latency; - cpumask_setall(policy->cpus); - - return 0; + return cpufreq_generic_init(policy, spear_cpufreq.freq_tbl, + spear_cpufreq.transition_latency); }
static struct cpufreq_driver spear_cpufreq_driver = {
Use generic cpufreq_generic_init() routine instead of replicating the same code here.
Along with that we are disabling clks in error cases and ->exit() routine.
Cc: Stephen Warren swarren@nvidia.com Signed-off-by: Viresh Kumar viresh.kumar@linaro.org --- drivers/cpufreq/tegra-cpufreq.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/cpufreq/tegra-cpufreq.c b/drivers/cpufreq/tegra-cpufreq.c index 3f25ab6..bc7c2a1 100644 --- a/drivers/cpufreq/tegra-cpufreq.c +++ b/drivers/cpufreq/tegra-cpufreq.c @@ -161,18 +161,21 @@ static struct notifier_block tegra_cpu_pm_notifier = {
static int tegra_cpu_init(struct cpufreq_policy *policy) { + int ret; + if (policy->cpu >= NUM_CPUS) return -EINVAL;
clk_prepare_enable(emc_clk); clk_prepare_enable(cpu_clk);
- cpufreq_table_validate_and_show(policy, freq_table); - /* FIXME: what's the actual transition time? */ - policy->cpuinfo.transition_latency = 300 * 1000; - - cpumask_copy(policy->cpus, cpu_possible_mask); + ret = cpufreq_generic_init(policy, freq_table, 300 * 1000); + if (ret) { + clk_disable_unprepare(cpu_clk); + clk_disable_unprepare(emc_clk); + return ret; + }
if (policy->cpu == 0) register_pm_notifier(&tegra_cpu_pm_notifier); @@ -183,6 +186,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy) static int tegra_cpu_exit(struct cpufreq_policy *policy) { cpufreq_frequency_table_put_attr(policy->cpu); + clk_disable_unprepare(cpu_clk); clk_disable_unprepare(emc_clk); return 0; }
On Wednesday, August 21, 2013 08:12:19 PM Viresh Kumar wrote:
Many CPUFreq drivers for SMP system (where all cores share same clock lines), do similar stuff in their ->init() part.
This patch creates a generic routine in cpufreq core which can be used by these so that we can remove some redundant code. And later part of patchset makes other drivers use this infrastructure.
Many drivers which weren't setting policy->cpus haven't been updated as they might have separate clocks for CPUs and setting all CPUs in policy->cpus may corrupt them..
This is Sixth part of my cleanup work for CPUFreq, first five are (And obviously its rebased over them):
OK, so the plan for merging this will be that we'll put 1 into linux-next and add 2 to it after a few days etc. to give people a chance to test one set of changes before going to the next one.
1: cpufreq: Introduce cpufreq_table_validate_and_show() https://lkml.org/lkml/2013/8/8/263
So perhaps we can *try* to push the above for 3.12 if it doesn't breaks stuff left and right.
Can you please resend it with all of the ACKs collected so far?
Thanks, Rafael
On 22 August 2013 04:50, Rafael J. Wysocki rjw@sisk.pl wrote:
OK, so the plan for merging this will be that we'll put 1 into linux-next and add 2 to it after a few days etc. to give people a chance to test one set of changes before going to the next one.
1: cpufreq: Introduce cpufreq_table_validate_and_show() https://lkml.org/lkml/2013/8/8/263
So perhaps we can *try* to push the above for 3.12 if it doesn't breaks stuff left and right.
Can you please resend it with all of the ACKs collected so far?
Sure..
But I believe we can reduce our work to some extent.. Probably instead of sending all again separately, we can bind them together logically..
So, I would like to divide these six patchsets into two and we can get the first one in 3.12 now..
This is how I would bind them:
Set I: CPUFreq: Introduce helper functions to remove code redundancy <132 Patches>
1: cpufreq: Introduce cpufreq_table_validate_and_show() https://lkml.org/lkml/2013/8/8/263
2: cpufreq: define generic routines for cpufreq drivers https://lkml.org/lkml/2013/8/10/48
4. CPUFreq: set policy->cur in cpufreq core instead of drivers https://lkml.org/lkml/2013/8/14/288
6. cpufreq: create & use cpufreq_generic_init() routine <This series>
Set II: CPUFreq: Make ->target lightweight() <70 Patches>
3. CPUFreq: Implement light weight ->target(): for 3.13 https://lkml.org/lkml/2013/8/13/349
5. CPUFreq: Move freq change notifications out of drivers https://lkml.org/lkml/2013/8/15/506
What do you say? I will wait for your reply before actually spamming LKML with so many patches :)
I have updated commits with all the Acks and pushed them to my for-v3.13 branch..
-- viresh
linaro-kernel@lists.linaro.org