Skip to content

Commit

Permalink
[CPUFREQ] p4-clockmod: switch to rdmsr_on_cpu/wrmsr_on_cpu
Browse files Browse the repository at this point in the history
Dances with cpumasks go away.

Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: Dave Jones <davej@redhat.com>
  • Loading branch information
Alexey Dobriyan authored and Dave Jones committed Apr 26, 2007
1 parent de46c33 commit 551948b
Showing 1 changed file with 6 additions and 25 deletions.
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

0 comments on commit 551948b

Please sign in to comment.