aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/acpi/cstate.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-01-10 09:12:18 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-10 09:12:18 -0500
commit4e9b1c184cadbece3694603de5f880b6e35bd7a7 (patch)
tree8ae2ab8a4eaab4d46b4460284fd5ee475ce9a42d /arch/x86/kernel/acpi/cstate.c
parent0176260fc30842e358cf34afa7dcd9413db44822 (diff)
parent36c401a44abcc389a00f9cd14892c9cf9bf0780d (diff)
Merge branch 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'cpus4096-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: [IA64] fix typo in cpumask_of_pcibus() x86: fix x86_32 builds for summit and es7000 arch's cpumask: use work_on_cpu in acpi-cpufreq.c for read_measured_perf_ctrs cpumask: use work_on_cpu in acpi-cpufreq.c for drv_read and drv_write cpumask: use cpumask_var_t in acpi-cpufreq.c cpumask: use work_on_cpu in acpi/cstate.c cpumask: convert struct cpufreq_policy to cpumask_var_t cpumask: replace CPUMASK_ALLOC etc with cpumask_var_t x86: cleanup remaining cpumask_t ops in smpboot code cpumask: update pci_bus_show_cpuaffinity to use new cpumask API cpumask: update local_cpus_show to use new cpumask API ia64: cpumask fix for is_affinity_mask_valid()
Diffstat (limited to 'arch/x86/kernel/acpi/cstate.c')
-rw-r--r--arch/x86/kernel/acpi/cstate.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index a4805b3b4095..bbbe4bbb6f34 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -67,35 +67,15 @@ static short mwait_supported[ACPI_PROCESSOR_MAX_POWER];
67 67
68#define NATIVE_CSTATE_BEYOND_HALT (2) 68#define NATIVE_CSTATE_BEYOND_HALT (2)
69 69
70int acpi_processor_ffh_cstate_probe(unsigned int cpu, 70static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
71 struct acpi_processor_cx *cx, struct acpi_power_register *reg)
72{ 71{
73 struct cstate_entry *percpu_entry; 72 struct acpi_processor_cx *cx = _cx;
74 struct cpuinfo_x86 *c = &cpu_data(cpu); 73 long retval;
75
76 cpumask_t saved_mask;
77 int retval;
78 unsigned int eax, ebx, ecx, edx; 74 unsigned int eax, ebx, ecx, edx;
79 unsigned int edx_part; 75 unsigned int edx_part;
80 unsigned int cstate_type; /* C-state type and not ACPI C-state type */ 76 unsigned int cstate_type; /* C-state type and not ACPI C-state type */
81 unsigned int num_cstate_subtype; 77 unsigned int num_cstate_subtype;
82 78
83 if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF )
84 return -1;
85
86 if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT)
87 return -1;
88
89 percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
90 percpu_entry->states[cx->index].eax = 0;
91 percpu_entry->states[cx->index].ecx = 0;
92
93 /* Make sure we are running on right CPU */
94 saved_mask = current->cpus_allowed;
95 retval = set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
96 if (retval)
97 return -1;
98
99 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); 79 cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
100 80
101 /* Check whether this particular cx_type (in CST) is supported or not */ 81 /* Check whether this particular cx_type (in CST) is supported or not */
@@ -116,21 +96,45 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
116 retval = -1; 96 retval = -1;
117 goto out; 97 goto out;
118 } 98 }
119 percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK;
120
121 /* Use the hint in CST */
122 percpu_entry->states[cx->index].eax = cx->address;
123 99
124 if (!mwait_supported[cstate_type]) { 100 if (!mwait_supported[cstate_type]) {
125 mwait_supported[cstate_type] = 1; 101 mwait_supported[cstate_type] = 1;
126 printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " 102 printk(KERN_DEBUG
127 "state\n", cx->type); 103 "Monitor-Mwait will be used to enter C-%d "
104 "state\n", cx->type);
128 } 105 }
129 snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", 106 snprintf(cx->desc,
130 cx->address); 107 ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
131 108 cx->address);
132out: 109out:
133 set_cpus_allowed_ptr(current, &saved_mask); 110 return retval;
111}
112
113int acpi_processor_ffh_cstate_probe(unsigned int cpu,
114 struct acpi_processor_cx *cx, struct acpi_power_register *reg)
115{
116 struct cstate_entry *percpu_entry;
117 struct cpuinfo_x86 *c = &cpu_data(cpu);
118 long retval;
119
120 if (!cpu_cstate_entry || c->cpuid_level < CPUID_MWAIT_LEAF)
121 return -1;
122
123 if (reg->bit_offset != NATIVE_CSTATE_BEYOND_HALT)
124 return -1;
125
126 percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
127 percpu_entry->states[cx->index].eax = 0;
128 percpu_entry->states[cx->index].ecx = 0;
129
130 /* Make sure we are running on right CPU */
131
132 retval = work_on_cpu(cpu, acpi_processor_ffh_cstate_probe_cpu, cx);
133 if (retval == 0) {
134 /* Use the hint in CST */
135 percpu_entry->states[cx->index].eax = cx->address;
136 percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK;
137 }
134 return retval; 138 return retval;
135} 139}
136EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); 140EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);