diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2008-06-09 12:35:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-06-10 09:52:29 -0400 |
commit | 00dba56465228825ea806e3a7fc0aa6bba7bdc6c (patch) | |
tree | aa1763b72f8396672d3e4697c6327c6d3d5dee0c /arch/x86/kernel | |
parent | 09fd4b4ef5bc7e5222c13acec1bee8cd252fb63f (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.c | 70 | ||||
-rw-r--r-- | arch/x86/kernel/process_32.c | 54 | ||||
-rw-r--r-- | arch/x86/kernel/process_64.c | 28 |
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 | */ | ||
51 | unsigned long boot_option_idle_override = 0; | ||
52 | EXPORT_SYMBOL(boot_option_idle_override); | ||
53 | |||
54 | /* | ||
55 | * Powermanagement idle function, if any.. | ||
56 | */ | ||
57 | void (*pm_idle)(void); | ||
58 | EXPORT_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 | */ | ||
65 | static int hlt_counter; | ||
66 | void disable_hlt(void) | ||
67 | { | ||
68 | hlt_counter++; | ||
69 | } | ||
70 | EXPORT_SYMBOL(disable_hlt); | ||
71 | |||
72 | void enable_hlt(void) | ||
73 | { | ||
74 | hlt_counter--; | ||
75 | } | ||
76 | EXPORT_SYMBOL(enable_hlt); | ||
77 | |||
78 | static inline int hlt_use_halt(void) | ||
79 | { | ||
80 | return (!hlt_counter && boot_cpu_data.hlt_works_ok); | ||
81 | } | ||
82 | #else | ||
83 | static 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 | */ | ||
93 | void 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 | ||
115 | EXPORT_SYMBOL(default_idle); | ||
116 | #endif | ||
117 | |||
48 | static void do_nothing(void *unused) | 118 | static 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 | ||
59 | asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); | 59 | asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); |
60 | 60 | ||
61 | static int hlt_counter; | ||
62 | |||
63 | unsigned long boot_option_idle_override = 0; | ||
64 | EXPORT_SYMBOL(boot_option_idle_override); | ||
65 | |||
66 | DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; | 61 | DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task; |
67 | EXPORT_PER_CPU_SYMBOL(current_task); | 62 | EXPORT_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 | */ | ||
83 | void (*pm_idle)(void); | ||
84 | EXPORT_SYMBOL(pm_idle); | ||
85 | |||
86 | void disable_hlt(void) | ||
87 | { | ||
88 | hlt_counter++; | ||
89 | } | ||
90 | |||
91 | EXPORT_SYMBOL(disable_hlt); | ||
92 | |||
93 | void enable_hlt(void) | ||
94 | { | ||
95 | hlt_counter--; | ||
96 | } | ||
97 | |||
98 | EXPORT_SYMBOL(enable_hlt); | ||
99 | |||
100 | /* | ||
101 | * We use this if we don't have any better | ||
102 | * idle routine.. | ||
103 | */ | ||
104 | void 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 | ||
126 | EXPORT_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 | ||
57 | unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; | 57 | unsigned long kernel_thread_flags = CLONE_VM | CLONE_UNTRACED; |
58 | 58 | ||
59 | unsigned long boot_option_idle_override = 0; | ||
60 | EXPORT_SYMBOL(boot_option_idle_override); | ||
61 | |||
62 | /* | ||
63 | * Powermanagement idle function, if any.. | ||
64 | */ | ||
65 | void (*pm_idle)(void); | ||
66 | EXPORT_SYMBOL(pm_idle); | ||
67 | |||
68 | static ATOMIC_NOTIFIER_HEAD(idle_notifier); | 59 | static ATOMIC_NOTIFIER_HEAD(idle_notifier); |
69 | 60 | ||
70 | void idle_notifier_register(struct notifier_block *n) | 61 | void 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 | */ | ||
101 | void 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 |
117 | DECLARE_PER_CPU(int, cpu_state); | 89 | DECLARE_PER_CPU(int, cpu_state); |
118 | 90 | ||