diff options
author | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> | 2015-03-31 14:15:09 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-04-03 07:15:50 -0400 |
commit | d75e4af14e228bbe3f86e29bcecb8e6be98d4e04 (patch) | |
tree | 6a7c821d8dd08581e092a7b08ce8009001636b2b | |
parent | e42391cd048809d903291d07f86ed3934ce138e9 (diff) |
cpuidle: remove state_count field from struct cpuidle_device
Thomas Schlichter reports the following issue on his Samsung NC20:
"The C-states C1 and C2 to the OS when connected to AC, and additionally
provides the C3 C-state when disconnected from AC. However, the number
of C-states shown in sysfs is fixed to the number of C-states present
at boot.
If I boot with AC connected, I always only see the C-states up to C2
even if I disconnect AC.
The reason is commit 130a5f692425 (ACPI / cpuidle: remove dev->state_count
setting). It removes the update of dev->state_count, but sysfs uses
exactly this variable to show the C-states.
The fix is to use drv->state_count in sysfs. As this is currently the
last user of dev->state_count, this variable can be completely removed."
Remove dev->state_count as per the above.
Reported-by: Thomas Schlichter <thomas.schlichter@web.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: 3.14+ <stable@vger.kernel.org> # 3.14+
[ rjw: Changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/cpuidle/cpuidle.c | 3 | ||||
-rw-r--r-- | drivers/cpuidle/sysfs.c | 5 | ||||
-rw-r--r-- | include/linux/cpuidle.h | 1 |
3 files changed, 3 insertions, 6 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 080bd2dbde4b..7a73a279e179 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c | |||
@@ -330,9 +330,6 @@ int cpuidle_enable_device(struct cpuidle_device *dev) | |||
330 | if (!dev->registered) | 330 | if (!dev->registered) |
331 | return -EINVAL; | 331 | return -EINVAL; |
332 | 332 | ||
333 | if (!dev->state_count) | ||
334 | dev->state_count = drv->state_count; | ||
335 | |||
336 | ret = cpuidle_add_device_sysfs(dev); | 333 | ret = cpuidle_add_device_sysfs(dev); |
337 | if (ret) | 334 | if (ret) |
338 | return ret; | 335 | return ret; |
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 97c5903b4606..832a2c3f01ff 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c | |||
@@ -401,7 +401,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device) | |||
401 | struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device); | 401 | struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device); |
402 | 402 | ||
403 | /* state statistics */ | 403 | /* state statistics */ |
404 | for (i = 0; i < device->state_count; i++) { | 404 | for (i = 0; i < drv->state_count; i++) { |
405 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); | 405 | kobj = kzalloc(sizeof(struct cpuidle_state_kobj), GFP_KERNEL); |
406 | if (!kobj) | 406 | if (!kobj) |
407 | goto error_state; | 407 | goto error_state; |
@@ -433,9 +433,10 @@ error_state: | |||
433 | */ | 433 | */ |
434 | static void cpuidle_remove_state_sysfs(struct cpuidle_device *device) | 434 | static void cpuidle_remove_state_sysfs(struct cpuidle_device *device) |
435 | { | 435 | { |
436 | struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device); | ||
436 | int i; | 437 | int i; |
437 | 438 | ||
438 | for (i = 0; i < device->state_count; i++) | 439 | for (i = 0; i < drv->state_count; i++) |
439 | cpuidle_free_state_kobj(device, i); | 440 | cpuidle_free_state_kobj(device, i); |
440 | } | 441 | } |
441 | 442 | ||
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 306178d7309f..9c5e89254796 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h | |||
@@ -77,7 +77,6 @@ struct cpuidle_device { | |||
77 | unsigned int cpu; | 77 | unsigned int cpu; |
78 | 78 | ||
79 | int last_residency; | 79 | int last_residency; |
80 | int state_count; | ||
81 | struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX]; | 80 | struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX]; |
82 | struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX]; | 81 | struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX]; |
83 | struct cpuidle_driver_kobj *kobj_driver; | 82 | struct cpuidle_driver_kobj *kobj_driver; |