diff options
Diffstat (limited to 'arch/i386')
| -rw-r--r-- | arch/i386/kernel/acpi/boot.c | 10 | ||||
| -rw-r--r-- | arch/i386/kernel/acpi/cstate.c | 122 | ||||
| -rw-r--r-- | arch/i386/kernel/process.c | 22 |
3 files changed, 141 insertions, 13 deletions
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 92f79cdd9a48..ab974ff97073 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c | |||
| @@ -332,7 +332,7 @@ acpi_parse_ioapic(acpi_table_entry_header * header, const unsigned long end) | |||
| 332 | /* | 332 | /* |
| 333 | * Parse Interrupt Source Override for the ACPI SCI | 333 | * Parse Interrupt Source Override for the ACPI SCI |
| 334 | */ | 334 | */ |
| 335 | static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) | 335 | static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigger) |
| 336 | { | 336 | { |
| 337 | if (trigger == 0) /* compatible SCI trigger is level */ | 337 | if (trigger == 0) /* compatible SCI trigger is level */ |
| 338 | trigger = 3; | 338 | trigger = 3; |
| @@ -352,13 +352,13 @@ static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) | |||
| 352 | * If GSI is < 16, this will update its flags, | 352 | * If GSI is < 16, this will update its flags, |
| 353 | * else it will create a new mp_irqs[] entry. | 353 | * else it will create a new mp_irqs[] entry. |
| 354 | */ | 354 | */ |
| 355 | mp_override_legacy_irq(gsi, polarity, trigger, gsi); | 355 | mp_override_legacy_irq(bus_irq, polarity, trigger, gsi); |
| 356 | 356 | ||
| 357 | /* | 357 | /* |
| 358 | * stash over-ride to indicate we've been here | 358 | * stash over-ride to indicate we've been here |
| 359 | * and for later update of acpi_fadt | 359 | * and for later update of acpi_fadt |
| 360 | */ | 360 | */ |
| 361 | acpi_sci_override_gsi = gsi; | 361 | acpi_sci_override_gsi = bus_irq; |
| 362 | return; | 362 | return; |
| 363 | } | 363 | } |
| 364 | 364 | ||
| @@ -376,7 +376,7 @@ acpi_parse_int_src_ovr(acpi_table_entry_header * header, | |||
| 376 | acpi_table_print_madt_entry(header); | 376 | acpi_table_print_madt_entry(header); |
| 377 | 377 | ||
| 378 | if (intsrc->bus_irq == acpi_fadt.sci_int) { | 378 | if (intsrc->bus_irq == acpi_fadt.sci_int) { |
| 379 | acpi_sci_ioapic_setup(intsrc->global_irq, | 379 | acpi_sci_ioapic_setup(intsrc->bus_irq, intsrc->global_irq, |
| 380 | intsrc->flags.polarity, | 380 | intsrc->flags.polarity, |
| 381 | intsrc->flags.trigger); | 381 | intsrc->flags.trigger); |
| 382 | return 0; | 382 | return 0; |
| @@ -879,7 +879,7 @@ static int __init acpi_parse_madt_ioapic_entries(void) | |||
| 879 | * pretend we got one so we can set the SCI flags. | 879 | * pretend we got one so we can set the SCI flags. |
| 880 | */ | 880 | */ |
| 881 | if (!acpi_sci_override_gsi) | 881 | if (!acpi_sci_override_gsi) |
| 882 | acpi_sci_ioapic_setup(acpi_fadt.sci_int, 0, 0); | 882 | acpi_sci_ioapic_setup(acpi_fadt.sci_int, acpi_fadt.sci_int, 0, 0); |
| 883 | 883 | ||
| 884 | /* Fill in identity legacy mapings where no override */ | 884 | /* Fill in identity legacy mapings where no override */ |
| 885 | mp_config_acpi_legacy_irqs(); | 885 | mp_config_acpi_legacy_irqs(); |
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c index 25db49ef1770..20563e52c622 100644 --- a/arch/i386/kernel/acpi/cstate.c +++ b/arch/i386/kernel/acpi/cstate.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
| 11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
| 12 | #include <linux/acpi.h> | 12 | #include <linux/acpi.h> |
| 13 | #include <linux/cpu.h> | ||
| 13 | 14 | ||
| 14 | #include <acpi/processor.h> | 15 | #include <acpi/processor.h> |
| 15 | #include <asm/acpi.h> | 16 | #include <asm/acpi.h> |
| @@ -41,5 +42,124 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, | |||
| 41 | flags->bm_check = 1; | 42 | flags->bm_check = 1; |
| 42 | } | 43 | } |
| 43 | } | 44 | } |
| 44 | |||
| 45 | EXPORT_SYMBOL(acpi_processor_power_init_bm_check); | 45 | EXPORT_SYMBOL(acpi_processor_power_init_bm_check); |
| 46 | |||
| 47 | /* The code below handles cstate entry with monitor-mwait pair on Intel*/ | ||
| 48 | |||
| 49 | struct cstate_entry_s { | ||
| 50 | struct { | ||
| 51 | unsigned int eax; | ||
| 52 | unsigned int ecx; | ||
| 53 | } states[ACPI_PROCESSOR_MAX_POWER]; | ||
| 54 | }; | ||
| 55 | static struct cstate_entry_s *cpu_cstate_entry; /* per CPU ptr */ | ||
| 56 | |||
| 57 | static short mwait_supported[ACPI_PROCESSOR_MAX_POWER]; | ||
| 58 | |||
| 59 | #define MWAIT_SUBSTATE_MASK (0xf) | ||
| 60 | #define MWAIT_SUBSTATE_SIZE (4) | ||
| 61 | |||
| 62 | #define CPUID_MWAIT_LEAF (5) | ||
| 63 | #define CPUID5_ECX_EXTENSIONS_SUPPORTED (0x1) | ||
| 64 | #define CPUID5_ECX_INTERRUPT_BREAK (0x2) | ||
| 65 | |||
| 66 | #define MWAIT_ECX_INTERRUPT_BREAK (0x1) | ||
| 67 | |||
| 68 | #define NATIVE_CSTATE_BEYOND_HALT (2) | ||
| 69 | |||
| 70 | int acpi_processor_ffh_cstate_probe(unsigned int cpu, | ||
| 71 | struct acpi_processor_cx *cx, struct acpi_power_register *reg) | ||
| 72 | { | ||
| 73 | struct cstate_entry_s *percpu_entry; | ||
| 74 | struct cpuinfo_x86 *c = cpu_data + cpu; | ||
| 75 | |||
| 76 | cpumask_t saved_mask; | ||
| 77 | int retval; | ||
| 78 | unsigned int eax, ebx, ecx, edx; | ||
| 79 | unsigned int edx_part; | ||
| 80 | unsigned int cstate_type; /* C-state type and not ACPI C-state type */ | ||
| 81 | unsigned int num_cstate_subtype; | ||
| 82 | |||
| 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(current, cpumask_of_cpu(cpu)); | ||
| 96 | if (retval) | ||
| 97 | return -1; | ||
| 98 | |||
| 99 | cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx); | ||
| 100 | |||
| 101 | /* Check whether this particular cx_type (in CST) is supported or not */ | ||
| 102 | cstate_type = (cx->address >> MWAIT_SUBSTATE_SIZE) + 1; | ||
| 103 | edx_part = edx >> (cstate_type * MWAIT_SUBSTATE_SIZE); | ||
| 104 | num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK; | ||
| 105 | |||
| 106 | retval = 0; | ||
| 107 | if (num_cstate_subtype < (cx->address & MWAIT_SUBSTATE_MASK)) { | ||
| 108 | retval = -1; | ||
| 109 | goto out; | ||
| 110 | } | ||
| 111 | |||
| 112 | /* mwait ecx extensions INTERRUPT_BREAK should be supported for C2/C3 */ | ||
| 113 | if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) || | ||
| 114 | !(ecx & CPUID5_ECX_INTERRUPT_BREAK)) { | ||
| 115 | retval = -1; | ||
| 116 | goto out; | ||
| 117 | } | ||
| 118 | percpu_entry->states[cx->index].ecx = MWAIT_ECX_INTERRUPT_BREAK; | ||
| 119 | |||
| 120 | /* Use the hint in CST */ | ||
| 121 | percpu_entry->states[cx->index].eax = cx->address; | ||
| 122 | |||
| 123 | if (!mwait_supported[cstate_type]) { | ||
| 124 | mwait_supported[cstate_type] = 1; | ||
| 125 | printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " | ||
| 126 | "state\n", cx->type); | ||
| 127 | } | ||
| 128 | |||
| 129 | out: | ||
| 130 | set_cpus_allowed(current, saved_mask); | ||
| 131 | return retval; | ||
| 132 | } | ||
| 133 | EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe); | ||
| 134 | |||
| 135 | void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx) | ||
| 136 | { | ||
| 137 | unsigned int cpu = smp_processor_id(); | ||
| 138 | struct cstate_entry_s *percpu_entry; | ||
| 139 | |||
| 140 | percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu); | ||
| 141 | mwait_idle_with_hints(percpu_entry->states[cx->index].eax, | ||
| 142 | percpu_entry->states[cx->index].ecx); | ||
| 143 | } | ||
| 144 | EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter); | ||
| 145 | |||
| 146 | static int __init ffh_cstate_init(void) | ||
| 147 | { | ||
| 148 | struct cpuinfo_x86 *c = &boot_cpu_data; | ||
| 149 | if (c->x86_vendor != X86_VENDOR_INTEL) | ||
| 150 | return -1; | ||
| 151 | |||
| 152 | cpu_cstate_entry = alloc_percpu(struct cstate_entry_s); | ||
| 153 | return 0; | ||
| 154 | } | ||
| 155 | |||
| 156 | static void __exit ffh_cstate_exit(void) | ||
| 157 | { | ||
| 158 | if (cpu_cstate_entry) { | ||
| 159 | free_percpu(cpu_cstate_entry); | ||
| 160 | cpu_cstate_entry = NULL; | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | arch_initcall(ffh_cstate_init); | ||
| 165 | __exitcall(ffh_cstate_exit); | ||
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index b0a07801d9df..57d375900afb 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c | |||
| @@ -236,20 +236,28 @@ EXPORT_SYMBOL_GPL(cpu_idle_wait); | |||
| 236 | * We execute MONITOR against need_resched and enter optimized wait state | 236 | * We execute MONITOR against need_resched and enter optimized wait state |
| 237 | * through MWAIT. Whenever someone changes need_resched, we would be woken | 237 | * through MWAIT. Whenever someone changes need_resched, we would be woken |
| 238 | * up from MWAIT (without an IPI). | 238 | * up from MWAIT (without an IPI). |
| 239 | * | ||
| 240 | * New with Core Duo processors, MWAIT can take some hints based on CPU | ||
| 241 | * capability. | ||
| 239 | */ | 242 | */ |
| 240 | static void mwait_idle(void) | 243 | void mwait_idle_with_hints(unsigned long eax, unsigned long ecx) |
| 241 | { | 244 | { |
| 242 | local_irq_enable(); | 245 | if (!need_resched()) { |
| 243 | |||
| 244 | while (!need_resched()) { | ||
| 245 | __monitor((void *)¤t_thread_info()->flags, 0, 0); | 246 | __monitor((void *)¤t_thread_info()->flags, 0, 0); |
| 246 | smp_mb(); | 247 | smp_mb(); |
| 247 | if (need_resched()) | 248 | if (!need_resched()) |
| 248 | break; | 249 | __mwait(eax, ecx); |
| 249 | __mwait(0, 0); | ||
| 250 | } | 250 | } |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | /* Default MONITOR/MWAIT with no hints, used for default C1 state */ | ||
| 254 | static void mwait_idle(void) | ||
| 255 | { | ||
| 256 | local_irq_enable(); | ||
| 257 | while (!need_resched()) | ||
| 258 | mwait_idle_with_hints(0, 0); | ||
| 259 | } | ||
| 260 | |||
| 253 | void __devinit select_idle_routine(const struct cpuinfo_x86 *c) | 261 | void __devinit select_idle_routine(const struct cpuinfo_x86 *c) |
| 254 | { | 262 | { |
| 255 | if (cpu_has(c, X86_FEATURE_MWAIT)) { | 263 | if (cpu_has(c, X86_FEATURE_MWAIT)) { |
