Skip to content

Commit 87fa05a

Browse files
sravnborgKAGA-KOKO
authored andcommitted
sparc: Use generic idle loop
Add generic cpu_idle support sparc32: - replace call to cpu_idle() with cpu_startup_entry() - add arch_cpu_idle() sparc64: - smp_callin() now include cpu_startup_entry() call so we can skip calling cpu_idle from assembler - add arch_cpu_idle() and arch_cpu_idle_dead() Signed-off-by: Sam Ravnborg <[email protected]> Reviewed-by: "Srivatsa S. Bhat" <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Acked-by: David Miller <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 781b0e8 commit 87fa05a

File tree

7 files changed

+24
-57
lines changed

7 files changed

+24
-57
lines changed

arch/sparc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ config SPARC
3737
select GENERIC_SMP_IDLE_THREAD
3838
select GENERIC_CMOS_UPDATE
3939
select GENERIC_CLOCKEVENTS
40+
select GENERIC_IDLE_LOOP
4041
select GENERIC_STRNCPY_FROM_USER
4142
select GENERIC_STRNLEN_USER
4243
select MODULES_USE_ELF_RELA

arch/sparc/kernel/hvtramp.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ hv_cpu_startup:
128128

129129
call smp_callin
130130
nop
131-
call cpu_idle
132-
mov 0, %o0
131+
133132
call cpu_panic
134133
nop
135134

arch/sparc/kernel/process_32.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,12 @@ extern void fpsave(unsigned long *, unsigned long *, void *, unsigned long *);
6464
struct task_struct *last_task_used_math = NULL;
6565
struct thread_info *current_set[NR_CPUS];
6666

67-
/*
68-
* the idle loop on a Sparc... ;)
69-
*/
70-
void cpu_idle(void)
67+
/* Idle loop support. */
68+
void arch_cpu_idle(void)
7169
{
72-
set_thread_flag(TIF_POLLING_NRFLAG);
73-
74-
/* endless idle loop with no priority at all */
75-
for (;;) {
76-
while (!need_resched()) {
77-
if (sparc_idle)
78-
(*sparc_idle)();
79-
else
80-
cpu_relax();
81-
}
82-
schedule_preempt_disabled();
83-
}
70+
if (sparc_idle)
71+
(*sparc_idle)();
72+
local_irq_enable();
8473
}
8574

8675
/* XXX cli/sti -> local_irq_xxx here, check this works once SMP is fixed. */

arch/sparc/kernel/process_64.c

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -52,28 +52,25 @@
5252

5353
#include "kstack.h"
5454

55-
static void sparc64_yield(int cpu)
55+
/* Idle loop support on sparc64. */
56+
void arch_cpu_idle(void)
5657
{
5758
if (tlb_type != hypervisor) {
5859
touch_nmi_watchdog();
59-
return;
60-
}
61-
62-
clear_thread_flag(TIF_POLLING_NRFLAG);
63-
smp_mb__after_clear_bit();
64-
65-
while (!need_resched() && !cpu_is_offline(cpu)) {
60+
} else {
6661
unsigned long pstate;
6762

68-
/* Disable interrupts. */
63+
/* The sun4v sleeping code requires that we have PSTATE.IE cleared over
64+
* the cpu sleep hypervisor call.
65+
*/
6966
__asm__ __volatile__(
7067
"rdpr %%pstate, %0\n\t"
7168
"andn %0, %1, %0\n\t"
7269
"wrpr %0, %%g0, %%pstate"
7370
: "=&r" (pstate)
7471
: "i" (PSTATE_IE));
7572

76-
if (!need_resched() && !cpu_is_offline(cpu))
73+
if (!need_resched() && !cpu_is_offline(smp_processor_id()))
7774
sun4v_cpu_yield();
7875

7976
/* Re-enable interrupts. */
@@ -84,36 +81,16 @@ static void sparc64_yield(int cpu)
8481
: "=&r" (pstate)
8582
: "i" (PSTATE_IE));
8683
}
87-
88-
set_thread_flag(TIF_POLLING_NRFLAG);
84+
local_irq_enable();
8985
}
9086

91-
/* The idle loop on sparc64. */
92-
void cpu_idle(void)
93-
{
94-
int cpu = smp_processor_id();
95-
96-
set_thread_flag(TIF_POLLING_NRFLAG);
97-
98-
while(1) {
99-
tick_nohz_idle_enter();
100-
rcu_idle_enter();
101-
102-
while (!need_resched() && !cpu_is_offline(cpu))
103-
sparc64_yield(cpu);
104-
105-
rcu_idle_exit();
106-
tick_nohz_idle_exit();
107-
10887
#ifdef CONFIG_HOTPLUG_CPU
109-
if (cpu_is_offline(cpu)) {
110-
sched_preempt_enable_no_resched();
111-
cpu_play_dead();
112-
}
113-
#endif
114-
schedule_preempt_disabled();
115-
}
88+
void arch_cpu_idle_dead()
89+
{
90+
sched_preempt_enable_no_resched();
91+
cpu_play_dead();
11692
}
93+
#endif
11794

11895
#ifdef CONFIG_COMPAT
11996
static void show_regwindow32(struct pt_regs *regs)

arch/sparc/kernel/smp_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ void __cpuinit sparc_start_secondary(void *arg)
369369
local_irq_enable();
370370

371371
wmb();
372-
cpu_idle();
372+
cpu_startup_entry(CPUHP_ONLINE);
373373

374374
/* We should never reach here! */
375375
BUG();

arch/sparc/kernel/smp_64.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ void __cpuinit smp_callin(void)
127127

128128
/* idle thread is expected to have preempt disabled */
129129
preempt_disable();
130+
131+
cpu_startup_entry(CPUHP_ONLINE);
130132
}
131133

132134
void cpu_panic(void)

arch/sparc/kernel/trampoline_64.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,7 @@ after_lock_tlb:
407407

408408
call smp_callin
409409
nop
410-
call cpu_idle
411-
mov 0, %o0
410+
412411
call cpu_panic
413412
nop
414413
1: b,a,pt %xcc, 1b

0 commit comments

Comments
 (0)