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] Report the number of processors in PowerNow-k8 correctly
  [CPUFREQ] do not declare undefined functions
  [CPUFREQ] cleanup kconfig options
  [CPUFREQ] Longhaul - Revert Longhaul ver. 2
  [CPUFREQ] Remove deprecated /proc/acpi/processor/performance write support
  [CPUFREQ] Fix limited cpufreq when booted on battery
  Fix preemption warnings in speedstep-centrino.c
  [CPUFREQ] Longhaul - Correct PCI code
  [CPUFREQ] p4-clockmod: switch to rdmsr_on_cpu/wrmsr_on_cpu
  • Loading branch information
Linus Torvalds committed May 5, 2007
2 parents 98b9617 + 2e49762 commit ded1504
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 143 deletions.
21 changes: 13 additions & 8 deletions arch/i386/kernel/cpu/cpufreq/longhaul.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,20 +590,23 @@ static acpi_status longhaul_walk_callback(acpi_handle obj_handle,
static int enable_arbiter_disable(void)
{
struct pci_dev *dev;
int status;
int reg;
u8 pci_cmd;

status = 1;
/* Find PLE133 host bridge */
reg = 0x78;
dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8601_0, NULL);
dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8601_0,
NULL);
/* Find CLE266 host bridge */
if (dev == NULL) {
reg = 0x76;
dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_862X_0, NULL);
dev = pci_get_device(PCI_VENDOR_ID_VIA,
PCI_DEVICE_ID_VIA_862X_0, NULL);
/* Find CN400 V-Link host bridge */
if (dev == NULL)
dev = pci_find_device(PCI_VENDOR_ID_VIA, 0x7259, NULL);

dev = pci_get_device(PCI_VENDOR_ID_VIA, 0x7259, NULL);
}
if (dev != NULL) {
/* Enable access to port 0x22 */
Expand All @@ -615,10 +618,11 @@ static int enable_arbiter_disable(void)
if (!(pci_cmd & 1<<7)) {
printk(KERN_ERR PFX
"Can't enable access to port 0x22.\n");
return 0;
status = 0;
}
}
return 1;
pci_dev_put(dev);
return status;
}
return 0;
}
Expand All @@ -629,7 +633,7 @@ static int longhaul_setup_vt8235(void)
u8 pci_cmd;

/* Find VT8235 southbridge */
dev = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL);
dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, NULL);
if (dev != NULL) {
/* Set transition time to max */
pci_read_config_byte(dev, 0xec, &pci_cmd);
Expand All @@ -641,6 +645,7 @@ static int longhaul_setup_vt8235(void)
pci_read_config_byte(dev, 0xe5, &pci_cmd);
pci_cmd |= 1 << 7;
pci_write_config_byte(dev, 0xe5, pci_cmd);
pci_dev_put(dev);
return 1;
}
return 0;
Expand Down Expand Up @@ -678,7 +683,7 @@ static int __init longhaul_cpu_init(struct cpufreq_policy *policy)
sizeof(samuel2_eblcr));
break;
case 1 ... 15:
longhaul_version = TYPE_LONGHAUL_V2;
longhaul_version = TYPE_LONGHAUL_V1;
if (c->x86_mask < 8) {
cpu_model = CPU_SAMUEL2;
cpuname = "C3 'Samuel 2' [C5B]";
Expand Down
31 changes: 6 additions & 25 deletions arch/i386/kernel/cpu/cpufreq/p4-clockmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <linux/cpufreq.h>
#include <linux/slab.h>
#include <linux/cpumask.h>
#include <linux/sched.h> /* current / set_cpus_allowed() */

#include <asm/processor.h>
#include <asm/msr.h>
Expand Down Expand Up @@ -62,18 +61,18 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
if (!cpu_online(cpu) || (newstate > DC_DISABLE) || (newstate == DC_RESV))
return -EINVAL;

rdmsr(MSR_IA32_THERM_STATUS, l, h);
rdmsr_on_cpu(cpu, MSR_IA32_THERM_STATUS, &l, &h);

if (l & 0x01)
dprintk("CPU#%d currently thermal throttled\n", cpu);

if (has_N44_O17_errata[cpu] && (newstate == DC_25PT || newstate == DC_DFLT))
newstate = DC_38PT;

rdmsr(MSR_IA32_THERM_CONTROL, l, h);
rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h);
if (newstate == DC_DISABLE) {
dprintk("CPU#%d disabling modulation\n", cpu);
wrmsr(MSR_IA32_THERM_CONTROL, l & ~(1<<4), h);
wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, l & ~(1<<4), h);
} else {
dprintk("CPU#%d setting duty cycle to %d%%\n",
cpu, ((125 * newstate) / 10));
Expand All @@ -84,7 +83,7 @@ static int cpufreq_p4_setdc(unsigned int cpu, unsigned int newstate)
*/
l = (l & ~14);
l = l | (1<<4) | ((newstate & 0x7)<<1);
wrmsr(MSR_IA32_THERM_CONTROL, l, h);
wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, l, h);
}

return 0;
Expand All @@ -111,7 +110,6 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
{
unsigned int newstate = DC_RESV;
struct cpufreq_freqs freqs;
cpumask_t cpus_allowed;
int i;

if (cpufreq_frequency_table_target(policy, &p4clockmod_table[0], target_freq, relation, &newstate))
Expand All @@ -132,17 +130,8 @@ static int cpufreq_p4_target(struct cpufreq_policy *policy,
/* run on each logical CPU, see section 13.15.3 of IA32 Intel Architecture Software
* Developer's Manual, Volume 3
*/
cpus_allowed = current->cpus_allowed;

for_each_cpu_mask(i, policy->cpus) {
cpumask_t this_cpu = cpumask_of_cpu(i);

set_cpus_allowed(current, this_cpu);
BUG_ON(smp_processor_id() != i);

for_each_cpu_mask(i, policy->cpus)
cpufreq_p4_setdc(i, p4clockmod_table[newstate].index);
}
set_cpus_allowed(current, cpus_allowed);

/* notifiers */
for_each_cpu_mask(i, policy->cpus) {
Expand Down Expand Up @@ -256,17 +245,9 @@ static int cpufreq_p4_cpu_exit(struct cpufreq_policy *policy)

static unsigned int cpufreq_p4_get(unsigned int cpu)
{
cpumask_t cpus_allowed;
u32 l, h;

cpus_allowed = current->cpus_allowed;

set_cpus_allowed(current, cpumask_of_cpu(cpu));
BUG_ON(smp_processor_id() != cpu);

rdmsr(MSR_IA32_THERM_CONTROL, l, h);

set_cpus_allowed(current, cpus_allowed);
rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL, &l, &h);

if (l & 0x10) {
l = l >> 1;
Expand Down
6 changes: 4 additions & 2 deletions arch/i386/kernel/cpu/cpufreq/powernow-k8.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ static int fill_powernow_table(struct powernow_k8_data *data, struct pst_s *pst,

dprintk("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
data->powernow_table = powernow_table;
print_basics(data);
if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
print_basics(data);

for (j = 0; j < data->numps; j++)
if ((pst[j].fid==data->currfid) && (pst[j].vid==data->currvid))
Expand Down Expand Up @@ -814,7 +815,8 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)

/* fill in data */
data->numps = data->acpi_data.state_count;
print_basics(data);
if (first_cpu(cpu_core_map[data->cpu]) == data->cpu)
print_basics(data);
powernow_k8_acpi_pst_values(data, 0);

/* notify BIOS that we exist */
Expand Down
2 changes: 2 additions & 0 deletions arch/i386/kernel/cpu/cpufreq/powernow-k8.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ static int core_frequency_transition(struct powernow_k8_data *data, u32 reqfid);

static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index);

#ifdef CONFIG_X86_POWERNOW_K8_ACPI
static int fill_powernow_table_pstate(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);
static int fill_powernow_table_fidvid(struct powernow_k8_data *data, struct cpufreq_frequency_table *powernow_table);
#endif

#ifdef CONFIG_SMP
static inline void define_siblings(int cpu, cpumask_t cpu_sharedcore_mask[])
Expand Down
10 changes: 9 additions & 1 deletion arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,15 @@ static int centrino_target (struct cpufreq_policy *policy,
cpu_set(j, set_mask);

set_cpus_allowed(current, set_mask);
preempt_disable();
if (unlikely(!cpu_isset(smp_processor_id(), set_mask))) {
dprintk("couldn't limit to CPUs in this domain\n");
retval = -EAGAIN;
if (first_cpu) {
/* We haven't started the transition yet. */
goto migrate_end;
}
preempt_enable();
break;
}

Expand Down Expand Up @@ -761,10 +763,13 @@ static int centrino_target (struct cpufreq_policy *policy,
}

wrmsr(MSR_IA32_PERF_CTL, oldmsr, h);
if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
preempt_enable();
break;
}

cpu_set(j, covered_cpus);
preempt_enable();
}

for_each_cpu_mask(k, online_policy_cpus) {
Expand Down Expand Up @@ -796,8 +801,11 @@ static int centrino_target (struct cpufreq_policy *policy,
cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
}
}
set_cpus_allowed(current, saved_mask);
return 0;

migrate_end:
preempt_enable();
set_cpus_allowed(current, saved_mask);
return 0;
}
Expand Down
19 changes: 15 additions & 4 deletions arch/x86_64/kernel/cpufreq/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ config X86_POWERNOW_K8
help
This adds the CPUFreq driver for mobile AMD Opteron/Athlon64 processors.

To compile this driver as a module, choose M here: the
module will be called powernow-k8.

For details, take a look at <file:Documentation/cpu-freq/>.

If in doubt, say N.
Expand All @@ -38,6 +41,9 @@ config X86_SPEEDSTEP_CENTRINO
mobile CPUs. This means Intel Pentium M (Centrino) CPUs
or 64bit enabled Intel Xeons.

To compile this driver as a module, choose M here: the
module will be called speedstep-centrino.

For details, take a look at <file:Documentation/cpu-freq/>.

If in doubt, say N.
Expand All @@ -55,14 +61,17 @@ config X86_ACPI_CPUFREQ
Processor Performance States.
This driver also supports Intel Enhanced Speedstep.

To compile this driver as a module, choose M here: the
module will be called acpi-cpufreq.

For details, take a look at <file:Documentation/cpu-freq/>.

If in doubt, say N.

comment "shared options"

config X86_ACPI_CPUFREQ_PROC_INTF
bool "/proc/acpi/processor/../performance interface (deprecated)"
bool "/proc/acpi/processor/../performance interface (deprecated)"
depends on PROC_FS
depends on X86_ACPI_CPUFREQ || X86_SPEEDSTEP_CENTRINO_ACPI || X86_POWERNOW_K8_ACPI
help
Expand All @@ -86,16 +95,18 @@ config X86_P4_CLOCKMOD
slowdowns and noticeable latencies. Normally Speedstep should be used
instead.

To compile this driver as a module, choose M here: the
module will be called p4-clockmod.

For details, take a look at <file:Documentation/cpu-freq/>.

Unless you are absolutely sure say N.


config X86_SPEEDSTEP_LIB
tristate
default X86_P4_CLOCKMOD
tristate
default X86_P4_CLOCKMOD

endif

endmenu

46 changes: 1 addition & 45 deletions drivers/acpi/processor_perflib.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,49 +433,6 @@ static int acpi_processor_perf_open_fs(struct inode *inode, struct file *file)
PDE(inode)->data);
}

static ssize_t
acpi_processor_write_performance(struct file *file,
const char __user * buffer,
size_t count, loff_t * data)
{
int result = 0;
struct seq_file *m = file->private_data;
struct acpi_processor *pr = m->private;
struct acpi_processor_performance *perf;
char state_string[12] = { '\0' };
unsigned int new_state = 0;
struct cpufreq_policy policy;


if (!pr || (count > sizeof(state_string) - 1))
return -EINVAL;

perf = pr->performance;
if (!perf)
return -EINVAL;

if (copy_from_user(state_string, buffer, count))
return -EFAULT;

state_string[count] = '\0';
new_state = simple_strtoul(state_string, NULL, 0);

if (new_state >= perf->state_count)
return -EINVAL;

cpufreq_get_policy(&policy, pr->id);

policy.cpu = pr->id;
policy.min = perf->states[new_state].core_frequency * 1000;
policy.max = perf->states[new_state].core_frequency * 1000;

result = cpufreq_set_policy(&policy);
if (result)
return result;

return count;
}

static void acpi_cpufreq_add_file(struct acpi_processor *pr)
{
struct proc_dir_entry *entry = NULL;
Expand All @@ -487,10 +444,9 @@ static void acpi_cpufreq_add_file(struct acpi_processor *pr)

/* add file 'performance' [R/W] */
entry = create_proc_entry(ACPI_PROCESSOR_FILE_PERFORMANCE,
S_IFREG | S_IRUGO | S_IWUSR,
S_IFREG | S_IRUGO,
acpi_device_dir(device));
if (entry){
acpi_processor_perf_fops.write = acpi_processor_write_performance;
entry->proc_fops = &acpi_processor_perf_fops;
entry->data = acpi_driver_data(device);
entry->owner = THIS_MODULE;
Expand Down
Loading

0 comments on commit ded1504

Please sign in to comment.