Questions on CPU frequency drivers for UltraSPARC IIe and III
Hi All,
Was doing some playing around tonight with the CPU frequency drivers in the 2.6 kernels and noticed a couple of things that I was wondering about;
1) The max frequency for the CPUs appears to be off by 3 decimal places. Originally, I had checked with cpufreq-info from the cpufrequtils package[1], and then later confirmed by checking the /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq file by hand. The values I was getting were 502000000 (502.00 GHz) on a 500 MHz Blade 100 and 750000000 (750.00 GHz) on either CPU in a dual 750 MHz Blade 1000. I'm guessing this is a problem with how the speeds are being reported to sysfs?
2) The minimum CPU frequencies possible being reported for the Blade 100 and Blade 1000 are 62750000 and 23437500 respectively. Are these accurate (even with the possibility mentioned above being taken into account)? They seem a bit low to me (based on what I've seen from the x86 world).
3) On x86, amd64 and PPC, there exists a file called /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq which shows the current running frequency of the CPU. For both the IIe and III cpufreq drivers, this is missing. Is there any reason for this (like no good way to poll the CPUs) or is it just a possible change in cpufreq stuff that wasn't synced up with sparc?
[1] -
http://www.kernel.org/pub/linux/utils/kernel/cpufreq/cpufrequtils.html
Thanks,
Signature · 2 lines
Jason Wever Gentoo/Sparc Team Co-Lead
From: Jason Wever <[email protected]>
Date: Wed, 17 Aug 2005 22:15:59 -0600
Quoted 8 lines
1) The max frequency for the CPUs appears to be off by 3 decimal places. Originally, I had checked with cpufreq-info from the cpufrequtils package[1], and then later confirmed by checking the
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freqfile by hand. The values I was getting were 502000000 (502.00 GHz) on a 500 MHz Blade 100 and 750000000 (750.00 GHz) on either CPU in a dual 750 MHz Blade 1000. I'm guessing this is a problem with how the speeds are being reported to sysfs?
That's definitely a bug. I'll try to figure out how I'm off by a factor of 1000 :-)
Quoted 5 lines
2) The minimum CPU frequencies possible being reported for the Blade 100 and Blade 1000 are 62750000 and 23437500 respectively. Are these accurate (even with the possibility mentioned above being taken into account)? They seem a bit low to me (based on what I've seen from the x86 world).
It looks right.
The UltraSPARC-III has three clock divisor values you can use, 1, 2, and 32. I know that seems weird, but that is what the chip supports.
UltraSPARC-IIe supports divisors 1, 2, 4, 6, and 8, so the IIe number looks correct as well.
Quoted 6 lines
3) On x86, amd64 and PPC, there exists a file called
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freqwhich shows the current running frequency of the CPU. For both the IIe and III cpufreq drivers, this is missing. Is there any reason for this (like no good way to poll the CPUs) or is it just a possible change in cpufreq stuff that wasn't synced up with sparc?
Strange, I'll try to figure out this bug as well.
Thanks for the report.
Jason, give this patch a spin, it should clear up the two bugs you spotted.
1) The clock tick values given to the cpufreq layer need to be in KHZ not MHZ.
2) The us2e/us3 drivers were not providing a "->get()" method which is why the cpuinfo_cur_freq sysfs field was not provided.
Thanks.
arch/sparc64/kernel/us2e_cpufreq.c +27 -9
@@ -88,7 +88,6 @@ static void frob_mem_refresh(int cpu_slo {unsigned long old_refr_count, refr_count, mctrl; - refr_count = (clock_tick *MCTRL0_REFR_INTERVAL ); refr_count /= (MCTRL0_REFR_CLKS_P_CNT * divisor *1000000000UL );
@@ -230,6 +229,25 @@ static unsigned long estar_to_divisor(unreturn ret; } +static unsigned int us2e_freq_get (unsigned int cpu) +{ +cpumask_t cpus_allowed; +unsigned long clock_tick, estar; + +if (!cpu_online (cpu)) +return 0 ; + + cpus_allowed = current->cpus_allowed; +set_cpus_allowed (current,cpumask_of_cpu (cpu)); + + clock_tick =sparc64_get_clock_tick (cpu) /1000 ; + estar =read_hbreg (HBIRD_ESTAR_MODE_ADDR ); + +set_cpus_allowed (current, cpus_allowed); + +return clock_tick /estar_to_divisor (estar); +} +static void us2e_set_cpu_divider_index (unsigned int cpu,unsigned int index) {unsigned long new_bits, new_freq;
@@ -243,7 +261,7 @@ static void us2e_set_cpu_divider_index(u cpus_allowed = current->cpus_allowed;set_cpus_allowed (current,cpumask_of_cpu (cpu)); - new_freq = clock_tick =sparc64_get_clock_tick (cpu); + new_freq = clock_tick =sparc64_get_clock_tick (cpu) /1000 ; new_bits =index_to_estar_mode (index); divisor =index_to_divisor (index); new_freq /= divisor;
@@ -258,7 +276,8 @@ static void us2e_set_cpu_divider_index(ucpufreq_notify_transition (&freqs,CPUFREQ_PRECHANGE );if (old_divisor != divisor) -us2e_transition (estar, new_bits, clock_tick, old_divisor, divisor); +us2e_transition (estar, new_bits, clock_tick *1000 , + old_divisor, divisor);cpufreq_notify_transition (&freqs,CPUFREQ_POSTCHANGE );
@@ -272,10 +291,8 @@ static int us2e_freq_target(struct cpufrunsigned int new_index =0 ;if (cpufreq_frequency_table_target (policy, - &us2e_freq_table[policy->cpu].table[0 ], - target_freq, - relation, - &new_index)) + &us2e_freq_table[policy->cpu].table[0 ], + target_freq, relation, &new_index))return -EINVAL ;us2e_set_cpu_divider_index (policy->cpu, new_index);
@@ -292,7 +309,7 @@ static int us2e_freq_verify(struct cpufrstatic int __init us2e_freq_cpu_init (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu; -unsigned long clock_tick =sparc64_get_clock_tick (cpu); +unsigned long clock_tick =sparc64_get_clock_tick (cpu) /1000 ; struct cpufreq_frequency_table *table &us2e_freq_table[cpu].table[0];
@@ -351,9 +368,10 @@ static int __init us2e_freq_init(void)memset (us2e_freq_table,0 , (NR_CPUS *sizeof (struct us2e_freq_percpu_info ))); + driver->init = us2e_freq_cpu_init; driver->verify = us2e_freq_verify; driver->target = us2e_freq_target; - driver->init = us2e_freq_cpu_init; + driver->get = us2e_freq_get; driver->exit = us2e_freq_cpu_exit; driver->owner =THIS_MODULE ,strcpy (driver->name,"UltraSPARC-IIe" );
arch/sparc64/kernel/us3_cpufreq.c +25 -4
@@ -56,7 +56,7 @@ static void write_safari_cfg(unsigned lostatic unsigned long get_current_freq (unsigned int cpu,unsigned long safari_cfg) { -unsigned long clock_tick =sparc64_get_clock_tick (cpu); +unsigned long clock_tick =sparc64_get_clock_tick (cpu) /1000 ;unsigned long ret;switch (safari_cfg &SAFARI_CFG_DIV_MASK ) {
@@ -76,6 +76,26 @@ static unsigned long get_current_freq(unreturn ret; } +static unsigned int us3_freq_get (unsigned int cpu) +{ +cpumask_t cpus_allowed; +unsigned long reg; +unsigned int ret; + +if (!cpu_online (cpu)) +return 0 ; + + cpus_allowed = current->cpus_allowed; +set_cpus_allowed (current,cpumask_of_cpu (cpu)); + + reg =read_safari_cfg (); + ret =get_current_freq (cpu, reg); + +set_cpus_allowed (current, cpus_allowed); + +return ret; +} +static void us3_set_cpu_divider_index (unsigned int cpu,unsigned int index) {unsigned long new_bits, new_freq, reg;
@@ -88,7 +108,7 @@ static void us3_set_cpu_divider_index(un cpus_allowed = current->cpus_allowed;set_cpus_allowed (current,cpumask_of_cpu (cpu)); - new_freq =sparc64_get_clock_tick (cpu); + new_freq =sparc64_get_clock_tick (cpu) /1000 ;switch (index) {case 0 : new_bits =SAFARI_CFG_DIV_1 ;
@@ -150,7 +170,7 @@ static int us3_freq_verify(struct cpufrestatic int __init us3_freq_cpu_init (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu; -unsigned long clock_tick =sparc64_get_clock_tick (cpu); +unsigned long clock_tick =sparc64_get_clock_tick (cpu) /1000 ; struct cpufreq_frequency_table *table &us3_freq_table[cpu].table[0];
@@ -206,9 +226,10 @@ static int __init us3_freq_init(void)memset (us3_freq_table,0 , (NR_CPUS *sizeof (struct us3_freq_percpu_info ))); + driver->init = us3_freq_cpu_init; driver->verify = us3_freq_verify; driver->target = us3_freq_target; - driver->init = us3_freq_cpu_init; + driver->get = us3_freq_get; driver->exit = us3_freq_cpu_exit; driver->owner =THIS_MODULE ,strcpy (driver->name,"UltraSPARC-III" );
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · David S. Miller
Jason, give this patch a spin, it should clear up the two bugs you spotted.
1) The clock tick values given to the cpufreq layer need to be in KHZ not MHZ.
2) The us2e/us3 drivers were not providing a "->get()" method which is why the
cpuinfo_cur_freqsysfs field was not provided.
Everything looks good now with this patch on both the Blade 100 and Blade 1000. Thanks!
- --
Jason Wever
Gentoo/Sparc Co-Team Lead
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDBJJEdKvgdVioq28RAr3kAJ9uf4ej/lz05cGsllyCG8Z+cpFiIgCgn4sw SBVH3ZMfQ8c2kNieWE18DOQ=9Xel
-----END PGP SIGNATURE-----
From: Jason Wever <[email protected]>
Date: Thu, 18 Aug 2005 07:50:58 -0600 (MDT)
Quoted 2 lines
Everything looks good now with this patch on both the Blade 100 and Blade 1000. Thanks!
Thanks for testing :-)
Stupid question... have you actually tried to change the frequency either manually or with a daemon like "cpuspeed"? That might be interesting :)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 11 lines · David S. Miller
From: Jason Wever <[email protected]>
Date: Thu, 18 Aug 2005 07:50:58 -0600 (MDT)Quoted 2 lines
Everything looks good now with this patch on both the Blade 100 and Blade 1000. Thanks!
Thanks for testing :-)
Stupid question... have you actually tried to change the frequency either manually or with a daemon like "cpuspeed"? That might be interesting :)
cpufrequtils includes tools to either change the speed manually or set a governor to do so. I've used the tool to set the governor to "ondemand" on the Blade 1000 and it seems to work fine (the cpufreq-info tool reports
both CPUs running at 23.4 MHz when idle). I can set the governor as well
on the Blade 100 but I haven't seen if the CPU frequency scales down yet as I've had it busy compiling things all day.
Cheers,
- --
Jason Wever
Gentoo/Sparc Co-Team Lead
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDBRVLdKvgdVioq28RAnkpAKCKghR5/w3fUG2UVcoelx0Xg2scOwCffAYt g880CDGkzSR9MqqB48OBPKY=S9C6
-----END PGP SIGNATURE-----