Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
cpuidle: Make drivers initialize polling state
Browse files Browse the repository at this point in the history
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 <rafael.j.wysocki@intel.com>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
  • Loading branch information
rafaeljw committed Aug 30, 2017
1 parent 34c2f65 commit 1b39e3f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion drivers/acpi/processor_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,21 @@ static int acpi_processor_setup_cpuidle_cx(struct acpi_processor *pr,

static int acpi_processor_setup_cstates(struct acpi_processor *pr)
{
int i, count = ACPI_IDLE_STATE_START;
int i, count;
struct acpi_processor_cx *cx;
struct cpuidle_state *state;
struct cpuidle_driver *drv = &acpi_idle_driver;

if (max_cstate == 0)
max_cstate = 1;

if (IS_ENABLED(CONFIG_ARCH_HAS_CPU_RELAX)) {
cpuidle_poll_state_init(drv);
count = 1;
} else {
count = 0;
}

for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
cx = &pr->power.states[i];

Expand Down
2 changes: 0 additions & 2 deletions drivers/cpuidle/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ static int __cpuidle_register_driver(struct cpuidle_driver *drv)
on_each_cpu_mask(drv->cpumask, cpuidle_setup_broadcast_timer,
(void *)1, 1);

poll_idle_init(drv);

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion drivers/cpuidle/poll_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev,
return index;
}

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

Expand All @@ -34,3 +34,4 @@ void poll_idle_init(struct cpuidle_driver *drv)
state->disabled = false;
state->flags = CPUIDLE_FLAG_POLLING;
}
EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);
1 change: 1 addition & 0 deletions drivers/idle/intel_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,7 @@ static void __init intel_idle_cpuidle_driver_init(void)

intel_idle_state_table_update();

cpuidle_poll_state_init(drv);
drv->state_count = 1;

for (cstate = 0; cstate < CPUIDLE_STATE_MAX; ++cstate) {
Expand Down
4 changes: 2 additions & 2 deletions include/linux/cpuidle.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ static inline void cpuidle_coupled_parallel_barrier(struct cpuidle_device *dev,
#endif

#ifdef CONFIG_ARCH_HAS_CPU_RELAX
void poll_idle_init(struct cpuidle_driver *drv);
void cpuidle_poll_state_init(struct cpuidle_driver *drv);
#else
static void poll_idle_init(struct cpuidle_driver *drv) {}
static inline void cpuidle_poll_state_init(struct cpuidle_driver *drv) {}
#endif

/******************************
Expand Down

0 comments on commit 1b39e3f

Please sign in to comment.