idle.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <phoenix@bsemi.com>
  10. * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
  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. #include <linux/errno.h>
  21. #include <linux/sched.h>
  22. #include <linux/kernel.h>
  23. #include <linux/mm.h>
  24. #include <linux/smp.h>
  25. #include <linux/stddef.h>
  26. #include <linux/unistd.h>
  27. #include <linux/ptrace.h>
  28. #include <linux/slab.h>
  29. #include <linux/tick.h>
  30. #include <asm/pgtable.h>
  31. #include <asm/uaccess.h>
  32. #include <asm/system.h>
  33. #include <asm/io.h>
  34. #include <asm/processor.h>
  35. #include <asm/mmu.h>
  36. #include <asm/cache.h>
  37. #include <asm/pgalloc.h>
  38. void (*powersave) (void) = NULL;
  39. static inline void pm_idle(void)
  40. {
  41. barrier();
  42. }
  43. void cpu_idle(void)
  44. {
  45. set_thread_flag(TIF_POLLING_NRFLAG);
  46. /* endless idle loop with no priority at all */
  47. while (1) {
  48. tick_nohz_idle_enter();
  49. rcu_idle_enter();
  50. while (!need_resched()) {
  51. check_pgt_cache();
  52. rmb();
  53. clear_thread_flag(TIF_POLLING_NRFLAG);
  54. local_irq_disable();
  55. /* Don't trace irqs off for idle */
  56. stop_critical_timings();
  57. if (!need_resched() && powersave != NULL)
  58. powersave();
  59. start_critical_timings();
  60. local_irq_enable();
  61. set_thread_flag(TIF_POLLING_NRFLAG);
  62. }
  63. rcu_idle_exit();
  64. tick_nohz_idle_exit();
  65. preempt_enable_no_resched();
  66. schedule();
  67. preempt_disable();
  68. }
  69. }