Skip to content

Commit ba1e78a

Browse files
committed
cpuidle: Drop disabled field from struct cpuidle_state
After recent cpuidle updates the "disabled" field in struct cpuidle_state is only used by two drivers (intel_idle and shmobile cpuidle) for marking unusable idle states, but that may as well be achieved with the help of a state flag, so define an "unusable" idle state flag, CPUIDLE_FLAG_UNUSABLE, make the drivers in question use it instead of the "disabled" field and make the core set CPUIDLE_STATE_DISABLED_BY_DRIVER for the idle states with that flag set. After the above changes, the "disabled" field in struct cpuidle_state is not used any more, so drop it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 656b4e6 commit ba1e78a

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

arch/sh/kernel/cpu/shmobile/cpuidle.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static struct cpuidle_driver cpuidle_driver = {
6767
.enter = cpuidle_sleep_enter,
6868
.name = "C2",
6969
.desc = "SuperH Sleep Mode [SF]",
70-
.disabled = true,
70+
.flags = CPUIDLE_FLAG_UNUSABLE,
7171
},
7272
{
7373
.exit_latency = 2300,
@@ -76,7 +76,7 @@ static struct cpuidle_driver cpuidle_driver = {
7676
.enter = cpuidle_sleep_enter,
7777
.name = "C3",
7878
.desc = "SuperH Mobile Standby Mode [SF]",
79-
.disabled = true,
79+
.flags = CPUIDLE_FLAG_UNUSABLE,
8080
},
8181
},
8282
.safe_state_index = 0,
@@ -86,10 +86,10 @@ static struct cpuidle_driver cpuidle_driver = {
8686
int __init sh_mobile_setup_cpuidle(void)
8787
{
8888
if (sh_mobile_sleep_supported & SUSP_SH_SF)
89-
cpuidle_driver.states[1].disabled = false;
89+
cpuidle_driver.states[1].flags = CPUIDLE_FLAG_NONE;
9090

9191
if (sh_mobile_sleep_supported & SUSP_SH_STANDBY)
92-
cpuidle_driver.states[2].disabled = false;
92+
cpuidle_driver.states[2].flags = CPUIDLE_FLAG_NONE;
9393

9494
return cpuidle_register(&cpuidle_driver, NULL);
9595
}

drivers/cpuidle/cpuidle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
572572
return -EINVAL;
573573

574574
for (i = 0; i < drv->state_count; i++)
575-
if (drv->states[i].disabled)
575+
if (drv->states[i].flags & CPUIDLE_FLAG_UNUSABLE)
576576
dev->states_usage[i].disable |= CPUIDLE_STATE_DISABLED_BY_DRIVER;
577577

578578
per_cpu(cpuidle_devices, dev->cpu) = dev;

drivers/cpuidle/poll_state.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ void cpuidle_poll_state_init(struct cpuidle_driver *drv)
5353
state->target_residency_ns = 0;
5454
state->power_usage = -1;
5555
state->enter = poll_idle;
56-
state->disabled = false;
5756
state->flags = CPUIDLE_FLAG_POLLING;
5857
}
5958
EXPORT_SYMBOL_GPL(cpuidle_poll_state_init);

drivers/idle/intel_idle.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,8 +1291,8 @@ static void sklh_idle_state_table_update(void)
12911291
return;
12921292
}
12931293

1294-
skl_cstates[5].disabled = 1; /* C8-SKL */
1295-
skl_cstates[6].disabled = 1; /* C9-SKL */
1294+
skl_cstates[5].flags |= CPUIDLE_FLAG_UNUSABLE; /* C8-SKL */
1295+
skl_cstates[6].flags |= CPUIDLE_FLAG_UNUSABLE; /* C9-SKL */
12961296
}
12971297
/*
12981298
* intel_idle_state_table_update()
@@ -1355,7 +1355,7 @@ static void __init intel_idle_cpuidle_driver_init(void)
13551355
continue;
13561356

13571357
/* if state marked as disabled, skip it */
1358-
if (cpuidle_state_table[cstate].disabled != 0) {
1358+
if (cpuidle_state_table[cstate].flags & CPUIDLE_FLAG_UNUSABLE) {
13591359
pr_debug("state %s is disabled\n",
13601360
cpuidle_state_table[cstate].name);
13611361
continue;

include/linux/cpuidle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ struct cpuidle_state {
5454
unsigned int exit_latency; /* in US */
5555
int power_usage; /* in mW */
5656
unsigned int target_residency; /* in US */
57-
bool disabled; /* disabled on all CPUs */
5857

5958
int (*enter) (struct cpuidle_device *dev,
6059
struct cpuidle_driver *drv,
@@ -77,6 +76,7 @@ struct cpuidle_state {
7776
#define CPUIDLE_FLAG_POLLING BIT(0) /* polling state */
7877
#define CPUIDLE_FLAG_COUPLED BIT(1) /* state applies to multiple cpus */
7978
#define CPUIDLE_FLAG_TIMER_STOP BIT(2) /* timer is stopped on this state */
79+
#define CPUIDLE_FLAG_UNUSABLE BIT(3) /* avoid using this state */
8080

8181
struct cpuidle_device_kobj;
8282
struct cpuidle_state_kobj;

0 commit comments

Comments
 (0)