aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2008-06-09 12:35:28 -0400
committerIngo Molnar <mingo@elte.hu>2008-06-10 09:52:29 -0400
commit00dba56465228825ea806e3a7fc0aa6bba7bdc6c (patch)
treeaa1763b72f8396672d3e4697c6327c6d3d5dee0c /arch/x86/kernel
parent09fd4b4ef5bc7e5222c13acec1bee8cd252fb63f (diff)
x86: move more common idle functions/variables to process.c
more unification. Should cause no change in functionality. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/process.c70
-rw-r--r--arch/x86/kernel/process_32.c54
-rw-r--r--arch/x86/kernel/process_64.c28
3 files changed, 70 insertions, 82 deletions
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index fe415ba606e0..9fea14607dfe 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -45,6 +45,76 @@ void arch_task_cache_init(void)
45 SLAB_PANIC, NULL); 45 SLAB_PANIC, NULL);
46} 46}
47 47
48/*
49 * Idle related variables and functions
50 */
51unsigned long boot_option_idle_override = 0;
52EXPORT_SYMBOL(boot_option_idle_override);
53
54/*
55 * Powermanagement idle function, if any..
56 */
57void (*pm_idle)(void);
58EXPORT_SYMBOL(pm_idle);
59
60#ifdef CONFIG_X86_32
61/*
62 * This halt magic was a workaround for ancient floppy DMA
63 * wreckage. It should be safe to remove.
64 */
65static int hlt_counter;
66void disable_hlt(void)
67{
68 hlt_counter++;
69}
70EXPORT_SYMBOL(disable_hlt);
71
72void enable_hlt(void)
73{
74 hlt_counter--;
75}
76EXPORT_SYMBOL(enable_hlt);
77
78static inline int hlt_use_halt(void)
79{
80 return (!hlt_counter && boot_cpu_data.hlt_works_ok);
81}
82#else
83static inline int hlt_use_halt(void)
84{
85 return 1;
86}
87#endif
88
89/*
90 * We use this if we don't have any better
91 * idle routine..
92 */
93void default_idle(void)
94{
95 if (hlt_use_halt()) {
96 current_thread_info()->status &= ~TS_POLLING;
97 /*
98 * TS_POLLING-cleared state must be visible before we
99 * test NEED_RESCHED:
100 */
101 smp_mb();
102
103 if (!need_resched())
104 safe_halt(); /* enables interrupts racelessly */
105 else
106 local_irq_enable();
107 current_thread_info()->status |= TS_POLLING;
108 } else {
109 local_irq_enable();
110 /* loop is done by the caller */
111 cpu_relax();
112 }
113}
114#ifdef CONFIG_APM_MODULE
115EXPORT_SYMBOL(default_idle);
116#endif
117
48static void do_nothing(void *unused) 118static void do_nothing(void *unused)
49{ 119{
50} 120}
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index ee4ab461c50d..ae4020486a97 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -58,11 +58,6 @@
58 58
59asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 59asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
60 60
61static int hlt_counter;
62
63unsigned long boot_option_idle_override = 0;
64EXPORT_SYMBOL(boot_option_idle_override);
65
66DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; 61DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
67EXPORT_PER_CPU_SYMBOL(current_task); 62EXPORT_PER_CPU_SYMBOL(current_task);
68 63
@@ -77,55 +72,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
77 return ((unsigned long *)tsk->thread.sp)[3]; 72 return ((unsigned long *)tsk->thread.sp)[3];
78} 73}
79 74
80/*
81 * Powermanagement idle function, if any..
82 */
83void (*pm_idle)(void);
84EXPORT_SYMBOL(pm_idle);
85
86void disable_hlt(void)
87{
88 hlt_counter++;
89}
90
91EXPORT_SYMBOL(disable_hlt);
92
93void enable_hlt(void)
94{
95 hlt_counter--;
96}
97
98EXPORT_SYMBOL(enable_hlt);
99
100/*
101 * We use this if we don't have any better
102 * idle routine..
103 */
104void default_idle(void)
105{
106 if (!hlt_counter && boot_cpu_data.hlt_works_ok) {
107 current_thread_info()->status &= ~TS_POLLING;
108 /*
109 * TS_POLLING-cleared state must be visible before we
110 * test NEED_RESCHED:
111 */
112 smp_mb();
113
114 if (!need_resched())
115 safe_halt(); /* enables interrupts racelessly */
116 else
117 local_irq_enable();
118 current_thread_info()->status |= TS_POLLING;
119 } else {
120 local_irq_enable();
121 /* loop is done by the caller */
122 cpu_relax();
123 }
124}
125#ifdef CONFIG_APM_MODULE
126EXPORT_SYMBOL(default_idle);
127#endif
128
129#ifdef CONFIG_HOTPLUG_CPU 75#ifdef CONFIG_HOTPLUG_CPU
130#include <asm/nmi.h> 76#include <asm/nmi.h>
131/* We don't actually take CPU down, just spin without interrupts. */ 77/* We don't actually take CPU down, just spin without interrupts. */
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index db3d89a04399..9fb3a6fe863b 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -56,15 +56,6 @@ asmlinkage extern void ret_from_fork(void);
56 56
57unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; 57unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED;
58 58
59unsigned long boot_option_idle_override = 0;
60EXPORT_SYMBOL(boot_option_idle_override);
61
62/*
63 * Powermanagement idle function, if any..
64 */
65void (*pm_idle)(void);
66EXPORT_SYMBOL(pm_idle);
67
68static ATOMIC_NOTIFIER_HEAD(idle_notifier); 59static ATOMIC_NOTIFIER_HEAD(idle_notifier);
69 60
70void idle_notifier_register(struct notifier_block *n) 61void idle_notifier_register(struct notifier_block *n)
@@ -94,25 +85,6 @@ void exit_idle(void)
94 __exit_idle(); 85 __exit_idle();
95} 86}
96 87
97/*
98 * We use this if we don't have any better
99 * idle routine..
100 */
101void default_idle(void)
102{
103 current_thread_info()->status &= ~TS_POLLING;
104 /*
105 * TS_POLLING-cleared state must be visible before we
106 * test NEED_RESCHED:
107 */
108 smp_mb();
109 if (!need_resched())
110 safe_halt(); /* enables interrupts racelessly */
111 else
112 local_irq_enable();
113 current_thread_info()->status |= TS_POLLING;
114}
115
116#ifdef CONFIG_HOTPLUG_CPU 88#ifdef CONFIG_HOTPLUG_CPU
117DECLARE_PER_CPU(int, cpu_state); 89DECLARE_PER_CPU(int, cpu_state);
118 90