CPUFreq: cleanup stuff for 3.13
Subsystems (16)
Viresh Kumar
maintainerPATCH 170/228 cpufreq: ppc: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/ppc-corenet-cpufreq.c | 15 ++++----------- drivers/cpufreq/ppc_cbe_cpufreq.c | 12 ++---------- 2 files changed, 6 insertions(+), 21 deletions(-)
drivers/cpufreq/ppc-corenet-cpufreq.c +4 -11
@@ -251,27 +251,20 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy) }static int corenet_cpufreq_target (struct cpufreq_policy *policy, -unsigned int target_freq,unsigned int relation) +unsigned int index) {struct cpufreq_freqs freqs; -unsigned int new;struct clk *parent;int ret;struct cpu_data *data =per_cpu (cpu_data, policy->cpu); -cpufreq_frequency_table_target (policy, data->table, - target_freq, relation, &new); - -if (policy->cur == data->table[new].frequency) -return 0 ; - freqs.old = policy->cur; - freqs.new = data->table[new].frequency; + freqs.new = data->table[index].frequency;mutex_lock (&cpufreq_lock);cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - parent =of_clk_get (data->parent, data->table[new].driver_data); + parent =of_clk_get (data->parent, data->table[index].driver_data); ret =clk_set_parent (data->clk, parent);if (ret) freqs.new = freqs.old;
@@ -288,7 +281,7 @@ static struct cpufreq_driver ppc_corenet_cpufreq_driver = { .init = corenet_cpufreq_cpu_init, .exit = __exit_p(corenet_cpufreq_cpu_exit), .verify = cpufreq_generic_frequency_table_verify, - .target = corenet_cpufreq_target, + .target_index = corenet_cpufreq_target, .get = corenet_cpufreq_get_speed, .attr = cpufreq_generic_attr, };
drivers/cpufreq/ppc_cbe_cpufreq.c +2 -10
@@ -129,18 +129,10 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy) }static int cbe_cpufreq_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +unsigned int cbe_pmode_new) {int rc;struct cpufreq_freqs freqs; -unsigned int cbe_pmode_new; - -cpufreq_frequency_table_target (policy, - cbe_freqs, - target_freq, - relation, - &cbe_pmode_new); freqs.old = policy->cur; freqs.new = cbe_freqs[cbe_pmode_new].frequency;
@@ -164,7 +156,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy,static struct cpufreq_driver cbe_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, - .target = cbe_cpufreq_target, + .target_index = cbe_cpufreq_target, .init = cbe_cpufreq_cpu_init, .exit = cpufreq_generic_exit, .name ="cbe-cpufreq" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 171/228 cpufreq: pxa: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/pxa2xx-cpufreq.c | 13 ++----------- drivers/cpufreq/pxa3xx-cpufreq.c | 17 +++-------------- 2 files changed, 5 insertions(+), 25 deletions(-)
drivers/cpufreq/pxa2xx-cpufreq.c +2 -11
@@ -267,14 +267,11 @@ static unsigned int pxa_cpufreq_get(unsigned int cpu)return get_clk_frequency_khz (0 ); } -static int pxa_set_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int pxa_set_target (struct cpufreq_policy *policy,unsigned int idx) {struct cpufreq_frequency_table *pxa_freqs_table;pxa_freqs_t *pxa_freq_settings;struct cpufreq_freqs freqs; -unsigned int idx;unsigned long flags;unsigned int new_freq_cpu, new_freq_mem;unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -283,12 +280,6 @@ static int pxa_set_target(struct cpufreq_policy *policy,/* Get the current policy */ find_freq_tables (&pxa_freqs_table, &pxa_freq_settings); -/* Lookup the next frequency */ -if (cpufreq_frequency_table_target (policy, pxa_freqs_table, - target_freq, relation, &idx)) { -return -EINVAL ; - } - new_freq_cpu = pxa_freq_settings[idx].khz; new_freq_mem = pxa_freq_settings[idx].membus; freqs.old = policy->cur;
@@ -448,7 +439,7 @@ static int pxa_cpufreq_init(struct cpufreq_policy *policy)static struct cpufreq_driver pxa_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, - .target = pxa_set_target, + .target_index = pxa_set_target, .init = pxa_cpufreq_init, .exit = cpufreq_generic_exit, .get = pxa_cpufreq_get,
drivers/cpufreq/pxa3xx-cpufreq.c +3 -14
@@ -155,24 +155,16 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)return pxa3xx_get_clk_frequency_khz (0 ); } -static int pxa3xx_cpufreq_set (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int pxa3xx_cpufreq_set (struct cpufreq_policy *policy,unsigned int index) {struct pxa3xx_freq_info *next;struct cpufreq_freqs freqs;unsigned long flags; -int idx;if (policy->cpu !=0 )return -EINVAL ; -/* Lookup the next frequency */ -if (cpufreq_frequency_table_target (policy, pxa3xx_freqs_table, - target_freq, relation, &idx)) -return -EINVAL ; - - next = &pxa3xx_freqs[idx]; + next = &pxa3xx_freqs[index]; freqs.old = policy->cur; freqs.new = next->cpufreq_mhz *1000 ;
@@ -181,9 +173,6 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, freqs.old /1000 , freqs.new /1000 , (freqs.old == freqs.new) ? " (skipped)" : ""); -if (freqs.old == target_freq) -return 0 ; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );local_irq_save (flags);
@@ -225,7 +214,7 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)static struct cpufreq_driver pxa3xx_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, - .target = pxa3xx_cpufreq_set, + .target_index = pxa3xx_cpufreq_set, .init = pxa3xx_cpufreq_init, .exit = cpufreq_generic_exit, .get = pxa3xx_cpufreq_get,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 172/228 cpufreq: s3c2416: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/s3c2416-cpufreq.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/cpufreq/s3c2416-cpufreq.c +4 -13
@@ -217,24 +217,15 @@ static int s3c2416_cpufreq_leave_dvs(struct s3c2416_data *s3c_freq, int idx) }static int s3c2416_cpufreq_set_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +unsigned int index) {struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;struct cpufreq_freqs freqs;int idx, ret, to_dvs =0 ; -unsigned int i;mutex_lock (&cpufreq_lock); -pr_debug ("cpufreq: to %dKHz, relation %d\n" , target_freq, relation); - - ret =cpufreq_frequency_table_target (policy, s3c_freq->freq_table, - target_freq, relation, &i); -if (ret !=0 ) - goto out; - - idx = s3c_freq->freq_table[i].driver_data; + idx = s3c_freq->freq_table[index].driver_data;if (idx ==SOURCE_HCLK ) to_dvs =1 ;
@@ -256,7 +247,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,*/ freqs.new = (s3c_freq->is_dvs && !to_dvs) ?clk_get_rate (s3c_freq->hclk) /1000 - : s3c_freq->freq_table[i].frequency; + : s3c_freq->freq_table[index].frequency;pr_debug ("cpufreq: Transition %d-%dkHz\n" , freqs.old, freqs.new);
@@ -505,7 +496,7 @@ err_hclk:static struct cpufreq_driver s3c2416_cpufreq_driver = { .flags =0 , .verify = cpufreq_generic_frequency_table_verify, - .target = s3c2416_cpufreq_set_target, + .target_index = s3c2416_cpufreq_set_target, .get = s3c2416_cpufreq_get_speed, .init = s3c2416_cpufreq_driver_init, .name ="s3c2416" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 173/228 cpufreq: s3c64xx: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/s3c64xx-cpufreq.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/cpufreq/s3c64xx-cpufreq.c +4 -14
@@ -63,26 +63,16 @@ static unsigned int s3c64xx_cpufreq_get_speed(unsigned int cpu) }static int s3c64xx_cpufreq_set_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +unsigned int index) {int ret; -unsigned int i;struct cpufreq_freqs freqs;struct s3c64xx_dvfs *dvfs; - ret =cpufreq_frequency_table_target (policy, s3c64xx_freq_table, - target_freq, relation, &i); -if (ret !=0 ) -return ret; - freqs.old =clk_get_rate (armclk) /1000 ; - freqs.new = s3c64xx_freq_table[i].frequency; + freqs.new = s3c64xx_freq_table[index].frequency; freqs.flags =0 ; - dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[i].driver_data]; - -if (freqs.old == freqs.new) -return 0 ; + dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[index].driver_data];pr_debug ("Transition %d-%dkHz\n" , freqs.old, freqs.new);
@@ -254,7 +244,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)static struct cpufreq_driver s3c64xx_cpufreq_driver = { .flags =0 , .verify = cpufreq_generic_frequency_table_verify, - .target = s3c64xx_cpufreq_set_target, + .target_index = s3c64xx_cpufreq_set_target, .get = s3c64xx_cpufreq_get_speed, .init = s3c64xx_cpufreq_driver_init, .name ="s3c" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 174/228 cpufreq: s5pv210: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
This drivers wasn't as straight forward as other ones. It was doing some funny stuff to disable driver while going into suspend mode. This part is simplified as well to get this converted to ->target_index().
--- drivers/cpufreq/s5pv210-cpufreq.c | 54 ++++++++++----------------------------- 1 file changed, 14 insertions(+), 40 deletions(-)
drivers/cpufreq/s5pv210-cpufreq.c +14 -40
@@ -36,16 +36,7 @@ static DEFINE_MUTEX(set_freq_lock);/* Use 800MHz when entering sleep mode */ #define SLEEP_FREQ (800 * 1000) -/* -* relation has an additional symantics other than the standard of cpufreq -* DISALBE_FURTHER_CPUFREQ: disable further access to target -* ENABLE_FURTUER_CPUFREQ: enable access to target -*/ -enum cpufreq_access { -DISABLE_FURTHER_CPUFREQ =0x10 , -ENABLE_FURTHER_CPUFREQ =0x20 , -}; - +/* Tracks if cpu freqency can be updated anymore */ static bool no_cpufreq_access;/*
@@ -182,12 +173,10 @@ static unsigned int s5pv210_getspeed(unsigned int cpu)return clk_get_rate (cpu_clk) /1000 ; } -static int s5pv210_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int s5pv210_target (struct cpufreq_policy *policy,unsigned int index) {unsigned long reg; -unsigned int index, priv_index; +unsigned int priv_index;unsigned int pll_changing =0 ;unsigned int bus_speed_changing =0 ;int arm_volt, int_volt;
@@ -195,9 +184,6 @@ static int s5pv210_target(struct cpufreq_policy *policy,mutex_lock (&set_freq_lock); -if (relation &ENABLE_FURTHER_CPUFREQ ) - no_cpufreq_access = false; -if (no_cpufreq_access) {#ifdef CONFIG_PM_VERBOSE pr_err("%s:%d denied access to %s as it is disabled"
@@ -207,27 +193,13 @@ static int s5pv210_target(struct cpufreq_policy *policy, goto exit; } -if (relation &DISABLE_FURTHER_CPUFREQ ) - no_cpufreq_access = true; - - relation &= ~(ENABLE_FURTHER_CPUFREQ |DISABLE_FURTHER_CPUFREQ ); - freqs.old =s5pv210_getspeed (0 ); - -if (cpufreq_frequency_table_target (policy, s5pv210_freq_table, - target_freq, relation, &index)) { - ret = -EINVAL ; - goto exit; - } - freqs.new = s5pv210_freq_table[index].frequency; -if (freqs.new == freqs.old) - goto exit; -/* Finding current running level index */ if (cpufreq_frequency_table_target (policy, s5pv210_freq_table, - freqs.old, relation, &priv_index)) { + freqs.old,CPUFREQ_RELATION_H , + &priv_index)) { ret = -EINVAL ; goto exit; }
@@ -559,16 +531,18 @@ static int s5pv210_cpufreq_notifier_event(struct notifier_block *this,switch (event) {case PM_SUSPEND_PREPARE : - ret =cpufreq_driver_target (cpufreq_cpu_get (0 ),SLEEP_FREQ , -DISABLE_FURTHER_CPUFREQ ); + ret =cpufreq_driver_target (cpufreq_cpu_get (0 ),SLEEP_FREQ ,0 );if (ret <0 )return NOTIFY_BAD ; +/* Disable updation of cpu frequency */ + no_cpufreq_access = true;return NOTIFY_OK ;case PM_POST_RESTORE :case PM_POST_SUSPEND : -cpufreq_driver_target (cpufreq_cpu_get (0 ),SLEEP_FREQ , -ENABLE_FURTHER_CPUFREQ ); +/* Enable updation of cpu frequency */ + no_cpufreq_access = false; +cpufreq_driver_target (cpufreq_cpu_get (0 ),SLEEP_FREQ ,0 );return NOTIFY_OK ; }
@@ -581,18 +555,18 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this, {int ret; - ret =cpufreq_driver_target (cpufreq_cpu_get (0 ),SLEEP_FREQ , -DISABLE_FURTHER_CPUFREQ ); + ret =cpufreq_driver_target (cpufreq_cpu_get (0 ),SLEEP_FREQ ,0 );if (ret <0 )return NOTIFY_BAD ; + no_cpufreq_access = true;return NOTIFY_DONE ; }static struct cpufreq_driver s5pv210_driver = { .flags =CPUFREQ_STICKY , .verify = cpufreq_generic_frequency_table_verify, - .target = s5pv210_target, + .target_index = s5pv210_target, .get = s5pv210_getspeed, .init = s5pv210_cpu_init, .name ="s5pv210" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 175/228 cpufreq: sa11x0: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
Some existing routines are no more required and so are removed now.
--- arch/arm/mach-sa1100/generic.c | 20 -------------------- arch/arm/mach-sa1100/generic.h | 2 -- drivers/cpufreq/sa1100-cpufreq.c | 24 ++++-------------------- drivers/cpufreq/sa1110-cpufreq.c | 26 ++++---------------------- 4 files changed, 8 insertions(+), 64 deletions(-)
arch/arm/mach-sa1100/generic.c +0 -20
@@ -62,26 +62,6 @@ struct cpufreq_frequency_table sa11x0_freq_table[NR_FREQS+1] = { { .frequency = CPUFREQ_TABLE_END, }, }; -/* rounds up(!) */ -unsigned int sa11x0_freq_to_ppcr (unsigned int khz) -{ -int i; - -for (i =0 ; i <NR_FREQS ; i++) -if (sa11x0_freq_table[i].frequency >= khz) -break ; - -return i; -} - -unsigned int sa11x0_ppcr_to_freq (unsigned int idx) -{ -unsigned int freq =0 ; -if (idx <NR_FREQS ) - freq = sa11x0_freq_table[idx].frequency; -return freq; -} -unsigned int sa11x0_getspeed (unsigned int cpu) {if (cpu)
arch/arm/mach-sa1100/generic.h +0 -2
@@ -22,9 +22,7 @@ extern void sa1110_mb_disable(void);struct cpufreq_policy ;extern struct cpufreq_frequency_table sa11x0_freq_table[]; -extern unsigned int sa11x0_freq_to_ppcr (unsigned int khz);extern unsigned int sa11x0_getspeed (unsigned int cpu); -extern unsigned int sa11x0_ppcr_to_freq (unsigned int idx);struct flash_platform_data ;struct resource ;
drivers/cpufreq/sa1100-cpufreq.c +4 -20
@@ -177,36 +177,20 @@ static void sa1100_update_dram_timings(int current_speed, int new_speed) } } -static int sa1100_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int sa1100_target (struct cpufreq_policy *policy,unsigned int ppcr) {unsigned int cur =sa11x0_getspeed (0 ); -unsigned int new_ppcr;struct cpufreq_freqs freqs; - new_ppcr =sa11x0_freq_to_ppcr (target_freq); -switch (relation) { -case CPUFREQ_RELATION_L : -if (sa11x0_ppcr_to_freq (new_ppcr) > policy->max) - new_ppcr--; -break ; -case CPUFREQ_RELATION_H : -if ((sa11x0_ppcr_to_freq (new_ppcr) > target_freq) && - (sa11x0_ppcr_to_freq (new_ppcr -1 ) >= policy->min)) - new_ppcr--; -break ; - } - freqs.old = cur; - freqs.new =sa11x0_ppcr_to_freq (new_ppcr); + freqs.new = sa11x0_freq_table[ppcr].frequency;cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );if (freqs.new > cur)sa1100_update_dram_timings (cur, freqs.new); -PPCR = new_ppcr; +PPCR = ppcr;if (freqs.new < cur)sa1100_update_dram_timings (cur, freqs.new);
@@ -224,7 +208,7 @@ static int __init sa1100_cpu_init(struct cpufreq_policy *policy)static struct cpufreq_driver sa1100_driver__refdata = { .flags =CPUFREQ_STICKY , .verify = cpufreq_generic_frequency_table_verify, - .target = sa1100_target, + .target_index = sa1100_target, .get = sa11x0_getspeed, .init = sa1100_cpu_init, .name ="sa1100" ,
drivers/cpufreq/sa1110-cpufreq.c +4 -22
@@ -229,34 +229,16 @@ sdram_update_refresh(u_int cpu_khz, struct sdram_params *sdram)/* * Ok, set the CPU frequency. */ -static int sa1110_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int sa1110_target (struct cpufreq_policy *policy,unsigned int ppcr) {struct sdram_params *sdram = &sdram_params;struct cpufreq_freqs freqs;struct sdram_info sd;unsigned long flags; -unsigned int ppcr, unused; - -switch (relation) { -case CPUFREQ_RELATION_L : - ppcr =sa11x0_freq_to_ppcr (target_freq); -if (sa11x0_ppcr_to_freq (ppcr) > policy->max) - ppcr--; -break ; -case CPUFREQ_RELATION_H : - ppcr =sa11x0_freq_to_ppcr (target_freq); -if (ppcr && (sa11x0_ppcr_to_freq (ppcr) > target_freq) && - (sa11x0_ppcr_to_freq (ppcr-1 ) >= policy->min)) - ppcr--; -break ; -default : -return -EINVAL ; - } +unsigned int unused; freqs.old =sa11x0_getspeed (0 ); - freqs.new =sa11x0_ppcr_to_freq (ppcr); + freqs.new = sa11x0_freq_table[ppcr].frequency;sdram_calculate_timing (&sd, freqs.new, sdram);
@@ -340,7 +322,7 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)static struct cpufreq_driver sa1110_driver__refdata = { .flags =CPUFREQ_STICKY , .verify = cpufreq_generic_frequency_table_verify, - .target = sa1110_target, + .target_index = sa1110_target, .get = sa11x0_getspeed, .init = sa1110_cpu_init, .name ="sa1110" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 175/228] cpufreq: sa11x0: Convert to light weight ->target_index() routine
Quoted 10 lines · Viresh Kumar
This patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call
cpufreq_frequency_table_target()before calling this routine and will pass index to it.Some existing routines are no more required and so are removed now.
Cc Russell King <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
Viresh Kumar
maintainerPATCH 176/228 cpufreq: sc520: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/sc520_freq.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/cpufreq/sc520_freq.c +2 -17
@@ -53,8 +53,7 @@ static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu) } } -static void sc520_freq_set_cpu_state (struct cpufreq_policy *policy, -unsigned int state) +static int sc520_freq_target (struct cpufreq_policy *policy,unsigned int state) {struct cpufreq_freqs freqs;
@@ -76,24 +75,10 @@ static void sc520_freq_set_cpu_state(struct cpufreq_policy *policy,local_irq_enable ();cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -}; - -static int sc520_freq_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) -{ -unsigned int newstate =0 ; - -if (cpufreq_frequency_table_target (policy, sc520_freq_table, - target_freq, relation, &newstate)) -return -EINVAL ; - -sc520_freq_set_cpu_state (policy, newstate);return 0 ; } -/* * Module init and exit code */
@@ -117,7 +102,7 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy)static struct cpufreq_driver sc520_freq_driver = { .get = sc520_freq_get_cpu_frequency, .verify = cpufreq_generic_frequency_table_verify, - .target = sc520_freq_target, + .target_index = sc520_freq_target, .init = sc520_freq_cpu_init, .exit = cpufreq_generic_exit, .name ="sc520_freq" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 177/228 cpufreq: sparc: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/sparc-us2e-cpufreq.c | 21 +++------------------ drivers/cpufreq/sparc-us3-cpufreq.c | 23 +++-------------------- 2 files changed, 6 insertions(+), 38 deletions(-)
drivers/cpufreq/sparc-us2e-cpufreq.c +3 -18
@@ -245,8 +245,7 @@ static unsigned int us2e_freq_get(unsigned int cpu)return clock_tick /estar_to_divisor (estar); } -static void us2e_set_cpu_divider_index (struct cpufreq_policy *policy, -unsigned int index) +static int us2e_freq_target (struct cpufreq_policy *policy,unsigned int index) {unsigned int cpu = policy->cpu;unsigned long new_bits, new_freq;
@@ -277,20 +276,6 @@ static void us2e_set_cpu_divider_index(struct cpufreq_policy *policy,cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );set_cpus_allowed_ptr (current, &cpus_allowed); -} - -static int us2e_freq_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) -{ -unsigned int new_index =0 ; - -if (cpufreq_frequency_table_target (policy, - &us2e_freq_table[policy->cpu].table[0 ], - target_freq, relation, &new_index)) -return -EINVAL ; - -us2e_set_cpu_divider_index (policy, new_index);return 0 ; }
@@ -325,7 +310,7 @@ static int us2e_freq_cpu_exit(struct cpufreq_policy *policy) {if (cpufreq_us2e_driver) {cpufreq_frequency_table_put_attr (policy->cpu); -us2e_set_cpu_divider_index (policy,0 ); +us2e_freq_target (policy,0 ); }return 0 ;
@@ -358,7 +343,7 @@ static int __init us2e_freq_init(void) driver->init = us2e_freq_cpu_init; driver->verify = cpufreq_generic_frequency_table_verify; - driver->target = us2e_freq_target; + driver->target_index = us2e_freq_target; driver->get = us2e_freq_get; driver->exit = us2e_freq_cpu_exit;strcpy (driver->name,"UltraSPARC-IIe" );
drivers/cpufreq/sparc-us3-cpufreq.c +3 -20
@@ -93,8 +93,7 @@ static unsigned int us3_freq_get(unsigned int cpu)return ret; } -static void us3_set_cpu_divider_index (struct cpufreq_policy *policy, -unsigned int index) +static int us3_freq_target (struct cpufreq_policy *policy,unsigned int index) {unsigned int cpu = policy->cpu;unsigned long new_bits, new_freq, reg;
@@ -136,22 +135,6 @@ static void us3_set_cpu_divider_index(struct cpufreq_policy *policy,cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );set_cpus_allowed_ptr (current, &cpus_allowed); -} - -static int us3_freq_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) -{ -unsigned int new_index =0 ; - -if (cpufreq_frequency_table_target (policy, - &us3_freq_table[policy->cpu].table[0 ], - target_freq, - relation, - &new_index)) -return -EINVAL ; - -us3_set_cpu_divider_index (policy, new_index);return 0 ; }
@@ -182,7 +165,7 @@ static int us3_freq_cpu_exit(struct cpufreq_policy *policy) {if (cpufreq_us3_driver) {cpufreq_frequency_table_put_attr (policy->cpu); -us3_set_cpu_divider_index (policy,0 ); +us3_freq_target (policy,0 ); }return 0 ;
@@ -219,7 +202,7 @@ static int __init us3_freq_init(void) driver->init = us3_freq_cpu_init; driver->verify = cpufreq_generic_frequency_table_verify; - driver->target = us3_freq_target; + driver->target_index = us3_freq_target; driver->get = us3_freq_get; driver->exit = us3_freq_cpu_exit;strcpy (driver->name,"UltraSPARC-III" );
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 178/228 cpufreq: SPEAr: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/spear-cpufreq.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/cpufreq/spear-cpufreq.c +4 -8
@@ -105,20 +105,16 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq) }static int spear_cpufreq_target (struct cpufreq_policy *policy, -unsigned int target_freq,unsigned int relation) +unsigned int index) {struct cpufreq_freqs freqs;unsigned long newfreq;struct clk *srcclk; -int index, ret, mult =1 ; - -if (cpufreq_frequency_table_target (policy, spear_cpufreq.freq_tbl, - target_freq, relation, &index)) -return -EINVAL ; +int ret, mult =1 ; freqs.old =spear_cpufreq_get (0 ); - newfreq = spear_cpufreq.freq_tbl[index].frequency *1000 ; +if (of_machine_is_compatible ("st,spear1340" )) {/* * SPEAr1340 is special in the sense that due to the possibility
@@ -179,7 +175,7 @@ static struct cpufreq_driver spear_cpufreq_driver = { .name = "cpufreq-spear", .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, - .target = spear_cpufreq_target, + .target_index = spear_cpufreq_target, .get = spear_cpufreq_get, .init = spear_cpufreq_init, .exit = cpufreq_generic_exit,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 179/228 cpufreq: speedstep: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/speedstep-centrino.c | 26 +++++++------------------- drivers/cpufreq/speedstep-ich.c | 24 ++++++------------------ drivers/cpufreq/speedstep-smi.c | 20 +++++--------------- 3 files changed, 18 insertions(+), 52 deletions(-)
drivers/cpufreq/speedstep-centrino.c +7 -19
@@ -417,21 +417,17 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)/** * centrino_setpolicy - set a new CPUFreq policy * @policy: new policy -* @target_freq: the target frequency -* @relation: how that frequency relates to achieved frequency -* (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) +* @index: index of target frequency * * Sets a new CPUFreq policy. */ -static int centrino_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int centrino_target (struct cpufreq_policy *policy,unsigned int index) { -unsigned int newstate =0 ;unsigned int msr, oldmsr =0 , h =0 , cpu = policy->cpu;struct cpufreq_freqs freqs;int retval =0 ;unsigned int j, first_cpu, tmp; +struct cpufreq_frequency_table *op_points;cpumask_var_t covered_cpus;if (unlikely (!zalloc_cpumask_var (&covered_cpus,GFP_KERNEL )))
@@ -442,16 +438,8 @@ static int centrino_target (struct cpufreq_policy *policy, goto out; } -if (unlikely (cpufreq_frequency_table_target (policy, -per_cpu (centrino_model, cpu)->op_points, - target_freq, - relation, - &newstate))) { - retval = -EINVAL ; - goto out; - } - first_cpu =1 ; + op_points = &per_cpu (centrino_model, cpu)->op_points[index];for_each_cpu (j, policy->cpus) {int good_cpu;
@@ -475,7 +463,7 @@ static int centrino_target (struct cpufreq_policy *policy,break ; } - msr =per_cpu (centrino_model, cpu)->op_points[newstate].driver_data; + msr = op_points->driver_data;if (first_cpu) {rdmsr_on_cpu (good_cpu,MSR_IA32_PERF_CTL , &oldmsr, &h);
@@ -490,7 +478,7 @@ static int centrino_target (struct cpufreq_policy *policy, freqs.new =extract_clock (msr, cpu,0 );pr_debug ("target=%dkHz old=%d new=%d msr=%04x\n" , - target_freq, freqs.old, freqs.new, msr); + op_points->frequency, freqs.old, freqs.new, msr);cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );
@@ -541,7 +529,7 @@ static struct cpufreq_driver centrino_driver = { .init = centrino_cpu_init, .exit = centrino_cpu_exit, .verify = cpufreq_generic_frequency_table_verify, - .target = centrino_target, + .target_index = centrino_target, .get = get_cur_freq, .attr = cpufreq_generic_attr, };
drivers/cpufreq/speedstep-ich.c +6 -18
@@ -251,36 +251,24 @@ static unsigned int speedstep_get(unsigned int cpu)/** * speedstep_target - set a new CPUFreq policy * @policy: new policy -* @target_freq: the target frequency -* @relation: how that frequency relates to achieved frequency -* (CPUFREQ_RELATION_L or CPUFREQ_RELATION_H) +* @index: index of target frequency * * Sets a new CPUFreq policy. */ -static int speedstep_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int speedstep_target (struct cpufreq_policy *policy,unsigned int index) { -unsigned int newstate =0 , policy_cpu; +unsigned int policy_cpu;struct cpufreq_freqs freqs; -if (cpufreq_frequency_table_target (policy, &speedstep_freqs[0 ], - target_freq, relation, &newstate)) -return -EINVAL ; - policy_cpu =cpumask_any_and (policy->cpus, cpu_online_mask); freqs.old =speedstep_get (policy_cpu); - freqs.new = speedstep_freqs[newstate].frequency; + freqs.new = speedstep_freqs[index].frequency;pr_debug ("transiting from %u to %u kHz\n" , freqs.old, freqs.new); -/* no transition necessary */ -if (freqs.old == freqs.new) -return 0 ; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -smp_call_function_single (policy_cpu, _speedstep_set_state, &newstate, +smp_call_function_single (policy_cpu, _speedstep_set_state, &index, true);cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );
@@ -330,7 +318,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)static struct cpufreq_driver speedstep_driver = { .name ="speedstep-ich" , .verify = cpufreq_generic_frequency_table_verify, - .target = speedstep_target, + .target_index = speedstep_target, .init = speedstep_cpu_init, .exit = cpufreq_generic_exit, .get = speedstep_get,
drivers/cpufreq/speedstep-smi.c +5 -15
@@ -235,29 +235,19 @@ static void speedstep_set_state(unsigned int state)/** * speedstep_target - set a new CPUFreq policy * @policy: new policy -* @target_freq: new freq -* @relation: +* @index: index of new freq * * Sets a new CPUFreq policy/freq. */ -static int speedstep_target (struct cpufreq_policy *policy, -unsigned int target_freq,unsigned int relation) +static int speedstep_target (struct cpufreq_policy *policy,unsigned int index) { -unsigned int newstate =0 ;struct cpufreq_freqs freqs; -if (cpufreq_frequency_table_target (policy, &speedstep_freqs[0 ], - target_freq, relation, &newstate)) -return -EINVAL ; - freqs.old = speedstep_freqs[speedstep_get_state ()].frequency; - freqs.new = speedstep_freqs[newstate].frequency; - -if (freqs.old == freqs.new) -return 0 ; + freqs.new = speedstep_freqs[index].frequency;cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -speedstep_set_state (newstate); +speedstep_set_state (index);cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );return 0 ;
@@ -327,7 +317,7 @@ static int speedstep_resume(struct cpufreq_policy *policy)static struct cpufreq_driver speedstep_driver = { .name ="speedstep-smi" , .verify = cpufreq_generic_frequency_table_verify, - .target = speedstep_target, + .target_index = speedstep_target, .init = speedstep_cpu_init, .exit = cpufreq_generic_exit, .get = speedstep_get,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 180/228 cpufreq: tegra: Convert to light weight ->target_index() routine
In reply to Viresh KumarThis patch converts existing .target() to newly defined light weight .target_index() routine for this driver.
CPUFreq core will call cpufreq_frequency_table_target() before calling this routine and will pass index to it.
--- drivers/cpufreq/tegra-cpufreq.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/cpufreq/tegra-cpufreq.c +3 -9
@@ -150,11 +150,8 @@ static unsigned long tegra_cpu_highest_speed(void)return rate; } -static int tegra_target (struct cpufreq_policy *policy, -unsigned int target_freq, -unsigned int relation) +static int tegra_target (struct cpufreq_policy *policy,unsigned int index) { -unsigned int idx;unsigned int freq;int ret =0 ;
@@ -165,10 +162,7 @@ static int tegra_target(struct cpufreq_policy *policy, goto out; } -cpufreq_frequency_table_target (policy, freq_table, target_freq, - relation, &idx); - - freq = freq_table[idx].frequency; + freq = freq_table[index].frequency; target_cpu_speed[policy->cpu] = freq;
@@ -238,7 +232,7 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)static struct cpufreq_driver tegra_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, - .target = tegra_target, + .target_index = tegra_target, .get = tegra_getspeed, .init = tegra_cpu_init, .exit = tegra_cpu_exit,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 181/228 cpufreq: move freq change notifications to cpufreq core
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
There are few special cases though, like exynos5440, which doesn't do everything on the call to ->target_index() routine and call some kind of bottom halves for doing this work, work/tasklet/etc..
They may continue doing notification from their own code and so this patch introduces another flag: CPUFREQ_ASYNC_NOTIFICATION, which will be set by such drivers.
--- drivers/cpufreq/cpufreq.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/cpufreq/cpufreq.c +35 -0
@@ -1787,6 +1787,9 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, retval = cpufreq_driver->target (policy, target_freq, relation); else if (cpufreq_driver->target_index) {struct cpufreq_frequency_table *freq_table; +struct cpufreq_freqs freqs; +unsigned long flags; +bool notify;int index; freq_table =cpufreq_frequency_get_table (policy->cpu);
@@ -1807,7 +1810,39 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, goto out; } +read_lock_irqsave (&cpufreq_driver_lock, flags); + notify = !(cpufreq_driver->flags &CPUFREQ_ASYNC_NOTIFICATION ); +read_unlock_irqrestore (&cpufreq_driver_lock, flags); + +if (notify) { + freqs.old = policy->cur; + freqs.new = freq_table[index].frequency; + freqs.flags =0 ; + +pr_debug ("%s: cpu: %d, oldfreq: %u, new freq: %u\n" , + __func__, policy->cpu, freqs.old, + freqs.new); + +cpufreq_notify_transition (policy, &freqs, +CPUFREQ_PRECHANGE ); + } + retval = cpufreq_driver->target_index (policy, index); +if (retval) +pr_err ("%s: Failed to change cpu frequency: %d\n" , + __func__, retval); + +if (notify) { +/* +* Notify with old freq in case we failed to change +* frequency +*/ +if (retval) + freqs.new = freqs.old; + +cpufreq_notify_transition (policy, &freqs, +CPUFREQ_POSTCHANGE ); + } } out:
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core
drivers/cpufreq/cpufreq.c int __cpufreq_driver_target(struct cpufreq_policy *policy, · line 1815
Quoted 3 lines · Viresh Kumar
drivers/cpufreq/cpufreq.c +3
-0+read_lock_irqsave (&cpufreq_driver_lock, flags); + notify = !(cpufreq_driver->flags &CPUFREQ_ASYNC_NOTIFICATION ); +read_unlock_irqrestore (&cpufreq_driver_lock, flags);
I don't think this needs to be read under a lock - if this bit changes dynamically, then there's something very wrong.
Viresh Kumar
maintainerRe: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core
Quoted 7 lines · Russell King - ARM Linux
Review
Quoted 3 lines · Viresh Kumar
(quoted diff) +3
-0+ read_lock_irqsave(&cpufreq_driver_lock, flags); + notify = !(cpufreq_driver->flags & CPUFREQ_ASYNC_NOTIFICATION); + read_unlock_irqrestore(&cpufreq_driver_lock, flags);I don't think this needs to be read under a lock - if this bit changes dynamically, then there's something very wrong.
No it doesn't change dynamically.. Was a mistake.. Following change folded into the original commit (attached)
drivers/cpufreq/cpufreq.c +0 -3
@@ -1802,7 +1802,6 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,else if (cpufreq_driver->target_index) {struct cpufreq_frequency_table *freq_table;struct cpufreq_freqs freqs; -unsigned long flags;bool notify;int index;
@@ -1824,9 +1823,7 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, goto out; } -read_lock_irqsave (&cpufreq_driver_lock, flags); notify = !(cpufreq_driver->flags &CPUFREQ_ASYNC_NOTIFICATION ); -read_unlock_irqrestore (&cpufreq_driver_lock, flags);if (notify) { freqs.old = policy->cur;
From f34fc9f4e38df19dff41bc529d33ade1a80d0bfb Mon Sep 17 00:00:00 2001
Message-Id: <f34fc9f4e38df19dff41bc529d33ade1a80d0bfb.1379088136.git.viresh.kumar@linaro.org>
From: Viresh Kumar <[email protected]>
Date: Wed, 14 Aug 2013 19:38:24 +0530
Subject: [PATCH 181/228] cpufreq: move freq change notifications to cpufreq core
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
There are few special cases though, like exynos5440, which doesn't do everything on the call to ->target_index() routine and call some kind of bottom halves for doing this work, work/tasklet/etc..
They may continue doing notification from their own code and so this patch introduces another flag: CPUFREQ_ASYNC_NOTIFICATION, which will be set by such drivers.
--- drivers/cpufreq/cpufreq.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/cpufreq/cpufreq.c +32 -0
@@ -1787,6 +1787,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, retval = cpufreq_driver->target (policy, target_freq, relation); else if (cpufreq_driver->target_index) {struct cpufreq_frequency_table *freq_table; +struct cpufreq_freqs freqs; +bool notify;int index; freq_table =cpufreq_frequency_get_table (policy->cpu);
@@ -1807,7 +1809,37 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, goto out; } + notify = !(cpufreq_driver->flags &CPUFREQ_ASYNC_NOTIFICATION ); + +if (notify) { + freqs.old = policy->cur; + freqs.new = freq_table[index].frequency; + freqs.flags =0 ; + +pr_debug ("%s: cpu: %d, oldfreq: %u, new freq: %u\n" , + __func__, policy->cpu, freqs.old, + freqs.new); + +cpufreq_notify_transition (policy, &freqs, +CPUFREQ_PRECHANGE ); + } + retval = cpufreq_driver->target_index (policy, index); +if (retval) +pr_err ("%s: Failed to change cpu frequency: %d\n" , + __func__, retval); + +if (notify) { +/* +* Notify with old freq in case we failed to change +* frequency +*/ +if (retval) + freqs.new = freqs.old; + +cpufreq_notify_transition (policy, &freqs, +CPUFREQ_POSTCHANGE ); + } } out:
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 182/228 cpufreq: acpi: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/acpi-cpufreq.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +2 -12
@@ -428,14 +428,10 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy, {struct acpi_cpufreq_data *data =per_cpu (acfreq_data, policy->cpu);struct acpi_processor_performance *perf; -struct cpufreq_freqs freqs;struct drv_cmd cmd;unsigned int next_perf_state =0 ;/* Index into perf table */ int result =0 ; -pr_debug ("acpi_cpufreq_target %d (%d)\n" , - data->freq_table[index].frequency, policy->cpu); -if (unlikely (data ==NULL || data->acpi_data ==NULL || data->freq_table ==NULL )) {return -ENODEV ;
@@ -483,23 +479,17 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,else cmd.mask =cpumask_of (policy->cpu); - freqs.old = perf->states[perf->state].core_frequency *1000 ; - freqs.new = data->freq_table[index].frequency; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -drv_write (&cmd);if (acpi_pstate_strict) { -if (!check_freqs (cmd.mask, freqs.new, data)) { +if (!check_freqs (cmd.mask, data->freq_table[index].frequency, + data)) {pr_debug ("acpi_cpufreq_target failed (%d)\n" , policy->cpu); result = -EAGAIN ; - freqs.new = freqs.old; } } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -if (!result) perf->state = next_perf_state;
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 183/228 cpufreq: arm_big_little: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/arm_big_little.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-)
drivers/cpufreq/arm_big_little.c +3 -22
@@ -51,30 +51,11 @@ static unsigned int bL_cpufreq_get(unsigned int cpu)static int bL_cpufreq_set_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs; -u32 cpu = policy->cpu, cur_cluster; -int ret =0 ; +u32 cur_cluster; cur_cluster =cpu_to_cluster (policy->cpu); - - freqs.old =bL_cpufreq_get (policy->cpu); - freqs.new = freq_table[cur_cluster][index].frequency; - -pr_debug ("%s: cpu: %d, cluster: %d, oldfreq: %d, target freq: %d, new freq: %d\n" , - __func__, cpu, cur_cluster, freqs.old, freqs.new, - freqs.new); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - - ret =clk_set_rate (clk[cur_cluster], freqs.new *1000 ); -if (ret) { -pr_err ("clk_set_rate failed: %d\n" , ret); - freqs.new = freqs.old; - } - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -return ret; +return clk_set_rate (clk[cur_cluster], + freq_table[cur_cluster][index].frequency *1000 ); }static void put_cluster_clk_and_freq_table (struct device *cpu_dev)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 184/228 cpufreq: at32ap: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/at32ap-cpufreq.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-)
drivers/cpufreq/at32ap-cpufreq.c +9 -13
@@ -37,27 +37,23 @@ static unsigned long loops_per_jiffy_ref;static int at32_set_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs; +unsigned int old_freq, new_freq; - freqs.old =at32_get_speed (0 ); - freqs.new = freq_table[index].frequency; + old_freq =at32_get_speed (0 ); + new_freq = freq_table[index].frequency;if (!ref_freq) { - ref_freq = freqs.old; + ref_freq = old_freq; loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -if (freqs.old < freqs.new) +if (old_freq < new_freq) boot_cpu_data.loops_per_jiffy =cpufreq_scale ( - loops_per_jiffy_ref, ref_freq, freqs.new); -clk_set_rate (cpuclk, freqs.new *1000 ); -if (freqs.new < freqs.old) + loops_per_jiffy_ref, ref_freq, new_freq); +clk_set_rate (cpuclk, new_freq *1000 ); +if (new_freq < old_freq) boot_cpu_data.loops_per_jiffy =cpufreq_scale ( - loops_per_jiffy_ref, ref_freq, freqs.new); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -pr_debug ("cpufreq: set frequency %u Hz\n" , freqs.new *1000 ); + loops_per_jiffy_ref, ref_freq, new_freq);return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 185/228 cpufreq: blackfin: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/blackfin-cpufreq.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
drivers/cpufreq/blackfin-cpufreq.c +7 -15
@@ -132,27 +132,23 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index)#ifndef CONFIG_BF60xunsigned int plldiv;#endif -struct cpufreq_freqs freqs;static unsigned long lpj_ref;static unsigned int lpj_ref_freq; +unsigned int old_freq, new_freq;int ret =0 ;#if defined(CONFIG_CYCLES_CLOCKSOURCE )cycles_t cycles;#endif - freqs.old =bfin_getfreq_khz (0 ); - freqs.new = bfin_freq_table[index].frequency; + old_freq =bfin_getfreq_khz (0 ); + new_freq = bfin_freq_table[index].frequency; -pr_debug ("cpufreq: changing cclk to %lu; target = %u, oldfreq = %u\n" , - freqs.new, freqs.new, freqs.old); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );#ifndef CONFIG_BF60x plldiv = (bfin_read_PLL_DIV () &SSEL ) | dpm_state_table[index].csel;bfin_write_PLL_DIV (plldiv);#else - ret =cpu_set_cclk (policy->cpu, freqs.new *1000 ); + ret =cpu_set_cclk (policy->cpu, new_freq *1000 );if (ret !=0 ) {WARN_ONCE (ret,"cpufreq set freq failed %d\n" , ret);return ret;
@@ -168,17 +164,13 @@ static int bfin_target(struct cpufreq_policy *policy, unsigned int index)#endif if (!lpj_ref_freq) { lpj_ref = loops_per_jiffy; - lpj_ref_freq = freqs.old; + lpj_ref_freq = old_freq; } -if (freqs.new != freqs.old) { +if (new_freq != old_freq) { loops_per_jiffy =cpufreq_scale (lpj_ref, - lpj_ref_freq, freqs.new); + lpj_ref_freq, new_freq); } -/* TODO: just test case for cycles clock source, remove later */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -pr_debug ("cpufreq: done\n" );return ret; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 186/228 cpufreq: cpu0: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/cpufreq-cpu0.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-)
drivers/cpufreq/cpufreq-cpu0.c +12 -21
@@ -36,20 +36,19 @@ static unsigned int cpu0_get_speed(unsigned int cpu)static int cpu0_set_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs;struct opp *opp;unsigned long volt =0 , volt_old =0 , tol =0 ; +unsigned int old_freq, new_freq;long freq_Hz, freq_exact;int ret; freq_Hz =clk_round_rate (cpu_clk, freq_table[index].frequency *1000 );if (freq_Hz <0 ) freq_Hz = freq_table[index].frequency *1000 ; - freq_exact = freq_Hz; - freqs.new = freq_Hz /1000 ; - freqs.old =clk_get_rate (cpu_clk) /1000 ; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); + freq_exact = freq_Hz; + new_freq = freq_Hz /1000 ; + old_freq =clk_get_rate (cpu_clk) /1000 ;if (!IS_ERR (cpu_reg)) {rcu_read_lock ();
@@ -57,9 +56,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)if (IS_ERR (opp)) {rcu_read_unlock ();pr_err ("failed to find OPP for %ld\n" , freq_Hz); - freqs.new = freqs.old; - ret =PTR_ERR (opp); - goto post_notify; +return PTR_ERR (opp); } volt =opp_get_voltage (opp);rcu_read_unlock ();
@@ -68,16 +65,15 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index) }pr_debug ("%u MHz, %ld mV --> %u MHz, %ld mV\n" , - freqs.old /1000 , volt_old ? volt_old /1000 :-1 , - freqs.new /1000 , volt ? volt /1000 :-1 ); + old_freq /1000 , volt_old ? volt_old /1000 :-1 , + new_freq /1000 , volt ? volt /1000 :-1 );/* scaling up? scale voltage before frequency */ -if (!IS_ERR (cpu_reg) && freqs.new > freqs.old) { +if (!IS_ERR (cpu_reg) && new_freq > old_freq) { ret =regulator_set_voltage_tol (cpu_reg, volt, tol);if (ret) {pr_err ("failed to scale voltage up: %d\n" , ret); - freqs.new = freqs.old; - goto post_notify; +return ret; } }
@@ -86,23 +82,18 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)pr_err ("failed to set clock rate: %d\n" , ret);if (!IS_ERR (cpu_reg))regulator_set_voltage_tol (cpu_reg, volt_old, tol); - freqs.new = freqs.old; - goto post_notify; +return ret; }/* scaling down? scale voltage after frequency */ -if (!IS_ERR (cpu_reg) && freqs.new < freqs.old) { +if (!IS_ERR (cpu_reg) && new_freq < old_freq) { ret =regulator_set_voltage_tol (cpu_reg, volt, tol);if (ret) {pr_err ("failed to scale voltage down: %d\n" , ret); -clk_set_rate (cpu_clk, freqs.old *1000 ); - freqs.new = freqs.old; +clk_set_rate (cpu_clk, old_freq *1000 ); } } -post_notify: -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return ret; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 187/228 cpufreq: cris: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/cris-artpec3-cpufreq.c | 8 -------- drivers/cpufreq/cris-etraxfs-cpufreq.c | 8 -------- 2 files changed, 16 deletions(-)
drivers/cpufreq/cris-artpec3-cpufreq.c +0 -8
@@ -29,15 +29,9 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)static int cris_freq_target (struct cpufreq_policy *policy,unsigned int state) { -struct cpufreq_freqs freqs;reg_clkgen_rw_clk_ctrl clk_ctrl; clk_ctrl =REG_RD (clkgen, regi_clkgen, rw_clk_ctrl); - freqs.old =cris_freq_get_cpu_frequency (policy->cpu); - freqs.new = cris_freq_table[state].frequency; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -local_irq_disable ();/* Even though we may be SMP they will share the same clock
@@ -50,8 +44,6 @@ static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state)local_irq_enable (); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }
drivers/cpufreq/cris-etraxfs-cpufreq.c +0 -8
@@ -29,15 +29,9 @@ static unsigned int cris_freq_get_cpu_frequency(unsigned int cpu)static int cris_freq_target (struct cpufreq_policy *policy,unsigned int state) { -struct cpufreq_freqs freqs;reg_config_rw_clk_ctrl clk_ctrl; clk_ctrl =REG_RD (config, regi_config, rw_clk_ctrl); - freqs.old =cris_freq_get_cpu_frequency (policy->cpu); - freqs.new = cris_freq_table[state].frequency; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -local_irq_disable ();/* Even though we may be SMP they will share the same clock
@@ -50,8 +44,6 @@ static int cris_freq_target(struct cpufreq_policy *policy, unsigned int state)local_irq_enable (); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 187/228] cpufreq: cris: remove calls to cpufreq_notify_transition()
Quoted 12 lines · Viresh Kumar
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
Quoted 7 lines
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
Quoted 3 lines
Cc Mikael Starvik <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]
Viresh Kumar
maintainerPATCH 188/228 cpufreq: davinci: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/davinci-cpufreq.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/cpufreq/davinci-cpufreq.c +10 -20
@@ -68,46 +68,36 @@ static unsigned int davinci_getspeed(unsigned int cpu)static int davinci_target (struct cpufreq_policy *policy,unsigned int idx) { -int ret =0 ; -struct cpufreq_freqs freqs;struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data;struct clk *armclk = cpufreq.armclk; +unsigned int old_freq, new_freq; +int ret =0 ; - freqs.old =davinci_getspeed (0 ); - freqs.new = pdata->freq_table[idx].frequency; - -dev_dbg (cpufreq.dev,"transition: %u --> %u\n" , freqs.old, freqs.new); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); + old_freq =davinci_getspeed (0 ); + new_freq = pdata->freq_table[idx].frequency;/* if moving to higher frequency, up the voltage beforehand */ -if (pdata->set_voltage && freqs.new > freqs.old) { +if (pdata->set_voltage && new_freq > old_freq) { ret = pdata->set_voltage (idx);if (ret) - goto out; +return ret; } ret =clk_set_rate (armclk, idx);if (ret) - goto out; +return ret;if (cpufreq.asyncclk) { ret =clk_set_rate (cpufreq.asyncclk, cpufreq.asyncrate);if (ret) - goto out; +return ret; }/* if moving to lower freq, lower the voltage after lowering freq */ -if (pdata->set_voltage && freqs.new < freqs.old) +if (pdata->set_voltage && new_freq < old_freq) pdata->set_voltage (idx); -out: -if (ret) - freqs.new = freqs.old; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -return ret; +return 0 ; }static int davinci_cpu_init (struct cpufreq_policy *policy)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 189/228 cpufreq: dbx500: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/dbx500-cpufreq.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
drivers/cpufreq/dbx500-cpufreq.c +1 -21
@@ -22,28 +22,8 @@ static struct clk *armss_clk;static int dbx500_cpufreq_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs; -int ret; - - freqs.old = policy->cur; - freqs.new = freq_table[index].frequency; - -/* pre-change notification */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -/* update armss clk frequency */ - ret =clk_set_rate (armss_clk, freqs.new *1000 ); - -if (ret) { -pr_err ("dbx500-cpufreq: Failed to set armss_clk to %d Hz: error %d\n" , - freqs.new *1000 , ret); - freqs.new = freqs.old; - } - -/* post change notification */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -return ret; +return clk_set_rate (armss_clk, freq_table[index].frequency *1000 ); }static unsigned int dbx500_cpufreq_getspeed (unsigned int cpu)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 189/228] cpufreq: dbx500: remove calls to cpufreq_notify_transition()
Quoted 15 lines · Viresh Kumar
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Quoted 7 lines
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
Cc Linus Walleij <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
Yours,
Linus Walleij
Viresh Kumar
maintainerPATCH 190/228 cpufreq: e_powersaver: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/e_powersaver.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-)
drivers/cpufreq/e_powersaver.c +3 -20
@@ -107,15 +107,9 @@ static int eps_set_state(struct eps_cpu_data *centaur, struct cpufreq_policy *policy, u32 dest_state) { -struct cpufreq_freqs freqs;u32 lo, hi; -int err =0 ;int i; - freqs.old =eps_get (policy->cpu); - freqs.new = centaur->fsb * ((dest_state >>8 ) &0xff ); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -/* Wait while CPU is busy */ rdmsr (MSR_IA32_PERF_STATUS , lo, hi); i =0 ;
@@ -124,8 +118,7 @@ static int eps_set_state(struct eps_cpu_data *centaur,rdmsr (MSR_IA32_PERF_STATUS , lo, hi); i++;if (unlikely (i >64 )) { - err = -ENODEV ; - goto postchange; +return -ENODEV ; } }/* Set new multiplier and voltage */
@@ -137,16 +130,10 @@ static int eps_set_state(struct eps_cpu_data *centaur,rdmsr (MSR_IA32_PERF_STATUS , lo, hi); i++;if (unlikely (i >64 )) { - err = -ENODEV ; - goto postchange; +return -ENODEV ; } }while (lo & ((1 <<16 ) | (1 <<17 ))); -/* Return current frequency */ -postchange: -rdmsr (MSR_IA32_PERF_STATUS , lo, hi); - freqs.new = centaur->fsb * ((lo >>8 ) &0xff ); -#ifdef DEBUG {u8 current_multiplier, current_voltage;
@@ -161,11 +148,7 @@ postchange: current_multiplier); }#endif -if (err) - freqs.new = freqs.old; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return err; +return 0 ; }static int eps_target (struct cpufreq_policy *policy,unsigned int index)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 191/228 cpufreq: elanfreq: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/elanfreq.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/cpufreq/elanfreq.c +0 -13
@@ -108,17 +108,6 @@ static unsigned int elanfreq_get_cpu_frequency(unsigned int cpu)static int elanfreq_target (struct cpufreq_policy *policy,unsigned int state) { -struct cpufreq_freqs freqs; - - freqs.old =elanfreq_get_cpu_frequency (0 ); - freqs.new = elan_multiplier[state].clock; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - -printk (KERN_INFO "elanfreq: attempting to set frequency to %i kHz\n" , - elan_multiplier[state].clock); - -/* * Access to the Elan's internal registers is indexed via * 0x22: Chip Setup & Control Register Index Register (CSCI)
@@ -149,8 +138,6 @@ static int elanfreq_target(struct cpufreq_policy *policy,udelay (10000 );local_irq_enable (); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }/*
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 192/228 cpufreq: exynos: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/exynos-cpufreq.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +8 -20
@@ -25,7 +25,6 @@static struct exynos_dvfs_info *exynos_info;static struct regulator *arm_regulator; -static struct cpufreq_freqs freqs;static unsigned int locking_frequency;static bool frequency_locked;
@@ -59,18 +58,18 @@ static int exynos_cpufreq_scale(unsigned int target_freq)struct cpufreq_policy *policy =cpufreq_cpu_get (0 );unsigned int arm_volt, safe_arm_volt =0 ;unsigned int mpll_freq_khz = exynos_info->mpll_freq_khz; +unsigned int old_freq;int index, old_index;int ret =0 ; - freqs.old = policy->cur; - freqs.new = target_freq; + old_freq = policy->cur;/* * The policy max have been changed so that we cannot get proper * old_index with cpufreq_frequency_table_target(). Thus, ignore * policy and get the index from the raw freqeuncy table. */ - old_index =exynos_cpufreq_get_index (freqs.old); + old_index =exynos_cpufreq_get_index (old_freq);if (old_index <0 ) { ret = old_index; goto out;
@@ -95,17 +94,14 @@ static int exynos_cpufreq_scale(unsigned int target_freq) } arm_volt = volt_table[index]; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -/* When the new frequency is higher than current frequency */ -if ((freqs.new > freqs.old) && !safe_arm_volt) { +if ((target_freq > old_freq) && !safe_arm_volt) {/* Firstly, voltage up to increase frequency */ ret =regulator_set_voltage (arm_regulator, arm_volt, arm_volt);if (ret) {pr_err ("%s: failed to set cpu voltage to %d\n" , __func__, arm_volt); - freqs.new = freqs.old; - goto post_notify; +return ret; } }
@@ -115,22 +111,15 @@ static int exynos_cpufreq_scale(unsigned int target_freq)if (ret) {pr_err ("%s: failed to set cpu voltage to %d\n" , __func__, safe_arm_volt); - freqs.new = freqs.old; - goto post_notify; +return ret; } } exynos_info->set_freq (old_index, index); -post_notify: -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -if (ret) - goto out; -/* When the new frequency is lower than current frequency */ -if ((freqs.new < freqs.old) || - ((freqs.new > freqs.old) && safe_arm_volt)) { +if ((target_freq < old_freq) || + ((target_freq > old_freq) && safe_arm_volt)) {/* down the voltage after frequency change */ regulator_set_voltage (arm_regulator, arm_volt, arm_volt);
@@ -142,7 +131,6 @@ post_notify: } out: -cpufreq_cpu_put (policy);return ret;
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 193/228 cpufreq: ia64-acpi: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/ia64-acpi-cpufreq.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/cpufreq/ia64-acpi-cpufreq.c +0 -19
@@ -141,7 +141,6 @@ processor_set_freq ( {int ret =0 ;u32 value =0 ; -struct cpufreq_freqs cpufreq_freqs;cpumask_t saved_mask;int retval;
@@ -168,13 +167,6 @@ processor_set_freq (pr_debug ("Transitioning from P%d to P%d\n" , data->acpi_data.state, state); -/* cpufreq frequency struct */ - cpufreq_freqs.old = data->freq_table[data->acpi_data.state].frequency; - cpufreq_freqs.new = data->freq_table[state].frequency; - -/* notify cpufreq */ -cpufreq_notify_transition (policy, &cpufreq_freqs,CPUFREQ_PRECHANGE ); -/* * First we write the target state's 'control' value to the * control_register.
@@ -186,22 +178,11 @@ processor_set_freq ( ret =processor_set_pstate (value);if (ret) { -unsigned int tmp = cpufreq_freqs.new; -cpufreq_notify_transition (policy, &cpufreq_freqs, -CPUFREQ_POSTCHANGE ); - cpufreq_freqs.new = cpufreq_freqs.old; - cpufreq_freqs.old = tmp; -cpufreq_notify_transition (policy, &cpufreq_freqs, -CPUFREQ_PRECHANGE ); -cpufreq_notify_transition (policy, &cpufreq_freqs, -CPUFREQ_POSTCHANGE );printk (KERN_WARNING "Transition failed with error %d\n" , ret); retval = -ENODEV ; goto migrate_end; } -cpufreq_notify_transition (policy, &cpufreq_freqs,CPUFREQ_POSTCHANGE ); - data->acpi_data.state = state; retval =0 ;
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 194/228 cpufreq: imx6q: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/imx6q-cpufreq.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-)
drivers/cpufreq/imx6q-cpufreq.c +15 -22
@@ -41,14 +41,14 @@ static unsigned int imx6q_get_speed(unsigned int cpu)static int imx6q_set_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs;struct opp *opp;unsigned long freq_hz, volt, volt_old; +unsigned int old_freq, new_freq;int ret; - freqs.new = freq_table[index].frequency; - freq_hz = freqs.new *1000 ; - freqs.old =clk_get_rate (arm_clk) /1000 ; + new_freq = freq_table[index].frequency; + freq_hz = new_freq *1000 ; + old_freq =clk_get_rate (arm_clk) /1000 ;rcu_read_lock (); opp =opp_find_freq_ceil (cpu_dev, &freq_hz);
@@ -63,26 +63,23 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) volt_old =regulator_get_voltage (arm_reg);dev_dbg (cpu_dev,"%u MHz, %ld mV --> %u MHz, %ld mV\n" , - freqs.old /1000 , volt_old /1000 , - freqs.new /1000 , volt /1000 ); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); + old_freq /1000 , volt_old /1000 , + new_freq /1000 , volt /1000 );/* scaling up? scale voltage before frequency */ -if (freqs.new > freqs.old) { +if (new_freq > old_freq) { ret =regulator_set_voltage_tol (arm_reg, volt,0 );if (ret) {dev_err (cpu_dev,"failed to scale vddarm up: %d\n" , ret); - freqs.new = freqs.old; - goto post_notify; +return ret; }/* * Need to increase vddpu and vddsoc for safety * if we are about to run at 1.2 GHz. */ -if (freqs.new ==FREQ_1P2_GHZ /1000 ) { +if (new_freq ==FREQ_1P2_GHZ /1000 ) {regulator_set_voltage_tol (pu_reg,PU_SOC_VOLTAGE_HIGH ,0 ); regulator_set_voltage_tol(soc_reg,
@@ -102,21 +99,20 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)clk_set_parent (step_clk, pll2_pfd2_396m_clk);clk_set_parent (pll1_sw_clk, step_clk);if (freq_hz >clk_get_rate (pll2_pfd2_396m_clk)) { -clk_set_rate (pll1_sys_clk, freqs.new *1000 ); +clk_set_rate (pll1_sys_clk, new_freq *1000 );clk_set_parent (pll1_sw_clk, pll1_sys_clk); }/* Ensure the arm clock divider is what we expect */ - ret =clk_set_rate (arm_clk, freqs.new *1000 ); + ret =clk_set_rate (arm_clk, new_freq *1000 );if (ret) {dev_err (cpu_dev,"failed to set clock rate: %d\n" , ret);regulator_set_voltage_tol (arm_reg, volt_old,0 ); - freqs.new = freqs.old; - goto post_notify; +return ret; }/* scaling down? scale voltage after frequency */ -if (freqs.new < freqs.old) { +if (new_freq < old_freq) { ret =regulator_set_voltage_tol (arm_reg, volt,0 );if (ret) { dev_warn(cpu_dev,
@@ -124,7 +120,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) ret =0 ; } -if (freqs.old ==FREQ_1P2_GHZ /1000 ) { +if (old_freq ==FREQ_1P2_GHZ /1000 ) {regulator_set_voltage_tol (pu_reg,PU_SOC_VOLTAGE_NORMAL ,0 ); regulator_set_voltage_tol(soc_reg,
@@ -132,10 +128,7 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) } } -post_notify: -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -return ret; +return 0 ; }static int imx6q_cpufreq_init (struct cpufreq_policy *policy)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 195/228 cpufreq: kirkwood: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/kirkwood-cpufreq.c | 54 ++++++++++++++------------------------ 1 file changed, 20 insertions(+), 34 deletions(-)
drivers/cpufreq/kirkwood-cpufreq.c +20 -34
@@ -58,48 +58,34 @@ static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu)static int kirkwood_cpufreq_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs;unsigned int state = kirkwood_freq_table[index].driver_data;unsigned long reg; - freqs.old =kirkwood_cpufreq_get_cpu_frequency (0 ); - freqs.new = kirkwood_freq_table[index].frequency; +local_irq_disable (); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); +/* Disable interrupts to the CPU */ + reg =readl_relaxed (priv.base); + reg |=CPU_SW_INT_BLK ; +writel_relaxed (reg, priv.base); -dev_dbg (priv.dev,"Attempting to set frequency to %i KHz\n" , - kirkwood_freq_table[index].frequency); -dev_dbg (priv.dev,"old frequency was %i KHz\n" , -kirkwood_cpufreq_get_cpu_frequency (0 )); - -if (freqs.old != freqs.new) { -local_irq_disable (); - -/* Disable interrupts to the CPU */ - reg =readl_relaxed (priv.base); - reg |=CPU_SW_INT_BLK ; -writel_relaxed (reg, priv.base); - -switch (state) { -case STATE_CPU_FREQ : -clk_disable (priv.powersave_clk); -break ; -case STATE_DDR_FREQ : -clk_enable (priv.powersave_clk); -break ; - } +switch (state) { +case STATE_CPU_FREQ : +clk_disable (priv.powersave_clk); +break ; +case STATE_DDR_FREQ : +clk_enable (priv.powersave_clk); +break ; + } -/* Wait-for-Interrupt, while the hardware changes frequency */ -cpu_do_idle (); +/* Wait-for-Interrupt, while the hardware changes frequency */ +cpu_do_idle (); -/* Enable interrupts to the CPU */ - reg =readl_relaxed (priv.base); - reg &= ~CPU_SW_INT_BLK ; -writel_relaxed (reg, priv.base); +/* Enable interrupts to the CPU */ + reg =readl_relaxed (priv.base); + reg &= ~CPU_SW_INT_BLK ; +writel_relaxed (reg, priv.base); -local_irq_enable (); - } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); +local_irq_enable ();return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 195/228] cpufreq: kirkwood: remove calls to cpufreq_notify_transition()
Quoted 6 lines · Viresh Kumar
drivers/cpufreq/kirkwood-cpufreq.c +0
-6-if (freqs.old != freqs.new) { -local_irq_disable (); - -/* Disable interrupts to the CPU */ - reg =readl_relaxed (priv.base); - reg |=CPU_SW_INT_BLK ;
drivers/cpufreq/kirkwood-cpufreq.c static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu) · line 90
Quoted 10 lines
drivers/cpufreq/kirkwood-cpufreq.c +0
-10-writel_relaxed (reg, priv.base); - -switch (state) { -case STATE_CPU_FREQ : -clk_disable (priv.powersave_clk); -break ; -case STATE_DDR_FREQ : -clk_enable (priv.powersave_clk); -break ; - }
Hi Viresh
I see you removed the test that the old and the new frequency are different. Is this guaranteed by the core? Because if not, you can lockup the CPU. The call to cpu_do_idle() will never return.
Thanks
Andrew
Viresh Kumar
maintainerRe: [PATCH 195/228] cpufreq: kirkwood: remove calls to cpufreq_notify_transition()
Quoted 21 lines · Andrew Lunn
Quoted 6 lines · Viresh Kumar
drivers/cpufreq/kirkwood-cpufreq.c +0
-6-if (freqs.old != freqs.new) { -local_irq_disable (); - -/* Disable interrupts to the CPU */ - reg =readl_relaxed (priv.base); - reg |=CPU_SW_INT_BLK ;drivers/cpufreq/kirkwood-cpufreq.c static unsigned int kirkwood_cpufreq_get_cpu_frequency(unsigned int cpu) · line 90
Quoted 10 lines
drivers/cpufreq/kirkwood-cpufreq.c +0
-10-writel_relaxed (reg, priv.base); - -switch (state) { -case STATE_CPU_FREQ : -clk_disable (priv.powersave_clk); -break ; -case STATE_DDR_FREQ : -clk_enable (priv.powersave_clk); -break ; - }Hi Viresh
Quoted 3 lines
I see you removed the test that the old and the new frequency are different. Is this guaranteed by the core? Because if not, you can lockup the CPU. The call to
cpu_do_idle()will never return.
Yes, that's guaranteed by core: patch 181..
Viresh Kumar
maintainerPATCH 196/228 cpufreq: loongson2: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/loongson2_cpufreq.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +0 -16
@@ -57,7 +57,6 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, {unsigned int cpu = policy->cpu;cpumask_t cpus_allowed; -struct cpufreq_freqs freqs;unsigned int freq; cpus_allowed = current->cpus_allowed;
@@ -67,26 +66,11 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy, ((cpu_clock_freq /1000 ) * loongson2_clockmod_table[index].driver_data) /8 ; -pr_debug ("cpufreq: requested frequency %u Hz\n" , - loongson2_clockmod_table[index].frequency *1000 ); - - freqs.old =loongson2_cpufreq_get (cpu); - freqs.new = freq; - freqs.flags =0 ; - -/* notifiers */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -set_cpus_allowed_ptr (current, &cpus_allowed);/* setting the cpu frequency */ clk_set_rate (cpuclk, freq); -/* notifiers */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -pr_debug ("cpufreq: set frequency %u kHz\n" , freq); -return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 197/228 cpufreq: maple: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/maple-cpufreq.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/cpufreq/maple-cpufreq.c +1 -17
@@ -69,8 +69,6 @@ static struct cpufreq_frequency_table maple_cpu_freqs[] = {*/ static int maple_pmode_cur; -static DEFINE_MUTEX (maple_switch_mutex); -static const u32 *maple_pmode_data;static int maple_pmode_max;
@@ -133,21 +131,7 @@ static int maple_scom_query_freq(void)static int maple_cpufreq_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs; -int rc; - -mutex_lock (&maple_switch_mutex); - - freqs.old = maple_cpu_freqs[maple_pmode_cur].frequency; - freqs.new = maple_cpu_freqs[index].frequency; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - rc =maple_scom_switch_freq (index); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -mutex_unlock (&maple_switch_mutex); - -return rc; +return maple_scom_switch_freq (index); }static unsigned int maple_cpufreq_get_speed (unsigned int cpu)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 198/228 cpufreq: omap: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/omap-cpufreq.c | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-)
drivers/cpufreq/omap-cpufreq.c +14 -25
@@ -53,15 +53,15 @@ static unsigned int omap_getspeed(unsigned int cpu)static int omap_target (struct cpufreq_policy *policy,unsigned int index) { -int r, ret =0 ; -struct cpufreq_freqs freqs; +int r, ret;struct opp *opp;unsigned long freq, volt =0 , volt_old =0 , tol =0 ; +unsigned int old_freq, new_freq; - freqs.old =omap_getspeed (policy->cpu); - freqs.new = freq_table[index].frequency; + old_freq =omap_getspeed (policy->cpu); + new_freq = freq_table[index].frequency; - freq = freqs.new *1000 ; + freq = new_freq *1000 ; ret =clk_round_rate (mpu_clk, freq);if (IS_ERR_VALUE (ret)) { dev_warn(mpu_dev,
@@ -77,7 +77,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)if (IS_ERR (opp)) {rcu_read_unlock ();dev_err (mpu_dev,"%s: unable to find MPU OPP for %d\n" , - __func__, freqs.new); + __func__, new_freq);return -EINVAL ; } volt =opp_get_voltage (opp);
@@ -87,43 +87,32 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) }dev_dbg (mpu_dev,"cpufreq-omap: %u MHz, %ld mV --> %u MHz, %ld mV\n" , - freqs.old /1000 , volt_old ? volt_old /1000 :-1 , - freqs.new /1000 , volt ? volt /1000 :-1 ); - -/* notifiers */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); + old_freq /1000 , volt_old ? volt_old /1000 :-1 , + new_freq /1000 , volt ? volt /1000 :-1 );/* scaling up? scale voltage before frequency */ -if (mpu_reg && (freqs.new > freqs.old)) { +if (mpu_reg && (new_freq > old_freq)) { r =regulator_set_voltage (mpu_reg, volt - tol, volt + tol);if (r <0 ) {dev_warn (mpu_dev,"%s: unable to scale voltage up.\n" , __func__); - freqs.new = freqs.old; - goto done; +return r; } } - ret =clk_set_rate (mpu_clk, freqs.new *1000 ); + ret =clk_set_rate (mpu_clk, new_freq *1000 );/* scaling down? scale voltage after frequency */ -if (mpu_reg && (freqs.new < freqs.old)) { +if (mpu_reg && (new_freq < old_freq)) { r =regulator_set_voltage (mpu_reg, volt - tol, volt + tol);if (r <0 ) {dev_warn (mpu_dev,"%s: unable to scale voltage down.\n" , __func__); - ret =clk_set_rate (mpu_clk, freqs.old *1000 ); - freqs.new = freqs.old; - goto done; +clk_set_rate (mpu_clk, old_freq *1000 ); +return r; } } - freqs.new =omap_getspeed (policy->cpu); - -done: -/* notifiers */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return ret; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 199/228 cpufreq: p4-clockmod: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/p4-clockmod.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/cpufreq/p4-clockmod.c +0 -10
@@ -107,15 +107,8 @@ static struct cpufreq_frequency_table p4clockmod_table[] = {static int cpufreq_p4_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs;int i; - freqs.old =cpufreq_p4_get (policy->cpu); - freqs.new = stock_freq * p4clockmod_table[index].driver_data /8 ; - -/* notifiers */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -/* run on each logical CPU, * see section 13.15.3 of IA32 Intel Architecture Software * Developer's Manual, Volume 3
@@ -123,9 +116,6 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy, unsigned int index)for_each_cpu (i, policy->cpus)cpufreq_p4_setdc (i, p4clockmod_table[index].driver_data); -/* notifiers */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 200/228 cpufreq: pasemi: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/pasemi-cpufreq.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/cpufreq/pasemi-cpufreq.c +1 -13
@@ -51,8 +51,6 @@static void __iomem *sdcpwr_mapbase;static void __iomem *sdcasr_mapbase; -static DEFINE_MUTEX (pas_switch_mutex); -/* Current astate, is used when waking up from power savings on * one core, in case the other core has switched states during * the idle time.
@@ -242,15 +240,8 @@ static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)static int pas_cpufreq_target (struct cpufreq_policy *policy,unsigned int pas_astate_new) { -struct cpufreq_freqs freqs;int i; - freqs.old = policy->cur; - freqs.new = pas_freqs[pas_astate_new].frequency; - -mutex_lock (&pas_switch_mutex); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", policy->cpu, pas_freqs[pas_astate_new].frequency,
@@ -261,10 +252,7 @@ static int pas_cpufreq_target(struct cpufreq_policy *policy,for_each_online_cpu (i)set_astate (i, pas_astate_new); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -mutex_unlock (&pas_switch_mutex); - - ppc_proc_freq = freqs.new *1000ul ; + ppc_proc_freq = pas_freqs[pas_astate_new].frequency *1000ul ;return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 201/228 cpufreq: pmac: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/pmac32-cpufreq.c | 20 ++++---------------- drivers/cpufreq/pmac64-cpufreq.c | 18 +----------------- 2 files changed, 5 insertions(+), 33 deletions(-)
drivers/cpufreq/pmac32-cpufreq.c +4 -16
@@ -331,21 +331,11 @@ static int pmu_set_cpu_speed(int low_speed)return 0 ; } -static int do_set_cpu_speed (struct cpufreq_policy *policy,int speed_mode, -int notify) +static int do_set_cpu_speed (struct cpufreq_policy *policy,int speed_mode) { -struct cpufreq_freqs freqs;unsigned long l3cr;static unsigned long prev_l3cr; - freqs.old = cur_freq; - freqs.new = (speed_mode ==CPUFREQ_HIGH ) ? hi_freq : low_freq; - -if (freqs.old == freqs.new) -return 0 ; - -if (notify) -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );if (speed_mode ==CPUFREQ_LOW &&cpu_has_feature (CPU_FTR_L3CR )) { l3cr =_get_L3CR ();
@@ -361,8 +351,6 @@ static int do_set_cpu_speed(struct cpufreq_policy *policy, int speed_mode,if ((prev_l3cr &L3CR_L3E ) && l3cr != prev_l3cr)_set_L3CR (prev_l3cr); } -if (notify) -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); cur_freq = (speed_mode ==CPUFREQ_HIGH ) ? hi_freq : low_freq;return 0 ;
@@ -378,7 +366,7 @@ static int pmac_cpufreq_target( struct cpufreq_policy *policy, {int rc; - rc =do_set_cpu_speed (policy, index,1 ); + rc =do_set_cpu_speed (policy, index); ppc_proc_freq = cur_freq *1000ul ;return rc;
@@ -420,7 +408,7 @@ static int pmac_cpufreq_suspend(struct cpufreq_policy *policy) no_schedule =1 ; sleep_freq = cur_freq;if (cur_freq == low_freq && !is_pmu_based) -do_set_cpu_speed (policy,CPUFREQ_HIGH ,0 ); +do_set_cpu_speed (policy,CPUFREQ_HIGH );return 0 ; }
@@ -437,7 +425,7 @@ static int pmac_cpufreq_resume(struct cpufreq_policy *policy)* probably high speed due to our suspend() routine */ do_set_cpu_speed (policy, sleep_freq == low_freq ? -CPUFREQ_LOW :CPUFREQ_HIGH ,0 ); +CPUFREQ_LOW :CPUFREQ_HIGH ); ppc_proc_freq = cur_freq *1000ul ;
drivers/cpufreq/pmac64-cpufreq.c +1 -17
@@ -79,8 +79,6 @@ static void (*g5_switch_volt)(int speed_mode);static int (*g5_switch_freq)(int speed_mode);static int (*g5_query_freq)(void ); -static DEFINE_MUTEX (g5_switch_mutex); -static unsigned long transition_latency;#ifdef CONFIG_PMAC_SMU
@@ -314,21 +312,7 @@ static int g5_pfunc_query_freq(void)static int g5_cpufreq_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs; -int rc; - -mutex_lock (&g5_switch_mutex); - - freqs.old = g5_cpu_freqs[g5_pmode_cur].frequency; - freqs.new = g5_cpu_freqs[index].frequency; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - rc =g5_switch_freq (index); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -mutex_unlock (&g5_switch_mutex); - -return rc; +return g5_switch_freq (index); }static unsigned int g5_cpufreq_get_speed (unsigned int cpu)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 202/228 cpufreq: ppc: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/ppc-corenet-cpufreq.c | 19 +------------------ drivers/cpufreq/ppc_cbe_cpufreq.c | 19 +------------------ 2 files changed, 2 insertions(+), 36 deletions(-)
drivers/cpufreq/ppc-corenet-cpufreq.c +1 -18
@@ -69,8 +69,6 @@ static const struct soc_data sdata[] = {static u32 min_cpufreq;static const u32 *fmask; -/* serialize frequency changes */ -static DEFINE_MUTEX (cpufreq_lock); static DEFINE_PER_CPU(struct cpu_data *, cpu_data);/* cpumask in a cluster */
@@ -253,26 +251,11 @@ static int __exit corenet_cpufreq_cpu_exit(struct cpufreq_policy *policy)static int corenet_cpufreq_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs;struct clk *parent; -int ret;struct cpu_data *data =per_cpu (cpu_data, policy->cpu); - freqs.old = policy->cur; - freqs.new = data->table[index].frequency; - -mutex_lock (&cpufreq_lock); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - parent =of_clk_get (data->parent, data->table[index].driver_data); - ret =clk_set_parent (data->clk, parent); -if (ret) - freqs.new = freqs.old; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -mutex_unlock (&cpufreq_lock); - -return ret; +return clk_set_parent (data->clk, parent); }static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
drivers/cpufreq/ppc_cbe_cpufreq.c +1 -18
@@ -30,9 +30,6 @@#include "ppc_cbe_cpufreq.h" -static DEFINE_MUTEX (cbe_switch_mutex); - -/* the CBE supports an 8 step frequency scaling */ static struct cpufreq_frequency_table cbe_freqs[] = { {1 ,0 },
@@ -131,27 +128,13 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)static int cbe_cpufreq_target (struct cpufreq_policy *policy,unsigned int cbe_pmode_new) { -int rc; -struct cpufreq_freqs freqs; - - freqs.old = policy->cur; - freqs.new = cbe_freqs[cbe_pmode_new].frequency; - -mutex_lock (&cbe_switch_mutex); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -pr_debug ("setting frequency for cpu %d to %d kHz, " \"1/%d of max frequency\n" , policy->cpu, cbe_freqs[cbe_pmode_new].frequency, cbe_freqs[cbe_pmode_new].driver_data); - rc =set_pmode (policy->cpu, cbe_pmode_new); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -mutex_unlock (&cbe_switch_mutex); - -return rc; +return set_pmode (policy->cpu, cbe_pmode_new); }static struct cpufreq_driver cbe_cpufreq_driver = {
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 203/228 cpufreq: pxa: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/pxa2xx-cpufreq.c | 27 ++++++--------------------- drivers/cpufreq/pxa3xx-cpufreq.c | 12 ------------ 2 files changed, 6 insertions(+), 33 deletions(-)
drivers/cpufreq/pxa2xx-cpufreq.c +6 -21
@@ -271,7 +271,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx) {struct cpufreq_frequency_table *pxa_freqs_table;pxa_freqs_t *pxa_freq_settings; -struct cpufreq_freqs freqs;unsigned long flags;unsigned int new_freq_cpu, new_freq_mem;unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
@@ -282,24 +281,17 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx) new_freq_cpu = pxa_freq_settings[idx].khz; new_freq_mem = pxa_freq_settings[idx].membus; - freqs.old = policy->cur; - freqs.new = new_freq_cpu;if (freq_debug)pr_debug ("Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n" , - freqs.new /1000 , (pxa_freq_settings[idx].div2) ? + new_freq_cpu /1000 , (pxa_freq_settings[idx].div2) ? (new_freq_mem /2000 ) : (new_freq_mem /1000 )); -if (vcc_core && freqs.new > freqs.old) +if (vcc_core && new_freq_cpu > policy->cur) { ret =pxa_cpufreq_change_voltage (&pxa_freq_settings[idx]); -if (ret) -return ret; -/* -* Tell everyone what we're about to do... -* you should add a notify client with any platform specific -* Vcc changing capability -*/ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); +if (ret) +return ret; + }/* Calculate the next MDREFR. If we're slowing down the SDRAM clock * we need to preset the smaller DRI before the change. If we're
@@ -350,13 +342,6 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)local_irq_restore (flags);/* -* Tell everyone what we've just done... -* you should add a notify client with any platform specific -* SDRAM refresh timer adjustments -*/ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -/* * Even if voltage setting fails, we don't report it, as the frequency * change succeeded. The voltage reduction is not a critical failure, * only power savings will suffer from this.
@@ -365,7 +350,7 @@ static int pxa_set_target(struct cpufreq_policy *policy, unsigned int idx)* bug is triggered (seems a deadlock). Should anybody find out where, * the "return 0" should become a "return ret". */ -if (vcc_core && freqs.new < freqs.old) +if (vcc_core && new_freq_cpu < policy->cur) ret =pxa_cpufreq_change_voltage (&pxa_freq_settings[idx]);return 0 ;
drivers/cpufreq/pxa3xx-cpufreq.c +0 -12
@@ -158,7 +158,6 @@ static unsigned int pxa3xx_cpufreq_get(unsigned int cpu)static int pxa3xx_cpufreq_set (struct cpufreq_policy *policy,unsigned int index) {struct pxa3xx_freq_info *next; -struct cpufreq_freqs freqs;unsigned long flags;if (policy->cpu !=0 )
@@ -166,22 +165,11 @@ static int pxa3xx_cpufreq_set(struct cpufreq_policy *policy, unsigned int index) next = &pxa3xx_freqs[index]; - freqs.old = policy->cur; - freqs.new = next->cpufreq_mhz *1000 ; - -pr_debug ("CPU frequency from %d MHz to %d MHz%s\n" , - freqs.old /1000 , freqs.new /1000 , - (freqs.old == freqs.new) ?" (skipped)" :"" ); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -local_irq_save (flags);__update_core_freq (next);__update_bus_freq (next);local_irq_restore (flags); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 204/228 cpufreq: s3c: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/s3c2416-cpufreq.c | 21 ++++------------- drivers/cpufreq/s3c64xx-cpufreq.c | 48 +++++++++++++-------------------------- 2 files changed, 20 insertions(+), 49 deletions(-)
drivers/cpufreq/s3c2416-cpufreq.c +4 -17
@@ -220,7 +220,7 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) {struct s3c2416_data *s3c_freq = &s3c2416_cpufreq; -struct cpufreq_freqs freqs; +unsigned int new_freq;int idx, ret, to_dvs =0 ;mutex_lock (&cpufreq_lock);
@@ -237,25 +237,14 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy, goto out; } - freqs.flags =0 ; - freqs.old = s3c_freq->is_dvs ?FREQ_DVS - :clk_get_rate (s3c_freq->armclk) /1000 ; -/* When leavin dvs mode, always switch the armdiv to the hclk rate * The S3C2416 has stability issues when switching directly to * higher frequencies. */ - freqs.new = (s3c_freq->is_dvs && !to_dvs) + new_freq = (s3c_freq->is_dvs && !to_dvs) ?clk_get_rate (s3c_freq->hclk) /1000 : s3c_freq->freq_table[index].frequency; -pr_debug ("cpufreq: Transition %d-%dkHz\n" , freqs.old, freqs.new); - -if (!to_dvs && freqs.old == freqs.new) - goto out; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -if (to_dvs) {pr_debug ("cpufreq: enter dvs\n" ); ret =s3c2416_cpufreq_enter_dvs (s3c_freq, idx);
@@ -263,12 +252,10 @@ static int s3c2416_cpufreq_set_target(struct cpufreq_policy *policy,pr_debug ("cpufreq: leave dvs\n" ); ret =s3c2416_cpufreq_leave_dvs (s3c_freq, idx); }else { -pr_debug ("cpufreq: change armdiv to %dkHz\n" , freqs.new); - ret =s3c2416_cpufreq_set_armdiv (s3c_freq, freqs.new); +pr_debug ("cpufreq: change armdiv to %dkHz\n" , new_freq); + ret =s3c2416_cpufreq_set_armdiv (s3c_freq, new_freq); } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - out:mutex_unlock (&cpufreq_lock);
drivers/cpufreq/s3c64xx-cpufreq.c +16 -32
84 lines not on this page · raw message
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 205/228 cpufreq: s5pv210: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/s5pv210-cpufreq.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/cpufreq/s5pv210-cpufreq.c +6 -10
@@ -26,7 +26,6 @@static struct clk *cpu_clk;static struct clk *dmc0_clk;static struct clk *dmc1_clk; -static struct cpufreq_freqs freqs;static DEFINE_MUTEX (set_freq_lock);/* APLL M,P,S values for 1G/800Mhz */
@@ -179,6 +178,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index)unsigned int priv_index;unsigned int pll_changing =0 ;unsigned int bus_speed_changing =0 ; +unsigned int old_freq, new_freq;int arm_volt, int_volt;int ret =0 ;
@@ -193,12 +193,12 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) goto exit; } - freqs.old =s5pv210_getspeed (0 ); - freqs.new = s5pv210_freq_table[index].frequency; + old_freq =s5pv210_getspeed (0 ); + new_freq = s5pv210_freq_table[index].frequency;/* Finding current running level index */ if (cpufreq_frequency_table_target (policy, s5pv210_freq_table, - freqs.old,CPUFREQ_RELATION_H , + old_freq,CPUFREQ_RELATION_H , &priv_index)) { ret = -EINVAL ; goto exit;
@@ -207,7 +207,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) arm_volt = dvs_conf[index].arm_volt; int_volt = dvs_conf[index].int_volt; -if (freqs.new > freqs.old) { +if (new_freq > old_freq) { ret =regulator_set_voltage (arm_regulator, arm_volt, arm_volt_max);if (ret)
@@ -219,8 +219,6 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) goto exit; } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -/* Check if there need to change PLL */ if ((index ==L0 ) || (priv_index ==L0 )) pll_changing =1 ;
@@ -431,9 +429,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) } } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); - -if (freqs.new < freqs.old) { +if (new_freq < old_freq) {regulator_set_voltage (int_regulator, int_volt, int_volt_max);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 206/228 cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/sa1100-cpufreq.c | 17 ++++++----------- drivers/cpufreq/sa1110-cpufreq.c | 12 ++---------- 2 files changed, 8 insertions(+), 21 deletions(-)
drivers/cpufreq/sa1100-cpufreq.c +6 -11
@@ -180,22 +180,17 @@ static void sa1100_update_dram_timings(int current_speed, int new_speed)static int sa1100_target (struct cpufreq_policy *policy,unsigned int ppcr) {unsigned int cur =sa11x0_getspeed (0 ); -struct cpufreq_freqs freqs; +unsigned int new_freq; - freqs.old = cur; - freqs.new = sa11x0_freq_table[ppcr].frequency; + new_freq = sa11x0_freq_table[ppcr].frequency; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - -if (freqs.new > cur) -sa1100_update_dram_timings (cur, freqs.new); +if (new_freq > cur) +sa1100_update_dram_timings (cur, new_freq);PPCR = ppcr; -if (freqs.new < cur) -sa1100_update_dram_timings (cur, freqs.new); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); +if (new_freq < cur) +sa1100_update_dram_timings (cur, new_freq);return 0 ; }
drivers/cpufreq/sa1110-cpufreq.c +2 -10
@@ -232,15 +232,11 @@ sdram_update_refresh(u_int cpu_khz, struct sdram_params *sdram)static int sa1110_target (struct cpufreq_policy *policy,unsigned int ppcr) {struct sdram_params *sdram = &sdram_params; -struct cpufreq_freqs freqs;struct sdram_info sd;unsigned long flags;unsigned int unused; - freqs.old =sa11x0_getspeed (0 ); - freqs.new = sa11x0_freq_table[ppcr].frequency; - -sdram_calculate_timing (&sd, freqs.new, sdram); +sdram_calculate_timing (&sd, sa11x0_freq_table[ppcr].frequency, sdram);#if 0 /*
@@ -259,8 +255,6 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr) sd.mdcas[2 ] =0xaaaaaaaa ;#endif -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -/* * The clock could be going away for some time. Set the SDRAMs * to refresh rapidly (every 64 memory clock cycles). To get
@@ -305,9 +299,7 @@ static int sa1110_target(struct cpufreq_policy *policy, unsigned int ppcr)/* * Now, return the SDRAM refresh back to normal. */ -sdram_update_refresh (freqs.new, sdram); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); +sdram_update_refresh (sa11x0_freq_table[ppcr].frequency, sdram);return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
Quoted 15 lines · Viresh Kumar
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Quoted 7 lines
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
Cc Russell King <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
Shouldn't this patch set CPUFREQ_ASYNC_NOTIFICATION somewhere?
Viresh Kumar
maintainerRe: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
Quoted 19 lines · Russell King - ARM Linux
Quoted 18 lines · Viresh Kumar
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Quoted 6 lines
Quoted 4 lines
Some related minor cleanups are also done along with it.
Cc Russell King <[email protected]>Signed-off-by Viresh Kumar <[email protected]>Shouldn't this patch set
CPUFREQ_ASYNC_NOTIFICATIONsomewhere?
As far as I can see, sa11x0 completes frequency transition from within target() and so it does it synchronously.. And so it doesn't need to set CPUFREQ_ASYNC_NOTIFICATION...
Am I missing something?
Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
Quoted 26 lines · Viresh Kumar
Quoted 24 lines · Russell King - ARM Linux
Quoted 22 lines · Viresh Kumar
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
Cc Russell King <[email protected]>Signed-off-by Viresh Kumar <[email protected]>
Quoted 7 lines
Quoted 1 line
Shouldn't this patch set
CPUFREQ_ASYNC_NOTIFICATIONsomewhere?As far as I can see, sa11x0 completes frequency transition from within
target()and so it does it synchronously.. And so it doesn't need to setCPUFREQ_ASYNC_NOTIFICATION...Am I missing something?
The patch to which I'm replying removes the above calls. These calls are necessary to shutdown various bits of CPU-clock dependent hardware before changing the CPU clock, and restore them - reconfiguring them for the new clock rate after the transition has happened.
So, if you're removing these calls, what replaces them? I don't see anything which does without the above set.
Viresh Kumar
maintainerRe: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
Quoted 7 lines · Russell King - ARM Linux
The patch to which I'm replying removes the above calls. These calls are necessary to shutdown various bits of CPU-clock dependent hardware before changing the CPU clock, and restore them - reconfiguring them for the new clock rate after the transition has happened.
So, if you're removing these calls, what replaces them? I don't see anything which does without the above set.
The other patch on which you commented about unnecessary read locks being taken:
[PATCH 181/228] cpufreq: move freq change notifications to cpufreq
That calls these notifiers, for all platforms except the ones that have set CPUFREQ_ASYNC_NOTIFICATION, before and after calling ->target_index()..
And so functionally the code is supposed to be the same.. Unless I have done some stupid mistake..
Re: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
Quoted 13 lines · Viresh Kumar
Quoted 7 lines · Russell King - ARM Linux
The patch to which I'm replying removes the above calls. These calls are necessary to shutdown various bits of CPU-clock dependent hardware before changing the CPU clock, and restore them - reconfiguring them for the new clock rate after the transition has happened.
So, if you're removing these calls, what replaces them? I don't see anything which does without the above set.
The other patch on which you commented about unnecessary read locks being taken:
Quoted 8 lines
[PATCH 181/228] cpufreq: move freq change notifications to cpufreq
That calls these notifiers, for all platforms except the ones that have set
CPUFREQ_ASYNC_NOTIFICATION, before and after calling ->target_index()..And so functionally the code is supposed to be the same.. Unless I have done some stupid mistake..
Ah, sorry, read that that test the other way around. In that case, this patch is fine and can have my ack as per the other acks I've already given.
Thanks.
Viresh Kumar
maintainerRe: [PATCH 206/228] cpufreq: sa11x0: remove calls to cpufreq_notify_transition()
Quoted 3 lines · Russell King - ARM Linux
Ah, sorry, read that that test the other way around. In that case, this patch is fine and can have my ack as per the other acks I've already given.
Thanks :)
Viresh Kumar
maintainerPATCH 207/228 cpufreq: sc520: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/sc520_freq.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/cpufreq/sc520_freq.c +0 -11
@@ -56,17 +56,8 @@ static unsigned int sc520_freq_get_cpu_frequency(unsigned int cpu)static int sc520_freq_target (struct cpufreq_policy *policy,unsigned int state) { -struct cpufreq_freqs freqs;u8 clockspeed_reg; - freqs.old =sc520_freq_get_cpu_frequency (0 ); - freqs.new = sc520_freq_table[state].frequency; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - -pr_debug ("attempting to set frequency to %i kHz\n" , - sc520_freq_table[state].frequency); -local_irq_disable (); clockspeed_reg = *cpuctl & ~0x03 ;
@@ -74,8 +65,6 @@ static int sc520_freq_target(struct cpufreq_policy *policy, unsigned int state)local_irq_enable (); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 208/228 cpufreq: sparc: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/sparc-us2e-cpufreq.c | 7 ------- drivers/cpufreq/sparc-us3-cpufreq.c | 7 ------- 2 files changed, 14 deletions(-)
drivers/cpufreq/sparc-us2e-cpufreq.c +0 -7
@@ -251,7 +251,6 @@ static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index)unsigned long new_bits, new_freq;unsigned long clock_tick, divisor, old_divisor, estar;cpumask_t cpus_allowed; -struct cpufreq_freqs freqs;cpumask_copy (&cpus_allowed,tsk_cpus_allowed (current));set_cpus_allowed_ptr (current,cpumask_of (cpu));
@@ -265,16 +264,10 @@ static int us2e_freq_target(struct cpufreq_policy *policy, unsigned int index) old_divisor =estar_to_divisor (estar); - freqs.old = clock_tick / old_divisor; - freqs.new = new_freq; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -if (old_divisor != divisor)us2e_transition (estar, new_bits, clock_tick *1000 , old_divisor, divisor); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -set_cpus_allowed_ptr (current, &cpus_allowed);return 0 ;
drivers/cpufreq/sparc-us3-cpufreq.c +0 -7
@@ -98,7 +98,6 @@ static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index)unsigned int cpu = policy->cpu;unsigned long new_bits, new_freq, reg;cpumask_t cpus_allowed; -struct cpufreq_freqs freqs;cpumask_copy (&cpus_allowed,tsk_cpus_allowed (current));set_cpus_allowed_ptr (current,cpumask_of (cpu));
@@ -124,16 +123,10 @@ static int us3_freq_target(struct cpufreq_policy *policy, unsigned int index) reg =read_safari_cfg (); - freqs.old =get_current_freq (cpu, reg); - freqs.new = new_freq; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - reg &= ~SAFARI_CFG_DIV_MASK ; reg |= new_bits;write_safari_cfg (reg); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -set_cpus_allowed_ptr (current, &cpus_allowed);return 0 ;
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 209/228 cpufreq: SPEAr: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/spear-cpufreq.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/cpufreq/spear-cpufreq.c +1 -12
@@ -107,12 +107,10 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq)static int spear_cpufreq_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs;unsigned long newfreq;struct clk *srcclk;int ret, mult =1 ; - freqs.old =spear_cpufreq_get (0 ); newfreq = spear_cpufreq.freq_tbl[index].frequency *1000 ;if (of_machine_is_compatible ("st,spear1340" )) {
@@ -145,23 +143,14 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,return newfreq; } - freqs.new = newfreq /1000 ; - freqs.new /= mult; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -if (mult ==2 ) ret =spear1340_set_cpu_rate (srcclk, newfreq);else ret =clk_set_rate (spear_cpufreq.clk, newfreq); -/* Get current rate after clk_set_rate, in case of failure */ -if (ret) { +if (ret)pr_err ("CPU Freq: cpu clk_set_rate failed: %d\n" , ret); - freqs.new =clk_get_rate (spear_cpufreq.clk) /1000 ; - } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );return ret; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 210/228 cpufreq: speedstep: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/speedstep-centrino.c | 20 +------------------- drivers/cpufreq/speedstep-ich.c | 9 --------- drivers/cpufreq/speedstep-smi.c | 7 ------- 3 files changed, 1 insertion(+), 35 deletions(-)
drivers/cpufreq/speedstep-centrino.c +1 -19
@@ -424,9 +424,8 @@ static int centrino_cpu_exit(struct cpufreq_policy *policy)static int centrino_target (struct cpufreq_policy *policy,unsigned int index) {unsigned int msr, oldmsr =0 , h =0 , cpu = policy->cpu; -struct cpufreq_freqs freqs;int retval =0 ; -unsigned int j, first_cpu, tmp; +unsigned int j, first_cpu;struct cpufreq_frequency_table *op_points;cpumask_var_t covered_cpus;
@@ -474,15 +473,6 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index) goto out; } - freqs.old =extract_clock (oldmsr, cpu,0 ); - freqs.new =extract_clock (msr, cpu,0 ); - -pr_debug ("target=%dkHz old=%d new=%d msr=%04x\n" , - op_points->frequency, freqs.old, freqs.new, msr); - -cpufreq_notify_transition (policy, &freqs, -CPUFREQ_PRECHANGE ); - first_cpu =0 ;/* all but 16 LSB are reserved, treat them with care */ oldmsr &= ~0xffff ;
@@ -497,8 +487,6 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)cpumask_set_cpu (j, covered_cpus); } -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -if (unlikely (retval)) {/* * We have failed halfway through the frequency change.
@@ -509,12 +497,6 @@ static int centrino_target(struct cpufreq_policy *policy, unsigned int index)for_each_cpu (j, covered_cpus)wrmsr_on_cpu (j,MSR_IA32_PERF_CTL , oldmsr, h); - - tmp = freqs.new; - freqs.new = freqs.old; - freqs.old = tmp; -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); } retval =0 ;
drivers/cpufreq/speedstep-ich.c +0 -9
@@ -258,21 +258,12 @@ static unsigned int speedstep_get(unsigned int cpu)static int speedstep_target (struct cpufreq_policy *policy,unsigned int index) {unsigned int policy_cpu; -struct cpufreq_freqs freqs; policy_cpu =cpumask_any_and (policy->cpus, cpu_online_mask); - freqs.old =speedstep_get (policy_cpu); - freqs.new = speedstep_freqs[index].frequency; - -pr_debug ("transiting from %u to %u kHz\n" , freqs.old, freqs.new); - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );smp_call_function_single (policy_cpu, _speedstep_set_state, &index, true); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); -return 0 ; }
drivers/cpufreq/speedstep-smi.c +0 -7
@@ -241,14 +241,7 @@ static void speedstep_set_state(unsigned int state)*/ static int speedstep_target (struct cpufreq_policy *policy,unsigned int index) { -struct cpufreq_freqs freqs; - - freqs.old = speedstep_freqs[speedstep_get_state ()].frequency; - freqs.new = speedstep_freqs[index].frequency; - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );speedstep_set_state (index); -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );return 0 ; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 211/228 cpufreq: tegra: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarMost of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);
This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
--- drivers/cpufreq/tegra-cpufreq.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
drivers/cpufreq/tegra-cpufreq.c +5 -20
@@ -102,12 +102,8 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy, unsigned long rate) {int ret =0 ; -struct cpufreq_freqs freqs; - freqs.old =tegra_getspeed (0 ); - freqs.new = rate; - -if (freqs.old == freqs.new) +if (tegra_getspeed (0 ) == rate)return ret;/*
@@ -121,21 +117,10 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,else clk_set_rate (emc_clk,100000000 );/* emc 50Mhz */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); - -#ifdef CONFIG_CPU_FREQ_DEBUG -printk (KERN_DEBUG "cpufreq-tegra: transition: %u --> %u\n" , - freqs.old, freqs.new); -#endif - - ret =tegra_cpu_clk_set_rate (freqs.new *1000 ); -if (ret) { -pr_err ("cpu-tegra: Failed to set cpu frequency to %d kHz\n" , - freqs.new); - freqs.new = freqs.old; - } - -cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE ); + ret =tegra_cpu_clk_set_rate (rate *1000 ); +if (ret) +pr_err ("cpu-tegra: Failed to set cpu frequency to %lu kHz\n" , + rate);return ret; }
Signature · 1 line
1.7.12.rc2.18.g61b472e
Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()
Quoted 27 lines · Viresh Kumar
Most of the drivers do following in their ->target_index() routines:
struct cpufreq_freqs freqs; freqs.old = old freq... freqs.new = new freq... cpufreq_notify_transition(policy, &freqs, CPUFREQ_PRECHANGE); /* Change rate here */ cpufreq_notify_transition(policy, &freqs, CPUFREQ_POSTCHANGE);This is replicated over all cpufreq drivers today and there doesn't exists a good enough reason why this shouldn't be moved to cpufreq core instead.
Earlier patches have added support in cpufreq core to do cpufreq notification on frequency change, this one removes it from this driver.
Some related minor cleanups are also done along with it.
drivers/cpufreq/tegra-cpufreq.c +0
-1@@ -121,21 +117,10 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,else clk_set_rate (emc_clk,100000000 );/* emc 50Mhz */ -cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );
...
drivers/cpufreq/tegra-cpufreq.c static int tegra_update_cpu_speed(struct cpufreq_policy *policy, · line 138
Quoted 1 line
drivers/cpufreq/tegra-cpufreq.c +0
-1-cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );
I wonder if this series is bisectable? Perhaps I should just go and read the rest of the series, but I presume there's a patch somewhere else that adds those two cpufreq_notify_transition() to the cpufreq core. Either that happens before this patch (in which case listeners will get two notifications each time; perhaps that is safe?), or after this patch (in which case with just this patch applied, no notifications will be sent until a later patch!
Aside from that, all the Tegra-specific patches in this series,
Viresh Kumar
maintainerRe: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()
Quoted 7 lines · Stephen Warren
I wonder if this series is bisectable? Perhaps I should just go and read the rest of the series, but I presume there's a patch somewhere else that adds those two
cpufreq_notify_transition()to the cpufreq core. Either that happens before this patch (in which case listeners will get two notifications each time; perhaps that is safe?), or after this patch (in which case with just this patch applied, no notifications will be sent until a later patch!
Hmm.. Good Catch..
So, yes git bisect would be compilable but not runnable.. As we are already serialized notifications and so two PRE notifications will generate a crash..
But I don't want to get all that in a single patch as that would be:
40 files changed, 192 insertions(+), 623 deletions(-)
And that would be hard to review it..
Any suggestions?
Quoted 2 lines
Aside from that, all the Tegra-specific patches in this series,
Acked-by Stephen Warren <[email protected]>
Thanks..
Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()
Quoted 15 lines · Viresh Kumar
Quoted 7 lines · Stephen Warren
I wonder if this series is bisectable? Perhaps I should just go and read the rest of the series, but I presume there's a patch somewhere else that adds those two
cpufreq_notify_transition()to the cpufreq core. Either that happens before this patch (in which case listeners will get two notifications each time; perhaps that is safe?), or after this patch (in which case with just this patch applied, no notifications will be sent until a later patch!Hmm.. Good Catch..
So, yes git bisect would be compilable but not runnable.. As we are already serialized notifications and so two PRE notifications will generate a crash..
Quoted 8 lines
But I don't want to get all that in a single patch as that would be:
40 files changed, 192 insertions(+), 623 deletions(-)And that would be hard to review it..
Any suggestions?
It reminds me time of removing CONFIG_HOTPLUG and following __dev* attributes. At least stats for 48c68c4 "Drivers: video: remove __dev* attributes" is:
135 files changed, 1017 insertions(+), 1129 deletions(-)
Maybe coccinelle script, which maintainers could run it on their trees, would help?
Vladimir
Quoted 9 lines
Quoted 2 lines
Aside from that, all the Tegra-specific patches in this series,
Acked-by Stephen Warren <[email protected]>Thanks..
_______________________________________________
linaro-kernel mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/linaro-kernel
Re: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()
In reply to Viresh KumarQuoted 15 lines · Viresh Kumar
Quoted 7 lines · Stephen Warren
I wonder if this series is bisectable? Perhaps I should just go and read the rest of the series, but I presume there's a patch somewhere else that adds those two
cpufreq_notify_transition()to the cpufreq core. Either that happens before this patch (in which case listeners will get two notifications each time; perhaps that is safe?), or after this patch (in which case with just this patch applied, no notifications will be sent until a later patch!Hmm.. Good Catch..
So, yes git bisect would be compilable but not runnable.. As we are already serialized notifications and so two PRE notifications will generate a crash..
Quoted 7 lines
But I don't want to get all that in a single patch as that would be:
40 files changed, 192 insertions(+), 623 deletions(-)And that would be hard to review it..
Any suggestions?
Well, I guess you can assume that everyone has a chance to review the series by now and send it as one patch in the next iteration.
A patch that adds 192 lines of code isn't shockingly large by any measure.
Thanks,
Rafael
Viresh Kumar
maintainerRe: [PATCH 211/228] cpufreq: tegra: remove calls to cpufreq_notify_transition()
Quoted 2 lines · Rafael J. Wysocki
Well, I guess you can assume that everyone has a chance to review the series by now and send it as one patch in the next iteration.
Yeah, that's what I thought..
Quoted 1 line
A patch that adds 192 lines of code isn't shockingly large by any measure.
It was more about removal of things and the number of files it touches.. But yes, its good for review to send them separately but in the end they can be merged..
Viresh Kumar
maintainerPATCH 212/228 cpufreq: tegra: remove target_cpu_speed[] array
In reply to Viresh KumarTegra's cpufreq driver was maintaining requested target frequencies in an array:target_cpu_speed. And then finally setting the highest requested freq in the core. This was probably done because both cores share clock line and logically we want to set both cores to the max frequency requested..
But this wasn't required to be done in individual CPUFreq drivers, its already taken care of by CPUFreq governors. They evaluate load for all CPUs and finally call target only for the frequency corresponding to max load.
So, get rid of this stuff from Tegra's cpufreq driver.
--- drivers/cpufreq/tegra-cpufreq.c | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-)
drivers/cpufreq/tegra-cpufreq.c +6 -30
@@ -47,7 +47,6 @@ static struct clk *pll_x_clk;static struct clk *pll_p_clk;static struct clk *emc_clk; -static unsigned long target_cpu_speed[NUM_CPUS ];static DEFINE_MUTEX (tegra_cpu_lock);static bool is_suspended;
@@ -103,9 +102,6 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy, {int ret =0 ; -if (tegra_getspeed (0 ) == rate) -return ret; -/* * Vote on memory bus frequency based on cpu frequency * This sets the minimum frequency, display or avp may request higher
@@ -125,35 +121,16 @@ static int tegra_update_cpu_speed(struct cpufreq_policy *policy,return ret; } -static unsigned long tegra_cpu_highest_speed (void ) -{ -unsigned long rate =0 ; -int i; - -for_each_online_cpu (i) - rate =max (rate, target_cpu_speed[i]); -return rate; -} -static int tegra_target (struct cpufreq_policy *policy,unsigned int index) { -unsigned int freq; -int ret =0 ; +int ret = -EBUSY ;mutex_lock (&tegra_cpu_lock); -if (is_suspended) { - ret = -EBUSY ; - goto out; - } - - freq = freq_table[index].frequency; - - target_cpu_speed[policy->cpu] = freq; +if (!is_suspended) + ret =tegra_update_cpu_speed (policy, + freq_table[index].frequency); - ret =tegra_update_cpu_speed (policy,tegra_cpu_highest_speed ()); - -out:mutex_unlock (&tegra_cpu_lock);return ret; }
@@ -167,7 +144,8 @@ static int tegra_pm_notify(struct notifier_block *nb, unsigned long event, is_suspended = true;pr_info ("Tegra cpufreq suspend: setting frequency to %d kHz\n" , freq_table[0 ].frequency); -tegra_update_cpu_speed (policy, freq_table[0 ].frequency); +if (tegra_getspeed (0 ) != freq_table[0 ].frequency) +tegra_update_cpu_speed (policy, freq_table[0 ].frequency);cpufreq_cpu_put (policy); }else if (event ==PM_POST_SUSPEND ) { is_suspended = false;
@@ -191,8 +169,6 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)clk_prepare_enable (emc_clk);clk_prepare_enable (cpu_clk); - target_cpu_speed[policy->cpu] =tegra_getspeed (policy->cpu); -/* FIXME: what's the actual transition time? */ ret =cpufreq_generic_init (policy, freq_table,300 *1000 );if (ret) {
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 213/228 cpufreq: create cpufreq_generic_get() routine
In reply to Viresh KumarCPUFreq drivers that use clock frameworks interface,i.e. clk_get_rate(), to get CPUs clk rate, has similar sort of code used for most of them.
This patch adds a generic ->get() which will do the same thing for them. All those drivers are required to now is to set .get to cpufreq_generic_get() and set their clk pointer in policy->clk during ->init().
--- drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++++++------ include/linux/cpufreq.h | 3 +++ 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/cpufreq/cpufreq.c +20 -6
@@ -219,6 +219,20 @@ int cpufreq_generic_init(struct cpufreq_policy *policy, }EXPORT_SYMBOL_GPL (cpufreq_generic_init); +unsigned int cpufreq_generic_get (unsigned int cpu) +{ +struct cpufreq_policy *policy =per_cpu (cpufreq_cpu_data, cpu); + +if (!policy ||IS_ERR (policy->clk)) { +pr_err ("%s: No %s associated to cpu: %d\n" , __func__, + policy ?"clk" :"policy" , cpu); +return 0 ; + } + +return clk_get_rate (policy->clk) /1000 ; +} +EXPORT_SYMBOL_GPL (cpufreq_generic_get); +struct cpufreq_policy *cpufreq_cpu_get (unsigned int cpu) {struct cpufreq_policy *policy =NULL ;
@@ -1115,6 +1129,11 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, goto err_set_policy_cpu; } +write_lock_irqsave (&cpufreq_driver_lock, flags); +for_each_cpu (j, policy->cpus) +per_cpu (cpufreq_cpu_data, j) = policy; +write_unlock_irqrestore (&cpufreq_driver_lock, flags); +if (cpufreq_driver->get) { policy->cur = cpufreq_driver->get (policy->cpu);if (!policy->cur) {
@@ -1147,11 +1166,6 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif, }#endif -write_lock_irqsave (&cpufreq_driver_lock, flags); -for_each_cpu (j, policy->cpus) -per_cpu (cpufreq_cpu_data, j) = policy; -write_unlock_irqrestore (&cpufreq_driver_lock, flags); -if (!frozen) { ret =cpufreq_add_dev_interface (policy, dev);if (ret)
@@ -1172,12 +1186,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,return 0 ; err_out_unregister: +err_get_freq:write_lock_irqsave (&cpufreq_driver_lock, flags);for_each_cpu (j, policy->cpus)per_cpu (cpufreq_cpu_data, j) =NULL ;write_unlock_irqrestore (&cpufreq_driver_lock, flags); -err_get_freq:if (cpufreq_driver->exit) cpufreq_driver->exit (policy); err_set_policy_cpu:
include/linux/cpufreq.h +3 -0
@@ -11,6 +11,7 @@#ifndef _LINUX_CPUFREQ_H#define _LINUX_CPUFREQ_H +#include <linux/clk.h> #include <linux/cpumask.h> #include <linux/completion.h> #include <linux/kobject.h>
@@ -66,6 +67,7 @@ struct cpufreq_policy {unsigned int cpu;/* cpu nr of CPU managing this policy */ unsigned int last_cpu;/* cpu nr of previous CPU that managed * this policy */ +struct clk *clk;struct cpufreq_cpuinfo cpuinfo;/* see above */ unsigned int min;/* in kHz */
@@ -440,6 +442,7 @@ void cpufreq_frequency_table_put_attr(unsigned int cpu);int cpufreq_table_validate_and_show (struct cpufreq_policy *policy,struct cpufreq_frequency_table *table); +unsigned int cpufreq_generic_get (unsigned int cpu);int cpufreq_generic_init (struct cpufreq_policy *policy,struct cpufreq_frequency_table *table,unsigned int transition_latency);
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 214/228 cpufreq: arm_big_little: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/arm_big_little.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/cpufreq/arm_big_little.c +2 -8
@@ -40,13 +40,6 @@ static struct clk *clk[MAX_CLUSTERS];static struct cpufreq_frequency_table *freq_table[MAX_CLUSTERS ];static atomic_t cluster_usage[MAX_CLUSTERS ] = {ATOMIC_INIT (0 ),ATOMIC_INIT (0 )}; -static unsigned int bL_cpufreq_get (unsigned int cpu) -{ -u32 cur_cluster =cpu_to_cluster (cpu); - -return clk_get_rate (clk[cur_cluster]) /1000 ; -} -/* Set clock frequency */ static int bL_cpufreq_set_target (struct cpufreq_policy *policy,unsigned int index)
@@ -145,6 +138,7 @@ static int bL_cpufreq_init(struct cpufreq_policy *policy)else policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ; + policy->clk = clk[cur_cluster];cpumask_copy (policy->cpus,topology_core_cpumask (policy->cpu));dev_info (cpu_dev,"%s: CPU %d initialized\n" , __func__, policy->cpu);
@@ -175,7 +169,7 @@ static struct cpufreq_driver bL_cpufreq_driver = { CPUFREQ_HAVE_GOVERNOR_PER_POLICY, .verify = cpufreq_generic_frequency_table_verify, .target_index = bL_cpufreq_set_target, - .get = bL_cpufreq_get, + .get = cpufreq_generic_get, .init = bL_cpufreq_init, .exit = bL_cpufreq_exit, .attr = cpufreq_generic_attr,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 215/228 cpufreq: at32ap: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/at32ap-cpufreq.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-)
drivers/cpufreq/at32ap-cpufreq.c +5 -12
@@ -21,17 +21,8 @@#include <linux/export.h> #include <linux/slab.h> -static struct clk *cpuclk;static struct cpufreq_frequency_table *freq_table; -static unsigned int at32_get_speed (unsigned int cpu) -{ -/* No SMP support */ -if (cpu) -return 0 ; -return (unsigned int )((clk_get_rate (cpuclk) +500 ) /1000 ); -} -static unsigned int ref_freq;static unsigned long loops_per_jiffy_ref;
@@ -39,7 +30,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index) {unsigned int old_freq, new_freq; - old_freq =at32_get_speed (0 ); + old_freq = policy->cur; new_freq = freq_table[index].frequency;if (!ref_freq) {
@@ -50,7 +41,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)if (old_freq < new_freq) boot_cpu_data.loops_per_jiffy =cpufreq_scale ( loops_per_jiffy_ref, ref_freq, new_freq); -clk_set_rate (cpuclk, new_freq *1000 ); +clk_set_rate (policy->clk, new_freq *1000 );if (new_freq < old_freq) boot_cpu_data.loops_per_jiffy =cpufreq_scale ( loops_per_jiffy_ref, ref_freq, new_freq);
@@ -61,6 +52,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)static int __init at32_cpufreq_driver_init (struct cpufreq_policy *policy) {unsigned int frequency, rate, min_freq; +static struct clk *cpuclk;int retval, steps, i;if (policy->cpu !=0 )
@@ -103,6 +95,7 @@ static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) frequency /=2 ; } + policy->clk = cpuclk; freq_table[steps -1 ].frequency =CPUFREQ_TABLE_END ; retval =cpufreq_table_validate_and_show (policy, freq_table);
@@ -123,7 +116,7 @@ static struct cpufreq_driver at32_driver = { .init = at32_cpufreq_driver_init, .verify = cpufreq_generic_frequency_table_verify, .target_index = at32_set_target, - .get = at32_get_speed, + .get = cpufreq_generic_get, .flags = CPUFREQ_STICKY, };
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 216/228 cpufreq: cpu0: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/cpufreq-cpu0.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/cpufreq/cpufreq-cpu0.c +2 -6
@@ -29,11 +29,6 @@ static struct clk *cpu_clk;static struct regulator *cpu_reg;static struct cpufreq_frequency_table *freq_table; -static unsigned int cpu0_get_speed (unsigned int cpu) -{ -return clk_get_rate (cpu_clk) /1000 ; -} -static int cpu0_set_target (struct cpufreq_policy *policy,unsigned int index) {struct opp *opp;
@@ -99,6 +94,7 @@ static int cpu0_set_target(struct cpufreq_policy *policy, unsigned int index)static int cpu0_cpufreq_init (struct cpufreq_policy *policy) { + policy->clk = cpu_clk;return cpufreq_generic_init (policy, freq_table, transition_latency); }
@@ -106,7 +102,7 @@ static struct cpufreq_driver cpu0_cpufreq_driver = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, .target_index = cpu0_set_target, - .get = cpu0_get_speed, + .get = cpufreq_generic_get, .init = cpu0_cpufreq_init, .exit = cpufreq_generic_exit, .name = "generic_cpu0",
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 217/228 cpufreq: davinci: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/davinci-cpufreq.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/cpufreq/davinci-cpufreq.c +4 -10
@@ -58,14 +58,6 @@ static int davinci_verify_speed(struct cpufreq_policy *policy)return 0 ; } -static unsigned int davinci_getspeed (unsigned int cpu) -{ -if (cpu) -return 0 ; - -return clk_get_rate (cpufreq.armclk) /1000 ; -} -static int davinci_target (struct cpufreq_policy *policy,unsigned int idx) {struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data;
@@ -73,7 +65,7 @@ static int davinci_target(struct cpufreq_policy *policy, unsigned int idx)unsigned int old_freq, new_freq;int ret =0 ; - old_freq =davinci_getspeed (0 ); + old_freq = policy->cur; new_freq = pdata->freq_table[idx].frequency;/* if moving to higher frequency, up the voltage beforehand */
@@ -116,6 +108,8 @@ static int davinci_cpu_init(struct cpufreq_policy *policy)return result; } + policy->clk = cpufreq.armclk; +/* * Time measurement across the target() function yields ~1500-1800us * time taken with no drivers on notification list.
@@ -129,7 +123,7 @@ static struct cpufreq_driver davinci_driver = { .flags = CPUFREQ_STICKY, .verify = davinci_verify_speed, .target_index = davinci_target, - .get = davinci_getspeed, + .get = cpufreq_generic_get, .init = davinci_cpu_init, .exit = cpufreq_generic_exit, .name = "davinci",
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 218/228 cpufreq: dbx500: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We don't have to find closest frequency in platform specific ->get() routine wihch dbx500 driver was doing and hence it can be removed as well.
--- drivers/cpufreq/dbx500-cpufreq.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/cpufreq/dbx500-cpufreq.c +2 -17
@@ -26,24 +26,9 @@ static int dbx500_cpufreq_target(struct cpufreq_policy *policy,return clk_set_rate (armss_clk, freq_table[index].frequency *1000 ); } -static unsigned int dbx500_cpufreq_getspeed (unsigned int cpu) -{ -int i =0 ; -unsigned long freq =clk_get_rate (armss_clk) /1000 ; - -/* The value is rounded to closest frequency in the defined table. */ -while (freq_table[i +1 ].frequency !=CPUFREQ_TABLE_END ) { -if (freq < freq_table[i].frequency + - (freq_table[i +1 ].frequency - freq_table[i].frequency) /2 ) -return freq_table[i].frequency; - i++; - } - -return freq_table[i].frequency; -} -static int dbx500_cpufreq_init (struct cpufreq_policy *policy) { + policy->clk = armss_clk;return cpufreq_generic_init (policy, freq_table,20 *1000 ); }
@@ -51,7 +36,7 @@ static struct cpufreq_driver dbx500_cpufreq_driver = { .flags = CPUFREQ_STICKY | CPUFREQ_CONST_LOOPS, .verify = cpufreq_generic_frequency_table_verify, .target_index = dbx500_cpufreq_target, - .get = dbx500_cpufreq_getspeed, + .get = cpufreq_generic_get, .init = dbx500_cpufreq_init, .name = "DBX500", .attr = cpufreq_generic_attr,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 219/228 cpufreq: exynos: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/exynos-cpufreq.c | 10 +++------- drivers/cpufreq/exynos5440-cpufreq.c | 33 ++++++++++++++------------------- 2 files changed, 17 insertions(+), 26 deletions(-)
drivers/cpufreq/exynos-cpufreq.c +3 -7
@@ -30,11 +30,6 @@ static unsigned int locking_frequency;static bool frequency_locked;static DEFINE_MUTEX (cpufreq_lock); -static unsigned int exynos_getspeed (unsigned int cpu) -{ -return clk_get_rate (exynos_info->cpu_clk) /1000 ; -} -static int exynos_cpufreq_get_index (unsigned int freq) {struct cpufreq_frequency_table *freq_table = exynos_info->freq_table;
@@ -214,6 +209,7 @@ static struct notifier_block exynos_cpufreq_nb = {static int exynos_cpufreq_cpu_init (struct cpufreq_policy *policy) { + policy->clk = exynos_info->cpu_clk;return cpufreq_generic_init (policy, exynos_info->freq_table,100000 ); }
@@ -221,7 +217,7 @@ static struct cpufreq_driver exynos_driver = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, .target_index = exynos_target, - .get = exynos_getspeed, + .get = cpufreq_generic_get, .init = exynos_cpufreq_cpu_init, .exit = cpufreq_generic_exit, .name = "exynos_cpufreq",
@@ -263,7 +259,7 @@ static int __init exynos_cpufreq_init(void) goto err_vdd_arm; } - locking_frequency =exynos_getspeed (0 ); + locking_frequency =clk_get_rate (exynos_info->cpu_clk) /1000 ;register_pm_notifier (&exynos_cpufreq_nb);
drivers/cpufreq/exynos5440-cpufreq.c +14 -19
@@ -100,7 +100,6 @@ struct exynos_dvfs_data {struct resource *mem;int irq;struct clk *cpu_clk; -unsigned int cur_frequency;unsigned int latency;struct cpufreq_frequency_table *freq_table;unsigned int freq_count;
@@ -165,7 +164,7 @@ static int init_div_table(void)return 0 ; } -static void exynos_enable_dvfs (void ) +static void exynos_enable_dvfs (unsigned int cur_frequency) {unsigned int tmp, i, cpu;struct cpufreq_frequency_table *freq_table = dvfs_info->freq_table;
@@ -184,18 +183,18 @@ static void exynos_enable_dvfs(void)/* Set initial performance index */ for (i =0 ; freq_table[i].frequency !=CPUFREQ_TABLE_END ; i++) -if (freq_table[i].frequency == dvfs_info->cur_frequency) +if (freq_table[i].frequency == cur_frequency)break ;if (freq_table[i].frequency ==CPUFREQ_TABLE_END ) {dev_crit (dvfs_info->dev,"Boot up frequency not supported\n" );/* Assign the highest frequency */ i =0 ; - dvfs_info->cur_frequency = freq_table[i].frequency; + cur_frequency = freq_table[i].frequency; }dev_info (dvfs_info->dev,"Setting dvfs initial frequency = %uKHZ" , - dvfs_info->cur_frequency); + cur_frequency);for (cpu =0 ; cpu <CONFIG_NR_CPUS ; cpu++) { tmp =__raw_readl (dvfs_info->base +XMU_C0_3_PSTATE + cpu *4 );
@@ -209,11 +208,6 @@ static void exynos_enable_dvfs(void) dvfs_info->base + XMU_DVFS_CTRL); } -static unsigned int exynos_getspeed (unsigned int cpu) -{ -return dvfs_info->cur_frequency; -} -static int exynos_target (struct cpufreq_policy *policy,unsigned int index) {unsigned int tmp;
@@ -222,7 +216,7 @@ static int exynos_target(struct cpufreq_policy *policy, unsigned int index)mutex_lock (&cpufreq_lock); - freqs.old = dvfs_info->cur_frequency; + freqs.old = policy->cur; freqs.new = freq_table[index].frequency;cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE );
@@ -253,7 +247,7 @@ static void exynos_cpufreq_work(struct work_struct *work) goto skip_work;mutex_lock (&cpufreq_lock); - freqs.old = dvfs_info->cur_frequency; + freqs.old = policy->cur; cur_pstate =__raw_readl (dvfs_info->base +XMU_P_STATUS );if (cur_pstate >>C0_3_PSTATE_VALID_SHIFT &0x1 )
@@ -263,10 +257,9 @@ static void exynos_cpufreq_work(struct work_struct *work)if (likely (index < dvfs_info->freq_count)) { freqs.new = freq_table[index].frequency; - dvfs_info->cur_frequency = freqs.new; }else {dev_crit (dvfs_info->dev,"New frequency out of range\n" ); - freqs.new = dvfs_info->cur_frequency; + freqs.new = freqs.old; }cpufreq_notify_transition (policy, &freqs,CPUFREQ_POSTCHANGE );
@@ -310,6 +303,7 @@ static void exynos_sort_descend_freq_table(void)static int exynos_cpufreq_cpu_init (struct cpufreq_policy *policy) { + policy->clk = dvfs_info->cpu_clk;return cpufreq_generic_init (policy, dvfs_info->freq_table, dvfs_info->latency); }
@@ -318,7 +312,7 @@ static struct cpufreq_driver exynos_driver = { .flags = CPUFREQ_STICKY | CPUFREQ_ASYNC_NOTIFICATION, .verify = cpufreq_generic_frequency_table_verify, .target_index = exynos_target, - .get = exynos_getspeed, + .get = cpufreq_generic_get, .init = exynos_cpufreq_cpu_init, .exit = cpufreq_generic_exit, .name = CPUFREQ_NAME,
@@ -337,6 +331,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev)int ret = -EINVAL ;struct device_node *np;struct resource res; +unsigned int cur_frequency; np = pdev->dev.of_node;if (!np)
@@ -392,13 +387,13 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) goto err_free_table; } - dvfs_info->cur_frequency =clk_get_rate (dvfs_info->cpu_clk); -if (!dvfs_info->cur_frequency) { + cur_frequency =clk_get_rate (dvfs_info->cpu_clk); +if (!cur_frequency) {dev_err (dvfs_info->dev,"Failed to get clock rate\n" ); ret = -EINVAL ; goto err_free_table; } - dvfs_info->cur_frequency /=1000 ; + cur_frequency /=1000 ;INIT_WORK (&dvfs_info->irq_work, exynos_cpufreq_work); ret = devm_request_irq(dvfs_info->dev, dvfs_info->irq,
@@ -415,7 +410,7 @@ static int exynos_cpufreq_probe(struct platform_device *pdev) goto err_free_table; } -exynos_enable_dvfs (); +exynos_enable_dvfs (cur_frequency); ret =cpufreq_register_driver (&exynos_driver);if (ret) { dev_err(dvfs_info->dev,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 220/228 cpufreq: imx6q: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/imx6q-cpufreq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/cpufreq/imx6q-cpufreq.c +2 -6
@@ -34,11 +34,6 @@ static struct device *cpu_dev;static struct cpufreq_frequency_table *freq_table;static unsigned int transition_latency; -static unsigned int imx6q_get_speed (unsigned int cpu) -{ -return clk_get_rate (arm_clk) /1000 ; -} -static int imx6q_set_target (struct cpufreq_policy *policy,unsigned int index) {struct opp *opp;
@@ -133,13 +128,14 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)static int imx6q_cpufreq_init (struct cpufreq_policy *policy) { + policy->clk = arm_clk;return cpufreq_generic_init (policy, freq_table, transition_latency); }static struct cpufreq_driver imx6q_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, .target_index = imx6q_set_target, - .get = imx6q_get_speed, + .get = cpufreq_generic_get, .init = imx6q_cpufreq_init, .exit = cpufreq_generic_exit, .name ="imx6q-cpufreq" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 221/228 cpufreq: loongson2: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We don't need a global variable to hold clock anymore.
--- drivers/cpufreq/loongson2_cpufreq.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/cpufreq/loongson2_cpufreq.c +5 -10
@@ -24,8 +24,6 @@static uint nowait; -static struct clk *cpuclk; -static void (*saved_cpu_wait) (void ); static int loongson2_cpu_freq_notifier(struct notifier_block *nb,
@@ -44,11 +42,6 @@ static int loongson2_cpu_freq_notifier(struct notifier_block *nb,return 0 ; } -static unsigned int loongson2_cpufreq_get (unsigned int cpu) -{ -return clk_get_rate (cpuclk); -} -/* * Here we notify other drivers of the proposed change and the final change. */
@@ -69,13 +62,14 @@ static int loongson2_cpufreq_target(struct cpufreq_policy *policy,set_cpus_allowed_ptr (current, &cpus_allowed);/* setting the cpu frequency */ -clk_set_rate (cpuclk, freq); +clk_set_rate (policy->clk, freq);return 0 ; }static int loongson2_cpufreq_cpu_init (struct cpufreq_policy *policy) { +static struct clk *cpuclk;int i;unsigned long rate;int ret;
@@ -104,13 +98,14 @@ static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy)return ret; } + policy->clk = cpuclk;return cpufreq_generic_init (policy, &loongson2_clockmod_table[0 ],0 ); }static int loongson2_cpufreq_exit (struct cpufreq_policy *policy) {cpufreq_frequency_table_put_attr (policy->cpu); -clk_put (cpuclk); +clk_put (policy->clk);return 0 ; }
@@ -119,7 +114,7 @@ static struct cpufreq_driver loongson2_cpufreq_driver = { .init = loongson2_cpufreq_cpu_init, .verify = cpufreq_generic_frequency_table_verify, .target_index = loongson2_cpufreq_target, - .get = loongson2_cpufreq_get, + .get = cpufreq_generic_get, .exit = loongson2_cpufreq_exit, .attr = cpufreq_generic_attr, };
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 222/228 cpufreq: omap: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We don't need a global variable to hold clock anymore.
--- drivers/cpufreq/omap-cpufreq.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-)
drivers/cpufreq/omap-cpufreq.c +10 -22
@@ -36,21 +36,9 @@static struct cpufreq_frequency_table *freq_table;static atomic_t freq_table_users =ATOMIC_INIT (0 ); -static struct clk *mpu_clk;static struct device *mpu_dev;static struct regulator *mpu_reg; -static unsigned int omap_getspeed (unsigned int cpu) -{ -unsigned long rate; - -if (cpu >=NR_CPUS ) -return 0 ; - - rate =clk_get_rate (mpu_clk) /1000 ; -return rate; -} -static int omap_target (struct cpufreq_policy *policy,unsigned int index) {int r, ret;
@@ -58,11 +46,11 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)unsigned long freq, volt =0 , volt_old =0 , tol =0 ;unsigned int old_freq, new_freq; - old_freq =omap_getspeed (policy->cpu); + old_freq = policy->cur; new_freq = freq_table[index].frequency; freq = new_freq *1000 ; - ret =clk_round_rate (mpu_clk, freq); + ret =clk_round_rate (policy->clk, freq);if (IS_ERR_VALUE (ret)) { dev_warn(mpu_dev, "CPUfreq: Cannot find matching frequency for %lu\n",
@@ -100,7 +88,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) } } - ret =clk_set_rate (mpu_clk, new_freq *1000 ); + ret =clk_set_rate (policy->clk, new_freq *1000 );/* scaling down? scale voltage after frequency */ if (mpu_reg && (new_freq < old_freq)) {
@@ -108,7 +96,7 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)if (r <0 ) {dev_warn (mpu_dev,"%s: unable to scale voltage down.\n" , __func__); -clk_set_rate (mpu_clk, old_freq *1000 ); +clk_set_rate (policy->clk, old_freq *1000 );return r; } }
@@ -126,9 +114,9 @@ static int omap_cpu_init(struct cpufreq_policy *policy) {int result; - mpu_clk =clk_get (NULL ,"cpufreq_ck" ); -if (IS_ERR (mpu_clk)) -return PTR_ERR (mpu_clk); + policy->clk =clk_get (NULL ,"cpufreq_ck" ); +if (IS_ERR (policy->clk)) +return PTR_ERR (policy->clk);if (!freq_table) { result =opp_init_cpufreq_table (mpu_dev, &freq_table);
@@ -149,7 +137,7 @@ static int omap_cpu_init(struct cpufreq_policy *policy)freq_table_free (); fail: -clk_put (mpu_clk); +clk_put (policy->clk);return result; }
@@ -157,7 +145,7 @@ static int omap_cpu_exit(struct cpufreq_policy *policy) {cpufreq_frequency_table_put_attr (policy->cpu);freq_table_free (); -clk_put (mpu_clk); +clk_put (policy->clk);return 0 ; }
@@ -165,7 +153,7 @@ static struct cpufreq_driver omap_driver = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, .target_index = omap_target, - .get = omap_getspeed, + .get = cpufreq_generic_get, .init = omap_cpu_init, .exit = omap_cpu_exit, .name = "omap",
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 223/228 cpufreq: ppc: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We don't need a variable to hold clock anymore in struct cpu_data.
--- drivers/cpufreq/ppc-corenet-cpufreq.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/cpufreq/ppc-corenet-cpufreq.c +4 -13
@@ -24,12 +24,10 @@/** * struct cpu_data - per CPU data struct -* @clk: the clk of CPU * @parent: the parent node of cpu clock * @table: frequency table */ struct cpu_data { -struct clk *clk;struct device_node *parent;struct cpufreq_frequency_table *table; };
@@ -81,13 +79,6 @@ static inline const struct cpumask *cpu_core_mask(int cpu) }#endif -static unsigned int corenet_cpufreq_get_speed (unsigned int cpu) -{ -struct cpu_data *data =per_cpu (cpu_data, cpu); - -return clk_get_rate (data->clk) /1000 ; -} -/* reduce the duplicated frequencies in frequency table */ static void freq_table_redup (struct cpufreq_frequency_table *freq_table,int count)
@@ -158,8 +149,8 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy) goto err_np; } - data->clk =of_clk_get (np,0 ); -if (IS_ERR (data->clk)) { + policy->clk =of_clk_get (np,0 ); +if (IS_ERR (policy->clk)) {pr_err ("%s: no clock information\n" , __func__); goto err_nomem2; }
@@ -255,7 +246,7 @@ static int corenet_cpufreq_target(struct cpufreq_policy *policy,struct cpu_data *data =per_cpu (cpu_data, policy->cpu); parent =of_clk_get (data->parent, data->table[index].driver_data); -return clk_set_parent (data->clk, parent); +return clk_set_parent (policy->clk, parent); }static struct cpufreq_driver ppc_corenet_cpufreq_driver = {
@@ -265,7 +256,7 @@ static struct cpufreq_driver ppc_corenet_cpufreq_driver = { .exit = __exit_p(corenet_cpufreq_cpu_exit), .verify = cpufreq_generic_frequency_table_verify, .target_index = corenet_cpufreq_target, - .get = corenet_cpufreq_get_speed, + .get = cpufreq_generic_get, .attr = cpufreq_generic_attr, };
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 224/228 cpufreq: s3c: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We don't need a global variable to hold clock anymore.
--- drivers/cpufreq/s3c24xx-cpufreq.c | 10 +++------- drivers/cpufreq/s3c64xx-cpufreq.c | 33 ++++++++++++--------------------- 2 files changed, 15 insertions(+), 28 deletions(-)
drivers/cpufreq/s3c24xx-cpufreq.c +3 -7
@@ -355,11 +355,6 @@ static int s3c_cpufreq_target(struct cpufreq_policy *policy,return -EINVAL ; } -static unsigned int s3c_cpufreq_get (unsigned int cpu) -{ -return clk_get_rate (clk_arm) /1000 ; -} -struct clk *s3c_cpufreq_clk_get (struct device *dev,const char *name) {struct clk *clk;
@@ -373,6 +368,7 @@ struct clk *s3c_cpufreq_clk_get(struct device *dev, const char *name)static int s3c_cpufreq_init (struct cpufreq_policy *policy) { + policy->clk = clk_arm;return cpufreq_generic_init (policy, ftab, cpu_cur.info->latency); }
@@ -408,7 +404,7 @@ static int s3c_cpufreq_suspend(struct cpufreq_policy *policy) { suspend_pll.frequency =clk_get_rate (_clk_mpll); suspend_pll.driver_data =__raw_readl (S3C2410_MPLLCON ); - suspend_freq =s3c_cpufreq_get (0 ) *1000 ; + suspend_freq =clk_get_rate (clk_arm);return 0 ; }
@@ -450,7 +446,7 @@ static int s3c_cpufreq_resume(struct cpufreq_policy *policy)static struct cpufreq_driver s3c24xx_driver = { .flags =CPUFREQ_STICKY , .target = s3c_cpufreq_target, - .get = s3c_cpufreq_get, + .get = cpufreq_generic_get, .init = s3c_cpufreq_init, .suspend = s3c_cpufreq_suspend, .resume = s3c_cpufreq_resume,
drivers/cpufreq/s3c64xx-cpufreq.c +12 -21
@@ -19,7 +19,6 @@#include <linux/regulator/consumer.h> #include <linux/module.h> -static struct clk *armclk;static struct regulator *vddarm;static unsigned long regulator_latency;
@@ -54,14 +53,6 @@ static struct cpufreq_frequency_table s3c64xx_freq_table[] = { };#endif -static unsigned int s3c64xx_cpufreq_get_speed (unsigned int cpu) -{ -if (cpu !=0 ) -return 0 ; - -return clk_get_rate (armclk) /1000 ; -} -static int s3c64xx_cpufreq_set_target (struct cpufreq_policy *policy,unsigned int index) {
@@ -69,7 +60,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,unsigned int old_freq, new_freq;int ret; - old_freq =clk_get_rate (armclk) /1000 ; + old_freq =clk_get_rate (policy->clk) /1000 ; new_freq = s3c64xx_freq_table[index].frequency; dvfs = &s3c64xx_dvfs_table[s3c64xx_freq_table[index].driver_data];
@@ -86,7 +77,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy, }#endif - ret =clk_set_rate (armclk, new_freq *1000 ); + ret =clk_set_rate (policy->clk, new_freq *1000 );if (ret <0 ) {pr_err ("Failed to set rate %dkHz: %d\n" , new_freq, ret);
@@ -101,7 +92,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,if (ret !=0 ) {pr_err ("Failed to set VDDARM for %dkHz: %d\n" , new_freq, ret); -if (clk_set_rate (armclk, old_freq *1000 ) <0 ) +if (clk_set_rate (policy->clk, old_freq *1000 ) <0 )pr_err ("Failed to restore original clock rate\n" );return ret;
@@ -110,7 +101,7 @@ static int s3c64xx_cpufreq_set_target(struct cpufreq_policy *policy,#endif pr_debug ("Set actual frequency %lukHz\n" , -clk_get_rate (armclk) /1000 ); +clk_get_rate (policy->clk) /1000 );return 0 ; }
@@ -169,11 +160,11 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)return -ENODEV ; } - armclk =clk_get (NULL ,"armclk" ); -if (IS_ERR (armclk)) { + policy->clk =clk_get (NULL ,"armclk" ); +if (IS_ERR (policy->clk)) {pr_err ("Unable to obtain ARMCLK: %ld\n" , -PTR_ERR (armclk)); -return PTR_ERR (armclk); +PTR_ERR (policy->clk)); +return PTR_ERR (policy->clk); }#ifdef CONFIG_REGULATOR
@@ -193,7 +184,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)unsigned long r;/* Check for frequencies we can generate */ - r =clk_round_rate (armclk, freq->frequency *1000 ); + r =clk_round_rate (policy->clk, freq->frequency *1000 ); r /=1000 ;if (r != freq->frequency) { pr_debug("%dkHz unsupported by clock\n",
@@ -203,7 +194,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)/* If we have no regulator then assume startup * frequency is the maximum we can support. */ -if (!vddarm && freq->frequency >s3c64xx_cpufreq_get_speed (0 )) +if (!vddarm && freq->frequency >clk_get_rate (policy->clk) /1000 ) freq->frequency =CPUFREQ_ENTRY_INVALID ; freq++;
@@ -219,7 +210,7 @@ static int s3c64xx_cpufreq_driver_init(struct cpufreq_policy *policy)pr_err ("Failed to configure frequency table: %d\n" , ret);regulator_put (vddarm); -clk_put (armclk); +clk_put (policy->clk); }return ret;
@@ -229,7 +220,7 @@ static struct cpufreq_driver s3c64xx_cpufreq_driver = { .flags = 0, .verify = cpufreq_generic_frequency_table_verify, .target_index = s3c64xx_cpufreq_set_target, - .get = s3c64xx_cpufreq_get_speed, + .get = cpufreq_generic_get, .init = s3c64xx_cpufreq_driver_init, .name = "s3c", };
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 225/228 cpufreq: s5pv210: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We don't need a global variable to hold clock anymore.
--- drivers/cpufreq/s5pv210-cpufreq.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/cpufreq/s5pv210-cpufreq.c +6 -15
@@ -23,7 +23,6 @@#include <mach/map.h> #include <mach/regs-clock.h> -static struct clk *cpu_clk;static struct clk *dmc0_clk;static struct clk *dmc1_clk;static DEFINE_MUTEX (set_freq_lock);
@@ -164,14 +163,6 @@ static void s5pv210_set_refresh(enum s5pv210_dmc_port ch, unsigned long freq)__raw_writel (tmp1, reg); } -static unsigned int s5pv210_getspeed (unsigned int cpu) -{ -if (cpu) -return 0 ; - -return clk_get_rate (cpu_clk) /1000 ; -} -static int s5pv210_target (struct cpufreq_policy *policy,unsigned int index) {unsigned long reg;
@@ -193,7 +184,7 @@ static int s5pv210_target(struct cpufreq_policy *policy, unsigned int index) goto exit; } - old_freq =s5pv210_getspeed (0 ); + old_freq = policy->cur; new_freq = s5pv210_freq_table[index].frequency;/* Finding current running level index */
@@ -471,9 +462,9 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy)unsigned long mem_type;int ret; - cpu_clk =clk_get (NULL ,"armclk" ); -if (IS_ERR (cpu_clk)) -return PTR_ERR (cpu_clk); + policy->clk =clk_get (NULL ,"armclk" ); +if (IS_ERR (policy->clk)) +return PTR_ERR (policy->clk); dmc0_clk =clk_get (NULL ,"sclk_dmc0" );if (IS_ERR (dmc0_clk)) {
@@ -516,7 +507,7 @@ static int __init s5pv210_cpu_init(struct cpufreq_policy *policy) out_dmc1:clk_put (dmc0_clk); out_dmc0: -clk_put (cpu_clk); +clk_put (policy->clk);return ret; }
@@ -563,7 +554,7 @@ static struct cpufreq_driver s5pv210_driver = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, .target_index = s5pv210_target, - .get = s5pv210_getspeed, + .get = cpufreq_generic_get, .init = s5pv210_cpu_init, .name = "s5pv210",#ifdef CONFIG_PM
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 226/228 cpufreq: spear: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/spear-cpufreq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/cpufreq/spear-cpufreq.c +2 -6
@@ -30,11 +30,6 @@ static struct {u32 cnt; } spear_cpufreq; -static unsigned int spear_cpufreq_get (unsigned int cpu) -{ -return clk_get_rate (spear_cpufreq.clk) /1000 ; -} -static struct clk *spear1340_cpu_get_possible_parent (unsigned long newfreq) {struct clk *sys_pclk;
@@ -156,6 +151,7 @@ static int spear_cpufreq_target(struct cpufreq_policy *policy,static int spear_cpufreq_init (struct cpufreq_policy *policy) { + policy->clk = spear_cpufreq.clk;return cpufreq_generic_init (policy, spear_cpufreq.freq_tbl, spear_cpufreq.transition_latency); }
@@ -165,7 +161,7 @@ static struct cpufreq_driver spear_cpufreq_driver = { .flags = CPUFREQ_STICKY, .verify = cpufreq_generic_frequency_table_verify, .target_index = spear_cpufreq_target, - .get = spear_cpufreq_get, + .get = cpufreq_generic_get, .init = spear_cpufreq_init, .exit = cpufreq_generic_exit, .attr = cpufreq_generic_attr,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 227/228 cpufreq: tegra: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
--- drivers/cpufreq/tegra-cpufreq.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/cpufreq/tegra-cpufreq.c +3 -13
@@ -50,17 +50,6 @@ static struct clk *emc_clk;static DEFINE_MUTEX (tegra_cpu_lock);static bool is_suspended; -static unsigned int tegra_getspeed (unsigned int cpu) -{ -unsigned long rate; - -if (cpu >=NUM_CPUS ) -return 0 ; - - rate =clk_get_rate (cpu_clk) /1000 ; -return rate; -} -static int tegra_cpu_clk_set_rate (unsigned long rate) {int ret;
@@ -144,7 +133,7 @@ static int tegra_pm_notify(struct notifier_block *nb, unsigned long event, is_suspended = true;pr_info ("Tegra cpufreq suspend: setting frequency to %d kHz\n" , freq_table[0 ].frequency); -if (tegra_getspeed (0 ) != freq_table[0 ].frequency) +if (clk_get_rate (cpu_clk) /1000 != freq_table[0 ].frequency)tegra_update_cpu_speed (policy, freq_table[0 ].frequency);cpufreq_cpu_put (policy); }else if (event ==PM_POST_SUSPEND ) {
@@ -180,6 +169,7 @@ static int tegra_cpu_init(struct cpufreq_policy *policy)if (policy->cpu ==0 )register_pm_notifier (&tegra_cpu_pm_notifier); + policy->clk = cpu_clk;return 0 ; }
@@ -194,7 +184,7 @@ static int tegra_cpu_exit(struct cpufreq_policy *policy)static struct cpufreq_driver tegra_cpufreq_driver = { .verify = cpufreq_generic_frequency_table_verify, .target_index = tegra_target, - .get = tegra_getspeed, + .get = cpufreq_generic_get, .init = tegra_cpu_init, .exit = tegra_cpu_exit, .name ="tegra" ,
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 228/228 cpufreq: unicore2: use cpufreq_generic_get() routine
In reply to Viresh KumarWe have common infrastructure available with us for getting a CPUs clk rate. Lets use it for this driver.
We also do clk_get() once instead of doing it again and again in target & init.
--- drivers/cpufreq/unicore2-cpufreq.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/cpufreq/unicore2-cpufreq.c +8 -13
@@ -11,6 +11,7 @@* published by the Free Software Foundation. */ +#include <linux/err.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/init.h>
@@ -33,26 +34,16 @@ static int ucv2_verify_speed(struct cpufreq_policy *policy)return 0 ; } -static unsigned int ucv2_getspeed (unsigned int cpu) -{ -struct clk *mclk =clk_get (NULL ,"MAIN_CLK" ); - -if (cpu) -return 0 ; -return clk_get_rate (mclk)/1000 ; -} -static int ucv2_target (struct cpufreq_policy *policy,unsigned int target_freq,unsigned int relation) { -unsigned int cur =ucv2_getspeed (0 ); +unsigned int cur = policy->cur;struct cpufreq_freqs freqs; -struct clk *mclk =clk_get (NULL ,"MAIN_CLK" );cpufreq_notify_transition (policy, &freqs,CPUFREQ_PRECHANGE ); -if (!clk_set_rate (mclk, target_freq *1000 )) { +if (!clk_set_rate (policy->clk, target_freq *1000 )) { freqs.old = cur; freqs.new = target_freq; }
@@ -66,9 +57,13 @@ static int __init ucv2_cpu_init(struct cpufreq_policy *policy) {if (policy->cpu !=0 )return -EINVAL ; + policy->min = policy->cpuinfo.min_freq =250000 ; policy->max = policy->cpuinfo.max_freq =1000000 ; policy->cpuinfo.transition_latency =CPUFREQ_ETERNAL ; + policy->clk =clk_get (NULL ,"MAIN_CLK" ); +if (IS_ERR (policy->clk)) +return PTR_ERR (policy->clk);return 0 ; }
@@ -76,7 +71,7 @@ static struct cpufreq_driver ucv2_driver = { .flags = CPUFREQ_STICKY, .verify = ucv2_verify_speed, .target = ucv2_target, - .get = ucv2_getspeed, + .get = cpufreq_generic_get, .init = ucv2_cpu_init, .name = "UniCore-II", };
Signature · 1 line
1.7.12.rc2.18.g61b472e
Quoted 7 lines · Viresh Kumar
This is my biggest patchset ever and it might not happen again in my entire career. I hope I haven't screwed up here :)
CPUFreq cleanup patches are ready to hit linux-next (I hope it doesn't turn out into horror stories, where it broke all possible architectures where Linux runs :))
Quoted 5 lines
Most of these are build tested only, Also done by: Fengguang Wu's build bot.
All of these were sent separately in smaller patchsets earlier and now merged together as a single set. Some parts are reviewed by platform maintainers and their Acks are included in the patches (Sorry if I missed any)..
I believe I asked you to send this stuff in pieces.
In any case, there's no way I'll apply this all at once and I'm not going to pull it all at once either.
Thanks,
Rafael
Viresh Kumar
maintainerQuoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Viresh Kumar
This is my biggest patchset ever and it might not happen again in my entire career. I hope I haven't screwed up here :)
CPUFreq cleanup patches are ready to hit linux-next (I hope it doesn't turn out into horror stories, where it broke all possible architectures where Linux runs :))
Most of these are build tested only, Also done by: Fengguang Wu's build bot.
Quoted 8 lines
Quoted 3 lines
All of these were sent separately in smaller patchsets earlier and now merged together as a single set. Some parts are reviewed by platform maintainers and their Acks are included in the patches (Sorry if I missed any)..
I believe I asked you to send this stuff in pieces.
In any case, there's no way I'll apply this all at once and I'm not going to pull it all at once either.
Exactly for this reason I had following in my cover-letter:
"As suggested by Rafael earlier, he might not apply all at once and will give people some chance to test sets one by one.. So, first set now, next one after few days. So, I am marking different sets with patch numbers to make it easier for Rafael.
- Patch 1->8: Generic cleanup of cpufreq core (First batch)
- Patch 9->54: Mostly about cpufreq_table_validate_and_show() helper (First batch)
- Patch 55->89: New generic routines for cpufreq drivers (First/Second batch)
- Patch 90->126: About calling cpufreq_driver->get() from core (First/Second batch)
- Patch 127->146: Generic init() routine (First/Second batch)
- Patch 147->180: Light weight ->target() routine (Third batch)
- Patch 181->211: Call notifiers from core instead of target() (Third/Fourth batch)
- Patch 212->228: Generic get() (Fifth batch)
"
I kept them together because it looked like multiple patchsets have confused people.. I have seen people reviewing first few sets and later on they haven't bothered to review.. Probably they got confused..
And so it was required to keep them together, so that people get the complete picture..
Sorry for the noise..