Skip to content

Commit 1b39e3f

Browse files
committed
cpuidle: Make drivers initialize polling state
Make the drivers that want to include the polling state into their states table initialize it explicitly and drop the initialization of it (which in fact is conditional, but that is not obvious from the code) from the core. Signed-off-by: Rafael J. Wysocki <[email protected]> Tested-by: Sudeep Holla <[email protected]> Acked-by: Daniel Lezcano <[email protected]>
1 parent 34c2f65 commit 1b39e3f

File tree

5 files changed

+13
-6
lines changed

5 files changed

+13
-6
lines changed

drivers/acpi/processor_idle.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,14 +842,21 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,
842842

843843
static int acpi_processor_setup_cstates(struct acpi_processor *pr)
844844
{
845-
int i, count = ACPI_IDLE_STATE_START;
845+
int i, count;
846846
struct acpi_processor_cx *cx;
847847
struct cpuidle_state *state;
848848
struct cpuidle_driver *drv = &acpi_idle_driver;
849849

850850
if (max_cstate == 0)
851851
max_cstate = 1;
852852

853+
if (IS_ENABLED(CONFIG_ARCH_HAS_CPU_RELAX)) {
854+
cpuidle_poll_state_init(drv);
855+
count = 1;
856+
} else {
857+
count = 0;
858+
}
859+
853860
for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
854861
cx = &pr->power.states[i];
855862

drivers/cpuidle/driver.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
216216
on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer,
217217
(void *)1, 1);
218218

219-
poll_idle_init(drv);
220-
221219
return 0;
222220
}
223221

drivers/cpuidle/poll_state.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
2121
return index;
2222
}
2323

24-
void poll_idle_init(struct cpuidle_driver *drv)
24+
void cpuidle_poll_state_init(struct cpuidle_driver *drv)
2525
{
2626
struct cpuidle_state *state = &drv->states[0];
2727

@@ -34,3 +34,4 @@ void poll_idle_init(struct cpuidle_driver *drv)
3434
state->disabled = false;
3535
state->flags = CPUIDLE_FLAG_POLLING;
3636
}
37+
EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);

drivers/idle/intel_idle.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,7 @@ static void __init intel_idle_cpuidle_driver_init(void)
13311331

13321332
intel_idle_state_table_update();
13331333

1334+
cpuidle_poll_state_init(drv);
13341335
drv->state_count = 1;
13351336

13361337
for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {

include/linux/cpuidle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ static inline void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev,
226226
#endif
227227

228228
#ifdef CONFIG_ARCH_HAS_CPU_RELAX
229-
void poll_idle_init(struct cpuidle_driver *drv);
229+
void cpuidle_poll_state_init(struct cpuidle_driver *drv);
230230
#else
231-
static void poll_idle_init(struct cpuidle_driver *drv) {}
231+
static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {}
232232
#endif
233233

234234
/******************************

0 commit comments

Comments
 (0)