block: Don't revalidate bdev of hidden gendisk
[linux/fpc-iii.git] / drivers / cpuidle / poll_state.c
blob23a1b27579a54d5e35ea373421aec47597d9f241
1 /*
2 * poll_state.c - Polling idle state
4 * This file is released under the GPLv2.
5 */
7 #include <linux/cpuidle.h>
8 #include <linux/sched.h>
9 #include <linux/sched/clock.h>
10 #include <linux/sched/idle.h>
12 #define POLL_IDLE_RELAX_COUNT 200
14 static int __cpuidle poll_idle(struct cpuidle_device *dev,
15 struct cpuidle_driver *drv, int index)
17 u64 time_start = local_clock();
19 dev->poll_time_limit = false;
21 local_irq_enable();
22 if (!current_set_polling_and_test()) {
23 unsigned int loop_count = 0;
24 u64 limit = TICK_NSEC;
25 int i;
27 for (i = 1; i < drv->state_count; i++) {
28 if (drv->states[i].disabled || dev->states_usage[i].disable)
29 continue;
31 limit = (u64)drv->states[i].target_residency * NSEC_PER_USEC;
32 break;
35 while (!need_resched()) {
36 cpu_relax();
37 if (loop_count++ < POLL_IDLE_RELAX_COUNT)
38 continue;
40 loop_count = 0;
41 if (local_clock() - time_start > limit) {
42 dev->poll_time_limit = true;
43 break;
47 current_clr_polling();
49 return index;
52 void cpuidle_poll_state_init(struct cpuidle_driver *drv)
54 struct cpuidle_state *state = &drv->states[0];
56 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
57 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
58 state->exit_latency = 0;
59 state->target_residency = 0;
60 state->power_usage = -1;
61 state->enter = poll_idle;
62 state->disabled = false;
63 state->flags = CPUIDLE_FLAG_POLLING;
65 EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);