[PATCH] ppc64: pSeries idle fixups
[deliverable/linux.git] / arch / ppc64 / kernel / idle.c
CommitLineData
1da177e4
LT
1/*
2 * Idle daemon for PowerPC. Idle daemon will handle any action
3 * that needs to be taken when the system becomes idle.
4 *
5 * Originally Written by Cort Dougan (cort@cs.nmt.edu)
6 *
7 * iSeries supported added by Mike Corrigan <mikejc@us.ibm.com>
8 *
9 * Additional shared processor, SMT, and firmware support
10 * Copyright (c) 2003 Dave Engebretsen <engebret@us.ibm.com>
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17
18#include <linux/config.h>
19#include <linux/sched.h>
20#include <linux/kernel.h>
21#include <linux/smp.h>
22#include <linux/cpu.h>
23#include <linux/module.h>
24#include <linux/sysctl.h>
25#include <linux/smp.h>
26
27#include <asm/system.h>
28#include <asm/processor.h>
29#include <asm/mmu.h>
30#include <asm/cputable.h>
31#include <asm/time.h>
32#include <asm/iSeries/HvCall.h>
33#include <asm/iSeries/ItLpQueue.h>
34#include <asm/plpar_wrappers.h>
35#include <asm/systemcfg.h>
fd899c0c 36#include <asm/machdep.h>
1da177e4
LT
37
38extern void power4_idle(void);
39
fd899c0c 40int default_idle(void)
1da177e4
LT
41{
42 long oldval;
43 unsigned int cpu = smp_processor_id();
44
45 while (1) {
46 oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED);
47
48 if (!oldval) {
49 set_thread_flag(TIF_POLLING_NRFLAG);
50
51 while (!need_resched() && !cpu_is_offline(cpu)) {
52 barrier();
53 /*
54 * Go into low thread priority and possibly
55 * low power mode.
56 */
57 HMT_low();
58 HMT_very_low();
59 }
60
61 HMT_medium();
62 clear_thread_flag(TIF_POLLING_NRFLAG);
63 } else {
64 set_need_resched();
65 }
66
67 schedule();
68 if (cpu_is_offline(cpu) && system_state == SYSTEM_RUNNING)
69 cpu_die();
70 }
71
72 return 0;
73}
74
fd899c0c 75int native_idle(void)
1da177e4
LT
76{
77 while(1) {
78 /* check CPU type here */
79 if (!need_resched())
80 power4_idle();
81 if (need_resched())
82 schedule();
83
39c715b7 84 if (cpu_is_offline(raw_smp_processor_id()) &&
1da177e4
LT
85 system_state == SYSTEM_RUNNING)
86 cpu_die();
87 }
88 return 0;
89}
90
1da177e4
LT
91void cpu_idle(void)
92{
fd899c0c
ME
93 BUG_ON(NULL == ppc_md.idle_loop);
94 ppc_md.idle_loop();
1da177e4
LT
95}
96
97int powersave_nap;
98
99#ifdef CONFIG_SYSCTL
100/*
101 * Register the sysctl to set/clear powersave_nap.
102 */
103static ctl_table powersave_nap_ctl_table[]={
104 {
105 .ctl_name = KERN_PPC_POWERSAVE_NAP,
106 .procname = "powersave-nap",
107 .data = &powersave_nap,
108 .maxlen = sizeof(int),
109 .mode = 0644,
110 .proc_handler = &proc_dointvec,
111 },
112 { 0, },
113};
114static ctl_table powersave_nap_sysctl_root[] = {
115 { 1, "kernel", NULL, 0, 0755, powersave_nap_ctl_table, },
116 { 0,},
117};
118
119static int __init
120register_powersave_nap_sysctl(void)
121{
122 register_sysctl_table(powersave_nap_sysctl_root, 0);
123
124 return 0;
125}
126__initcall(register_powersave_nap_sysctl);
127#endif
This page took 0.130898 seconds and 5 git commands to generate.