Blame view
drivers/cpuidle/poll_state.c
1.27 KB
55716d264
|
1 |
// SPDX-License-Identifier: GPL-2.0-only |
34c2f65b7
|
2 3 |
/* * poll_state.c - Polling idle state |
34c2f65b7
|
4 5 6 7 |
*/ #include <linux/cpuidle.h> #include <linux/sched.h> |
a37b969a6
|
8 |
#include <linux/sched/clock.h> |
34c2f65b7
|
9 |
#include <linux/sched/idle.h> |
4dc2375c1
|
10 |
#define POLL_IDLE_RELAX_COUNT 200 |
a37b969a6
|
11 |
|
34c2f65b7
|
12 13 14 |
static int __cpuidle poll_idle(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { |
a37b969a6
|
15 |
u64 time_start = local_clock(); |
5f26bdceb
|
16 |
dev->poll_time_limit = false; |
34c2f65b7
|
17 18 |
local_irq_enable(); if (!current_set_polling_and_test()) { |
4dc2375c1
|
19 |
unsigned int loop_count = 0; |
259231a04
|
20 |
u64 limit; |
800fb34a9
|
21 |
|
259231a04
|
22 |
limit = cpuidle_poll_time(drv, dev); |
4dc2375c1
|
23 |
|
a37b969a6
|
24 |
while (!need_resched()) { |
34c2f65b7
|
25 |
cpu_relax(); |
4dc2375c1
|
26 27 |
if (loop_count++ < POLL_IDLE_RELAX_COUNT) continue; |
a37b969a6
|
28 |
|
4dc2375c1
|
29 |
loop_count = 0; |
01bad1c68
|
30 |
if (local_clock() - time_start > limit) { |
5f26bdceb
|
31 |
dev->poll_time_limit = true; |
a37b969a6
|
32 |
break; |
5f26bdceb
|
33 |
} |
a37b969a6
|
34 |
} |
34c2f65b7
|
35 36 37 38 39 |
} current_clr_polling(); return index; } |
1b39e3f81
|
40 |
void cpuidle_poll_state_init(struct cpuidle_driver *drv) |
34c2f65b7
|
41 42 43 44 45 46 47 |
{ struct cpuidle_state *state = &drv->states[0]; snprintf(state->name, CPUIDLE_NAME_LEN, "POLL"); snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE"); state->exit_latency = 0; state->target_residency = 0; |
c1d51f684
|
48 49 |
state->exit_latency_ns = 0; state->target_residency_ns = 0; |
34c2f65b7
|
50 51 |
state->power_usage = -1; state->enter = poll_idle; |
34c2f65b7
|
52 53 |
state->flags = CPUIDLE_FLAG_POLLING; } |
1b39e3f81
|
54 |
EXPORT_SYMBOL_GPL(cpuidle_poll_state_init); |