Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
idle.c
Go to the documentation of this file.
1 /*
2  * OpenRISC idle.c
3  *
4  * Linux architectural port borrowing liberally from similar works of
5  * others. All original copyrights apply as per the original source
6  * declaration.
7  *
8  * Modifications for the OpenRISC architecture:
9  * Copyright (C) 2003 Matjaz Breskvar <[email protected]>
10  * Copyright (C) 2010-2011 Jonas Bonn <[email protected]>
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  * Idle daemon for or32. Idle daemon will handle any action
18  * that needs to be taken when the system becomes idle.
19  */
20 
21 #include <linux/errno.h>
22 #include <linux/sched.h>
23 #include <linux/kernel.h>
24 #include <linux/mm.h>
25 #include <linux/smp.h>
26 #include <linux/stddef.h>
27 #include <linux/unistd.h>
28 #include <linux/ptrace.h>
29 #include <linux/slab.h>
30 #include <linux/tick.h>
31 
32 #include <asm/pgtable.h>
33 #include <asm/uaccess.h>
34 #include <asm/io.h>
35 #include <asm/processor.h>
36 #include <asm/mmu.h>
37 #include <asm/cache.h>
38 #include <asm/pgalloc.h>
39 
41 
42 static inline void pm_idle(void)
43 {
44  barrier();
45 }
46 
47 void cpu_idle(void)
48 {
49  set_thread_flag(TIF_POLLING_NRFLAG);
50 
51  /* endless idle loop with no priority at all */
52  while (1) {
53  tick_nohz_idle_enter();
55 
56  while (!need_resched()) {
58  rmb();
59 
60  clear_thread_flag(TIF_POLLING_NRFLAG);
61 
63  /* Don't trace irqs off for idle */
65  if (!need_resched() && powersave != NULL)
66  powersave();
69  set_thread_flag(TIF_POLLING_NRFLAG);
70  }
71 
72  rcu_idle_exit();
73  tick_nohz_idle_exit();
75  schedule();
77  }
78 }