aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2012-07-05 09:23:25 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-07-05 16:37:47 -0400
commit25ac77613aa8fca131599705e3d7da2a0eaa06a0 (patch)
tree441f714bf32592797d1cf4c6c375e47e324ffded
parent6e797a078824b30afbfae6cc4b1c2b21c51761ef (diff)
ACPI: intel_idle : break dependency between modules
When the system is booted with some cpus offline, the idle driver is not initialized. When a cpu is set online, the acpi code call the intel idle init function. Unfortunately this code introduce a dependency between intel_idle and acpi. This patch is intended to remove this dependency by using the notifier of intel_idle. This patch has the benefit of encapsulating the intel_idle driver and remove some exported functions. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Acked-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-rw-r--r--drivers/acpi/processor_driver.c7
-rw-r--r--drivers/idle/intel_idle.c41
-rw-r--r--include/linux/cpuidle.h7
3 files changed, 27 insertions, 28 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index 0734086537b8..8648b29f6eec 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -427,18 +427,11 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
427 * Initialize missing things 427 * Initialize missing things
428 */ 428 */
429 if (pr->flags.need_hotplug_init) { 429 if (pr->flags.need_hotplug_init) {
430 struct cpuidle_driver *idle_driver =
431 cpuidle_get_driver();
432
433 printk(KERN_INFO "Will online and init hotplugged " 430 printk(KERN_INFO "Will online and init hotplugged "
434 "CPU: %d\n", pr->id); 431 "CPU: %d\n", pr->id);
435 WARN(acpi_processor_start(pr), "Failed to start CPU:" 432 WARN(acpi_processor_start(pr), "Failed to start CPU:"
436 " %d\n", pr->id); 433 " %d\n", pr->id);
437 pr->flags.need_hotplug_init = 0; 434 pr->flags.need_hotplug_init = 0;
438 if (idle_driver && !strcmp(idle_driver->name,
439 "intel_idle")) {
440 intel_idle_cpu_init(pr->id);
441 }
442 /* Normal CPU soft online event */ 435 /* Normal CPU soft online event */
443 } else { 436 } else {
444 acpi_processor_ppc_has_changed(pr, 0); 437 acpi_processor_ppc_has_changed(pr, 0);
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index d0f59c3f87ef..fe95d5464a02 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -96,6 +96,7 @@ static const struct idle_cpu *icpu;
96static struct cpuidle_device __percpu *intel_idle_cpuidle_devices; 96static struct cpuidle_device __percpu *intel_idle_cpuidle_devices;
97static int intel_idle(struct cpuidle_device *dev, 97static int intel_idle(struct cpuidle_device *dev,
98 struct cpuidle_driver *drv, int index); 98 struct cpuidle_driver *drv, int index);
99static int intel_idle_cpu_init(int cpu);
99 100
100static struct cpuidle_state *cpuidle_state_table; 101static struct cpuidle_state *cpuidle_state_table;
101 102
@@ -302,22 +303,35 @@ static void __setup_broadcast_timer(void *arg)
302 clockevents_notify(reason, &cpu); 303 clockevents_notify(reason, &cpu);
303} 304}
304 305
305static int setup_broadcast_cpuhp_notify(struct notifier_block *n, 306static int cpu_hotplug_notify(struct notifier_block *n,
306 unsigned long action, void *hcpu) 307 unsigned long action, void *hcpu)
307{ 308{
308 int hotcpu = (unsigned long)hcpu; 309 int hotcpu = (unsigned long)hcpu;
310 struct cpuidle_device *dev;
309 311
310 switch (action & 0xf) { 312 switch (action & 0xf) {
311 case CPU_ONLINE: 313 case CPU_ONLINE:
312 smp_call_function_single(hotcpu, __setup_broadcast_timer, 314
313 (void *)true, 1); 315 if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
316 smp_call_function_single(hotcpu, __setup_broadcast_timer,
317 (void *)true, 1);
318
319 /*
320 * Some systems can hotplug a cpu at runtime after
321 * the kernel has booted, we have to initialize the
322 * driver in this case
323 */
324 dev = per_cpu_ptr(intel_idle_cpuidle_devices, hotcpu);
325 if (!dev->registered)
326 intel_idle_cpu_init(hotcpu);
327
314 break; 328 break;
315 } 329 }
316 return NOTIFY_OK; 330 return NOTIFY_OK;
317} 331}
318 332
319static struct notifier_block setup_broadcast_notifier = { 333static struct notifier_block cpu_hotplug_notifier = {
320 .notifier_call = setup_broadcast_cpuhp_notify, 334 .notifier_call = cpu_hotplug_notify,
321}; 335};
322 336
323static void auto_demotion_disable(void *dummy) 337static void auto_demotion_disable(void *dummy)
@@ -405,10 +419,10 @@ static int intel_idle_probe(void)
405 419
406 if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */ 420 if (boot_cpu_has(X86_FEATURE_ARAT)) /* Always Reliable APIC Timer */
407 lapic_timer_reliable_states = LAPIC_TIMER_ALWAYS_RELIABLE; 421 lapic_timer_reliable_states = LAPIC_TIMER_ALWAYS_RELIABLE;
408 else { 422 else
409 on_each_cpu(__setup_broadcast_timer, (void *)true, 1); 423 on_each_cpu(__setup_broadcast_timer, (void *)true, 1);
410 register_cpu_notifier(&setup_broadcast_notifier); 424
411 } 425 register_cpu_notifier(&cpu_hotplug_notifier);
412 426
413 pr_debug(PREFIX "v" INTEL_IDLE_VERSION 427 pr_debug(PREFIX "v" INTEL_IDLE_VERSION
414 " model 0x%X\n", boot_cpu_data.x86_model); 428 " model 0x%X\n", boot_cpu_data.x86_model);
@@ -494,7 +508,7 @@ static int intel_idle_cpuidle_driver_init(void)
494 * allocate, initialize, register cpuidle_devices 508 * allocate, initialize, register cpuidle_devices
495 * @cpu: cpu/core to initialize 509 * @cpu: cpu/core to initialize
496 */ 510 */
497int intel_idle_cpu_init(int cpu) 511static int intel_idle_cpu_init(int cpu)
498{ 512{
499 int cstate; 513 int cstate;
500 struct cpuidle_device *dev; 514 struct cpuidle_device *dev;
@@ -539,7 +553,6 @@ int intel_idle_cpu_init(int cpu)
539 553
540 return 0; 554 return 0;
541} 555}
542EXPORT_SYMBOL_GPL(intel_idle_cpu_init);
543 556
544static int __init intel_idle_init(void) 557static int __init intel_idle_init(void)
545{ 558{
@@ -581,10 +594,10 @@ static void __exit intel_idle_exit(void)
581 intel_idle_cpuidle_devices_uninit(); 594 intel_idle_cpuidle_devices_uninit();
582 cpuidle_unregister_driver(&intel_idle_driver); 595 cpuidle_unregister_driver(&intel_idle_driver);
583 596
584 if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE) { 597
598 if (lapic_timer_reliable_states != LAPIC_TIMER_ALWAYS_RELIABLE)
585 on_each_cpu(__setup_broadcast_timer, (void *)false, 1); 599 on_each_cpu(__setup_broadcast_timer, (void *)false, 1);
586 unregister_cpu_notifier(&setup_broadcast_notifier); 600 unregister_cpu_notifier(&cpu_hotplug_notifier);
587 }
588 601
589 return; 602 return;
590} 603}
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 27cfced7b57b..524bb6f3b6c4 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -206,14 +206,7 @@ struct cpuidle_governor {
206extern int cpuidle_register_governor(struct cpuidle_governor *gov); 206extern int cpuidle_register_governor(struct cpuidle_governor *gov);
207extern void cpuidle_unregister_governor(struct cpuidle_governor *gov); 207extern void cpuidle_unregister_governor(struct cpuidle_governor *gov);
208 208
209#ifdef CONFIG_INTEL_IDLE
210extern int intel_idle_cpu_init(int cpu);
211#else 209#else
212static inline int intel_idle_cpu_init(int cpu) { return -1; }
213#endif
214
215#else
216static inline int intel_idle_cpu_init(int cpu) { return -1; }
217 210
218static inline int cpuidle_register_governor(struct cpuidle_governor *gov) 211static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
219{return 0;} 212{return 0;}