latency must be in _nano_seconds
Subsystems (3)
PATCH 7/8 latency must be in _nano_seconds
Even though the core stated that cpuinfo.transition_latency needs to be in 10^(-9) s, hardly any driver set it to nanoseconds but to microseconds. So, fix up the drivers.
arch/arm/mach-integrator/cpu.c | 2 +- arch/i386/kernel/cpu/cpufreq/acpi.c | 4 ++-- arch/i386/kernel/cpu/cpufreq/p4-clockmod.c | 2 +- arch/i386/kernel/cpu/cpufreq/powernow-k7.c | 2 +- arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 4 ++-- include/linux/cpufreq.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/mach-integrator/cpu.c +1 -1
@@ -172,7 +172,7 @@ policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; policy->cpuinfo.max_freq =160000 ; policy->cpuinfo.min_freq =12000 ; - policy->cpuinfo.transition_latency =1000 ;/* 1 ms, assumed */ + policy->cpuinfo.transition_latency =1000000 ;/* 1 ms, assumed */ policy->cur = policy->min = policy->max =icst525_khz (&cclk_params, vco);/* current freq */
arch/i386/kernel/cpu/cpufreq/acpi.c +2 -2
@@ -578,8 +578,8 @@/* detect transition latency */ policy->cpuinfo.transition_latency =0 ;for (i=0 ;i<perf->state_count;i++) { -if (perf->states[i].transition_latency > policy->cpuinfo.transition_latency) - policy->cpuinfo.transition_latency = perf->states[i].transition_latency; +if ((perf->states[i].transition_latency *1000 ) > policy->cpuinfo.transition_latency) + policy->cpuinfo.transition_latency = perf->states[i].transition_latency *1000 ; } policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; policy->cur = perf->states[pr->limit.state.px].core_frequency *1000 ;
arch/i386/kernel/cpu/cpufreq/p4-clockmod.c +1 -1
@@ -255,7 +255,7 @@/* cpuinfo and default policy values */ policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; - policy->cpuinfo.transition_latency =1000 ; + policy->cpuinfo.transition_latency =1000000 ;/* assumed */ policy->cur = stock_freq;return cpufreq_frequency_table_cpuinfo (policy, &p4clockmod_table[0 ]);
arch/i386/kernel/cpu/cpufreq/powernow-k7.c +1 -1
@@ -386,7 +386,7 @@ minimum_speed, maximum_speed); policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; - policy->cpuinfo.transition_latency = latency; + policy->cpuinfo.transition_latency = latency *20 ; policy->cur = maximum_speed;return cpufreq_frequency_table_cpuinfo (policy, powernow_table);
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +2 -2
@@ -959,8 +959,8 @@ pol->governor =CPUFREQ_DEFAULT_GOVERNOR ;/* Take a crude guess here. */ - pol->cpuinfo.transition_latency = ((rvo +8 ) * vstable *VST_UNITS_20US ) - + (3 * (1 << irt) *10 ); + pol->cpuinfo.transition_latency = (((rvo +8 ) * vstable *VST_UNITS_20US ) + + (3 * (1 << irt) *10 )) *1000 ;if (query_current_values_with_pending_wait ())return -EIO ;
include/linux/cpufreq.h +1 -1
@@ -57,7 +57,7 @@struct cpufreq_cpuinfo {unsigned int max_freq;unsigned int min_freq; -unsigned int transition_latency;/* in 10^(-9) s */ +unsigned int transition_latency;/* in 10^(-9) s = nanoseconds */ };struct cpufreq_real_policy {
arch/i386/kernel/cpu/cpufreq/powernow-k7.c line 390
Quoted 11 lines · Dominik Brodowski
return
cpufreq_frequency_table_cpuinfo(policy, &p4clockmod_table[0]);
diff -ruNlinux-original/arch/i386/kernel/cpu/cpufreq/powernow-k7.clinux/arch/i386/kernel/cpu/cpufreq/powernow-k7.carch/i386/kernel/cpu/cpufreq/powernow-k7.c +1
-1@@ -386,7 +386,7 @@ minimum_speed, maximum_speed); policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; - policy->cpuinfo.transition_latency = latency; + policy->cpuinfo.transition_latency = latency *20 ; policy->cur = maximum_speed;
Can we at least get a comment explaining where '20' comes from when we add magic numbers like this? I know, and you know, but it's a little non-obvious, and in six months time, I'll probably have forgotten too 8)
arch/i386/kernel/cpu/cpufreq/powernow-k8.c line 963
Quoted 11 lines
diff -ruN
linux-original/arch/i386/kernel/cpu/cpufreq/powernow-k8.clinux/arch/i386/kernel/cpu/cpufreq/powernow-k8.carch/i386/kernel/cpu/cpufreq/powernow-k8.c +2
-2@@ -959,8 +959,8 @@ pol->governor =CPUFREQ_DEFAULT_GOVERNOR ;/* Take a crude guess here. */ - pol->cpuinfo.transition_latency = ((rvo +8 ) * vstable *VST_UNITS_20US ) - + (3 * (1 << irt) *10 ); + pol->cpuinfo.transition_latency = (((rvo +8 ) * vstable *VST_UNITS_20US ) + + (3 * (1 << irt) *10 )) *1000 ;
Ditto. This one moreso, as its quite complex to begin with.
Dave
Quoted 9 lines · Dave Jones
Quoted 7 lines · Dominik Brodowski
return
cpufreq_frequency_table_cpuinfo(policy, &p4clockmod_table[0]);
diff -ruNlinux-original/arch/i386/kernel/cpu/cpufreq/powernow-k7.clinux/arch/i386/kernel/cpu/cpufreq/powernow-k7.carch/i386/kernel/cpu/cpufreq/powernow-k7.c +0
-0@@ -386,7 +386,7 @@ minimum_speed, maximum_speed);
Quoted 9 lines
arch/i386/kernel/cpu/cpufreq/powernow-k7.c line 390
Quoted 4 lines
arch/i386/kernel/cpu/cpufreq/powernow-k7.c +1
-1policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; - policy->cpuinfo.transition_latency = latency; + policy->cpuinfo.transition_latency = latency *20 ; policy->cur = maximum_speed;Can we at least get a comment explaining where '20' comes from when we add magic numbers like this? I know, and you know, but it's a little non-obvious, and in six months time, I'll probably have forgotten too 8)
Comment added.
Quoted 6 lines
Quoted 6 lines
diff -ruN
linux-original/arch/i386/kernel/cpu/cpufreq/powernow-k8.clinux/arch/i386/kernel/cpu/cpufreq/powernow-k8.carch/i386/kernel/cpu/cpufreq/powernow-k8.c +0
-0@@ -959,8 +959,8 @@ pol->governor =CPUFREQ_DEFAULT_GOVERNOR ;
Quoted 7 lines
arch/i386/kernel/cpu/cpufreq/powernow-k8.c line 963
Quoted 5 lines
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +2
-2/* Take a crude guess here. */ - pol->cpuinfo.transition_latency = ((rvo +8 ) * vstable *VST_UNITS_20US ) - + (3 * (1 << irt) *10 ); + pol->cpuinfo.transition_latency = (((rvo +8 ) * vstable *VST_UNITS_20US ) + + (3 * (1 << irt) *10 )) *1000 ;Ditto. This one moreso, as its quite complex to begin with.
What Paul Devriendt did here I do not know, but I added a comment for the factor "1000"...
Dominik
Even though the core stated that cpuinfo.transition_latency needs to be in 10^(-9) s, hardly any driver set it to nanoseconds but to microseconds. So, fix up the drivers.
arch/arm/mach-integrator/cpu.c | 2 +- arch/i386/kernel/cpu/cpufreq/acpi.c | 4 ++-- arch/i386/kernel/cpu/cpufreq/p4-clockmod.c | 2 +- arch/i386/kernel/cpu/cpufreq/powernow-k7.c | 6 +++++- arch/i386/kernel/cpu/cpufreq/powernow-k8.c | 7 ++++--- include/linux/cpufreq.h | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-)
arch/arm/mach-integrator/cpu.c +1 -1
@@ -172,7 +172,7 @@ policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; policy->cpuinfo.max_freq =160000 ; policy->cpuinfo.min_freq =12000 ; - policy->cpuinfo.transition_latency =1000 ;/* 1 ms, assumed */ + policy->cpuinfo.transition_latency =1000000 ;/* 1 ms, assumed */ policy->cur = policy->min = policy->max =icst525_khz (&cclk_params, vco);/* current freq */
arch/i386/kernel/cpu/cpufreq/acpi.c +2 -2
@@ -578,8 +578,8 @@/* detect transition latency */ policy->cpuinfo.transition_latency =0 ;for (i=0 ;i<perf->state_count;i++) { -if (perf->states[i].transition_latency > policy->cpuinfo.transition_latency) - policy->cpuinfo.transition_latency = perf->states[i].transition_latency; +if ((perf->states[i].transition_latency *1000 ) > policy->cpuinfo.transition_latency) + policy->cpuinfo.transition_latency = perf->states[i].transition_latency *1000 ; } policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; policy->cur = perf->states[pr->limit.state.px].core_frequency *1000 ;
arch/i386/kernel/cpu/cpufreq/p4-clockmod.c +1 -1
@@ -255,7 +255,7 @@/* cpuinfo and default policy values */ policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; - policy->cpuinfo.transition_latency =1000 ; + policy->cpuinfo.transition_latency =1000000 ;/* assumed */ policy->cur = stock_freq;return cpufreq_frequency_table_cpuinfo (policy, &p4clockmod_table[0 ]);
arch/i386/kernel/cpu/cpufreq/powernow-k7.c +5 -1
@@ -386,7 +386,11 @@ minimum_speed, maximum_speed); policy->governor =CPUFREQ_DEFAULT_GOVERNOR ; - policy->cpuinfo.transition_latency = latency; + +/* latency is in 10 ns (look for SGTC above) for each VID +* and FID transition, so multiply that value with 20 */ + policy->cpuinfo.transition_latency = latency *20 ; + policy->cur = maximum_speed;return cpufreq_frequency_table_cpuinfo (policy, powernow_table);
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +4 -3
@@ -958,9 +958,10 @@ pol->governor =CPUFREQ_DEFAULT_GOVERNOR ; -/* Take a crude guess here. */ - pol->cpuinfo.transition_latency = ((rvo +8 ) * vstable *VST_UNITS_20US ) - + (3 * (1 << irt) *10 ); +/* Take a crude guess here. +* That guess was in microseconds, so multply with 1000 */ + pol->cpuinfo.transition_latency = (((rvo +8 ) * vstable *VST_UNITS_20US ) + + (3 * (1 << irt) *10 )) *1000 ;if (query_current_values_with_pending_wait ())return -EIO ;
include/linux/cpufreq.h +1 -1
@@ -57,7 +57,7 @@struct cpufreq_cpuinfo {unsigned int max_freq;unsigned int min_freq; -unsigned int transition_latency;/* in 10^(-9) s */ +unsigned int transition_latency;/* in 10^(-9) s = nanoseconds */ };struct cpufreq_real_policy {