poll_state.c 877 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * poll_state.c - Polling idle state
  3. *
  4. * This file is released under the GPLv2.
  5. */
  6. #include <linux/cpuidle.h>
  7. #include <linux/sched.h>
  8. #include <linux/sched/idle.h>
  9. static int __cpuidle poll_idle(struct cpuidle_device *dev,
  10. struct cpuidle_driver *drv, int index)
  11. {
  12. local_irq_enable();
  13. if (!current_set_polling_and_test()) {
  14. while (!need_resched())
  15. cpu_relax();
  16. }
  17. current_clr_polling();
  18. return index;
  19. }
  20. void cpuidle_poll_state_init(struct cpuidle_driver *drv)
  21. {
  22. struct cpuidle_state *state = &drv->states[0];
  23. snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
  24. snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
  25. state->exit_latency = 0;
  26. state->target_residency = 0;
  27. state->power_usage = -1;
  28. state->enter = poll_idle;
  29. state->disabled = false;
  30. state->flags = CPUIDLE_FLAG_POLLING;
  31. }
  32. EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);