Skip to content

Commit

Permalink
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
Browse files Browse the repository at this point in the history
* master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq:
  [CPUFREQ] Don't take semaphore in cpufreq_quick_get()
  [CPUFREQ] Support different families in fid/did to frequency conversion
  [CPUFREQ] cpufreq_stats: misc cpuinit section annotations
  [CPUFREQ] implement !CONFIG_CPU_FREQ stub for  cpufreq_unregister_notifier()
  [CPUFREQ] mark hotplug notifier callback as __cpuinit
  [CPUFREQ] Only check for transition latency on problematic governors (kconfig fix)
  [CPUFREQ] allow ondemand and conservative cpufreq governors to be used as default
  [CPUFREQ] move policy's governor initialisation out of low-level drivers into cpufreq core
  [CPUFREQ] Longhaul - Add support for PM133 northbridge
  [CPUFREQ] x86: use num_online_nodes to get physical cpus numbers for
  • Loading branch information
Linus Torvalds committed Oct 12, 2007
2 parents 57c5b99 + 9eb5957 commit 4d5709a
Show file tree
Hide file tree
Showing 31 changed files with 119 additions and 86 deletions.
1 change: 0 additions & 1 deletion arch/arm/mach-imx/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,6 @@ static int __init imx_cpufreq_driver_init(struct cpufreq_policy *policy)
return -EINVAL;

policy->cur = policy->min = policy->max = imx_get_speed(0);
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.min_freq = 8000;
policy->cpuinfo.max_freq = 200000;
/* Manual states, that PLL stabilizes in two CLK32 periods */
Expand Down
1 change: 0 additions & 1 deletion arch/arm/mach-sa1100/cpu-sa1110.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ static int __init sa1110_cpu_init(struct cpufreq_policy *policy)
if (policy->cpu != 0)
return -EINVAL;
policy->cur = policy->min = policy->max = sa11x0_getspeed(0);
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.min_freq = 59000;
policy->cpuinfo.max_freq = 287000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
Expand Down
1 change: 0 additions & 1 deletion arch/arm/plat-omap/cpu-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ static int __init omap_cpu_init(struct cpufreq_policy *policy)
if (policy->cpu != 0)
return -EINVAL;
policy->cur = policy->min = policy->max = omap_getspeed(0);
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.min_freq = clk_round_rate(mpu_clk, 0) / 1000;
policy->cpuinfo.max_freq = clk_round_rate(mpu_clk, VERY_HI_RATE) / 1000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
Expand Down
2 changes: 0 additions & 2 deletions arch/blackfin/mach-bf533/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ static int __init __bf533_cpu_init(struct cpufreq_policy *policy)
if (policy->cpu != 0)
return -EINVAL;

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
/*Now ,only support one cpu */
policy->cur = bf533_getfreq(0);
Expand Down
2 changes: 0 additions & 2 deletions arch/ia64/kernel/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ acpi_cpufreq_cpu_init (
data->acpi_data.states[i].transition_latency * 1000;
}
}
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

policy->cur = processor_get_freq(data, policy->cpu);

/* table init */
Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/platforms/cell/cbe_cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
pr_debug("%d: %d\n", i, cbe_freqs[i].frequency);
}

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

/* if DEBUG is enabled set_pmode() measures the latency
* of a transition */
policy->cpuinfo.transition_latency = 25000;
Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/platforms/pasemi/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
pr_debug("%d: %d\n", i, pas_freqs[i].frequency);
}

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

policy->cpuinfo.transition_latency = get_gizmo_latency();

cur_astate = get_cur_astate(policy->cpu);
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/platforms/powermac/cpufreq_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
if (policy->cpu != 0)
return -ENODEV;

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = cur_freq;

Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/platforms/powermac/cpufreq_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ static unsigned int g5_cpufreq_get_speed(unsigned int cpu)

static int g5_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = g5_cpu_freqs[g5_query_freq()].frequency;
/* secondary CPUs are tied to the primary one by the
Expand Down
1 change: 0 additions & 1 deletion arch/sh/kernel/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.max_freq = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cur = sh_cpufreq_get(policy->cpu);
policy->min = policy->cpuinfo.min_freq;
policy->max = policy->cpuinfo.max_freq;
Expand Down
1 change: 0 additions & 1 deletion arch/sparc64/kernel/us2e_cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy)
table[2].index = 5;
table[3].frequency = CPUFREQ_TABLE_END;

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = 0;
policy->cur = clock_tick;

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,6 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
policy->cpuinfo.transition_latency =
perf->states[i].transition_latency * 1000;
}
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

data->max_freq = perf->states[0].core_frequency * 1000;
/* table init */
Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/cpufreq-nforce2.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
policy->cur = nforce2_get(policy->cpu);
policy->min = policy->cpuinfo.min_freq;
policy->max = policy->cpuinfo.max_freq;
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/e_powersaver.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ static int eps_cpu_init(struct cpufreq_policy *policy)
f_table[k].frequency = CPUFREQ_TABLE_END;
}

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = 140000; /* 844mV -> 700mV in ns */
policy->cur = fsb * current_multiplier;

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/elanfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ static int elanfreq_cpu_init(struct cpufreq_policy *policy)
}

/* cpuinfo and default policy values */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = elanfreq_get_cpu_frequency(0);

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/gx-suspmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
policy->min = maxfreq / POLICY_MIN_DIV;
policy->max = maxfreq;
policy->cur = curfreq;
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.min_freq = maxfreq / max_duration;
policy->cpuinfo.max_freq = maxfreq;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
Expand Down
5 changes: 4 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/longhaul.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,10 @@ static int enable_arbiter_disable(void)
reg = 0x78;
dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8601_0,
NULL);
/* Find PM133/VT8605 host bridge */
if (dev == NULL)
dev = pci_get_device(PCI_VENDOR_ID_VIA,
PCI_DEVICE_ID_VIA_8605_0, NULL);
/* Find CLE266 host bridge */
if (dev == NULL) {
reg = 0x76;
Expand Down Expand Up @@ -918,7 +922,6 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
if ((longhaul_version != TYPE_LONGHAUL_V1) && (scale_voltage != 0))
longhaul_setup_voltagescaling();

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = 200000; /* nsec */
policy->cur = calc_speed(longhaul_get_cpu_mult());

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/p4-clockmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
cpufreq_frequency_table_get_attr(p4clockmod_table, policy->cpu);

/* cpuinfo and default policy values */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = 1000000; /* assumed */
policy->cur = stock_freq;

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/powernow-k6.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
}

/* cpuinfo and default policy values */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = busfreq * max_multiplier;

Expand Down
2 changes: 0 additions & 2 deletions arch/x86/kernel/cpu/cpufreq/powernow-k7.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,6 @@ static int __init powernow_cpu_init (struct cpufreq_policy *policy)
printk (KERN_INFO PFX "Minimum speed %d MHz. Maximum speed %d MHz.\n",
minimum_speed/1000, maximum_speed/1000);

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;

policy->cpuinfo.transition_latency = cpufreq_scale(2000000UL, fsb, latency);

policy->cur = powernow_get(0);
Expand Down
13 changes: 5 additions & 8 deletions arch/x86/kernel/cpu/cpufreq/powernow-k8.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ static u32 find_khz_freq_from_fid(u32 fid)
/* Return a frequency in MHz, given an input fid and did */
static u32 find_freq_from_fiddid(u32 fid, u32 did)
{
return 100 * (fid + 0x10) >> did;
if (current_cpu_data.x86 == 0x10)
return 100 * (fid + 0x10) >> did;
else
return 100 * (fid + 0x8) >> did;
}

static u32 find_khz_freq_from_fiddid(u32 fid, u32 did)
Expand Down Expand Up @@ -1208,7 +1211,6 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
/* run on any CPU again */
set_cpus_allowed(current, oldmask);

pol->governor = CPUFREQ_DEFAULT_GOVERNOR;
if (cpu_family == CPU_HW_PSTATE)
pol->cpus = cpumask_of_cpu(pol->cpu);
else
Expand Down Expand Up @@ -1325,21 +1327,16 @@ static struct cpufreq_driver cpufreq_amd64_driver = {
static int __cpuinit powernowk8_init(void)
{
unsigned int i, supported_cpus = 0;
unsigned int booted_cores = 1;

for_each_online_cpu(i) {
if (check_supported_cpu(i))
supported_cpus++;
}

#ifdef CONFIG_SMP
booted_cores = cpu_data[0].booted_cores;
#endif

if (supported_cpus == num_online_cpus()) {
printk(KERN_INFO PFX "Found %d %s "
"processors (%d cpu cores) (" VERSION ")\n",
supported_cpus/booted_cores,
num_online_nodes(),
boot_cpu_data.x86_model_id, supported_cpus);
return cpufreq_register_driver(&cpufreq_amd64_driver);
}
Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/sc520_freq.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ static int sc520_freq_cpu_init(struct cpufreq_policy *policy)
return -ENODEV;

/* cpuinfo and default policy values */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = 1000000; /* 1ms */
policy->cur = sc520_freq_get_cpu_frequency(0);

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/speedstep-centrino.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)

freq = get_cur_freq(policy->cpu);

policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = 10000; /* 10uS transition latency */
policy->cur = freq;

Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/speedstep-ich.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
(speed / 1000));

/* cpuinfo and default policy values */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cur = speed;

result = cpufreq_frequency_table_cpuinfo(policy, speedstep_freqs);
Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/cpu/cpufreq/speedstep-smi.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
(speed / 1000));

/* cpuinfo and default policy values */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL;
policy->cur = speed;

Expand Down
27 changes: 23 additions & 4 deletions drivers/cpufreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ config CPU_FREQ_STAT_DETAILS

If in doubt, say N.

# Note that it is not currently possible to set the other governors (such as ondemand)
# as the default, since if they fail to initialise, cpufreq will be
# left in an undefined state.

choice
prompt "Default CPUFreq governor"
default CPU_FREQ_DEFAULT_GOV_USERSPACE if CPU_FREQ_SA1100 || CPU_FREQ_SA1110
Expand All @@ -85,6 +81,29 @@ config CPU_FREQ_DEFAULT_GOV_USERSPACE
program shall be able to set the CPU dynamically without having
to enable the userspace governor manually.

config CPU_FREQ_DEFAULT_GOV_ONDEMAND
bool "ondemand"
select CPU_FREQ_GOV_ONDEMAND
select CPU_FREQ_GOV_PERFORMANCE
help
Use the CPUFreq governor 'ondemand' as default. This allows
you to get a full dynamic frequency capable system by simply
loading your cpufreq low-level hardware driver.
Be aware that not all cpufreq drivers support the ondemand
governor. If unsure have a look at the help section of the
driver. Fallback governor will be the performance governor.

config CPU_FREQ_DEFAULT_GOV_CONSERVATIVE
bool "conservative"
select CPU_FREQ_GOV_CONSERVATIVE
select CPU_FREQ_GOV_PERFORMANCE
help
Use the CPUFreq governor 'conservative' as default. This allows
you to get a full dynamic frequency capable system by simply
loading your cpufreq low-level hardware driver.
Be aware that not all cpufreq drivers support the conservative
governor. If unsure have a look at the help section of the
driver. Fallback governor will be the performance governor.
endchoice

config CPU_FREQ_GOV_PERFORMANCE
Expand Down
34 changes: 28 additions & 6 deletions drivers/cpufreq/cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
init_completion(&policy->kobj_unregister);
INIT_WORK(&policy->update, handle_update);

/* Set governor before ->init, so that driver could check it */
policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
/* call driver. From then on the cpufreq must be able
* to accept all calls to ->verify and ->setpolicy for this CPU
*/
Expand Down Expand Up @@ -1109,12 +1111,7 @@ unsigned int cpufreq_quick_get(unsigned int cpu)
unsigned int ret_freq = 0;

if (policy) {
if (unlikely(lock_policy_rwsem_read(cpu)))
return ret_freq;

ret_freq = policy->cur;

unlock_policy_rwsem_read(cpu);
cpufreq_cpu_put(policy);
}

Expand Down Expand Up @@ -1483,6 +1480,31 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
{
int ret;

/* Only must be defined when default governor is known to have latency
restrictions, like e.g. conservative or ondemand.
That this is the case is already ensured in Kconfig
*/
#ifdef CONFIG_CPU_FREQ_GOV_PERFORMANCE
struct cpufreq_governor *gov = &cpufreq_gov_performance;
#else
struct cpufreq_governor *gov = NULL;
#endif

if (policy->governor->max_transition_latency &&
policy->cpuinfo.transition_latency >
policy->governor->max_transition_latency) {
if (!gov)
return -EINVAL;
else {
printk(KERN_WARNING "%s governor failed, too long"
" transition latency of HW, fallback"
" to %s governor\n",
policy->governor->name,
gov->name);
policy->governor = gov;
}
}

if (!try_module_get(policy->governor->owner))
return -EINVAL;

Expand Down Expand Up @@ -1703,7 +1725,7 @@ int cpufreq_update_policy(unsigned int cpu)
}
EXPORT_SYMBOL(cpufreq_update_policy);

static int cpufreq_cpu_callback(struct notifier_block *nfb,
static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{
unsigned int cpu = (unsigned long)hcpu;
Expand Down
Loading

0 comments on commit 4d5709a

Please sign in to comment.