fix cpuidle sysfs related issue
Subsystems (2)
PATCH 1/3 fix cpuidle sysfs related issue
resend the three patches per Len's request. No real change except adding patch description and diffstat.
Fix the cpuidle sysfs issue.
a. make kobject dynamicaly allocated
b. fixed sysfs init issue to avoid suspend/resume issue
Signed-off-by Shaohua Li <[email protected]>
--- drivers/acpi/processor_idle.c | 2 - drivers/cpuidle/cpuidle.c | 29 ++++++++++++++++----- drivers/cpuidle/sysfs.c | 57 +++++++++++++++++++++++++++++++++--------- include/linux/cpuidle.h | 13 +++++---- 4 files changed, 76 insertions(+), 25 deletions(-)
drivers/acpi/processor_idle.c +1 -1
@@ -624,7 +624,7 @@ int acpi_processor_cst_has_changed(strucreturn -ENODEV ;acpi_processor_get_power_info (pr); -return cpuidle_force_redetect (&per_cpu (cpuidle_devices, pr->id)); +return cpuidle_force_redetect (per_cpu (cpuidle_devices, pr->id)); }/* proc interface */
drivers/cpuidle/cpuidle.c +22 -7
@@ -18,7 +18,7 @@#include "cpuidle.h" -DEFINE_PER_CPU(struct cpuidle_device, cpuidle_devices); +DEFINE_PER_CPU(struct cpuidle_device *, cpuidle_devices);EXPORT_PER_CPU_SYMBOL_GPL (cpuidle_devices);DEFINE_MUTEX (cpuidle_lock);
@@ -34,13 +34,13 @@ static void (*pm_idle_old)(void);*/ static void cpuidle_idle_call (void ) { -struct cpuidle_device *dev = &__get_cpu_var (cpuidle_devices); +struct cpuidle_device *dev =__get_cpu_var (cpuidle_devices);struct cpuidle_state *target_state;int next_state;/* check if the device is ready */ -if (dev->status !=CPUIDLE_STATUS_DOIDLE ) { +if (!dev || dev->status !=CPUIDLE_STATUS_DOIDLE ) {if (pm_idle_old)pm_idle_old ();return ;
@@ -117,19 +117,32 @@ static int cpuidle_add_device(struct sysint cpu = sys_dev->id;struct cpuidle_device *dev; - dev = &per_cpu (cpuidle_devices, cpu); + dev =per_cpu (cpuidle_devices, cpu); - dev->cpu = cpu;mutex_lock (&cpuidle_lock);if (cpu_is_offline (cpu)) {mutex_unlock (&cpuidle_lock);return 0 ; } +if (!dev) { + dev =kzalloc (sizeof (struct cpuidle_device ),GFP_KERNEL ); +if (!dev) { +mutex_unlock (&cpuidle_lock); +return -ENOMEM ; + } +init_completion (&dev->kobj_unregister); +per_cpu (cpuidle_devices, cpu) = dev; + } + dev->cpu = cpu; +if (dev->status &CPUIDLE_STATUS_DETECTED ) {mutex_unlock (&cpuidle_lock);return 0 ; } + +cpuidle_add_sysfs (sys_dev); +if (cpuidle_curr_driver) {if (cpuidle_attach_driver (dev)) goto err_ret;
@@ -146,7 +159,6 @@ static int cpuidle_add_device(struct syscpuidle_install_idle_handler ();list_add (&dev->device_list, &cpuidle_detected_devices); -cpuidle_add_sysfs (sys_dev); dev->status |=CPUIDLE_STATUS_DETECTED ; err_ret:
@@ -165,7 +177,7 @@ static int __cpuidle_remove_device(struc {struct cpuidle_device *dev; - dev = &per_cpu (cpuidle_devices, sys_dev->id); + dev =per_cpu (cpuidle_devices, sys_dev->id);if (!(dev->status &CPUIDLE_STATUS_DETECTED )) {return 0 ;
@@ -178,6 +190,9 @@ static int __cpuidle_remove_device(struccpuidle_detach_driver (dev);cpuidle_remove_sysfs (sys_dev);list_del (&dev->device_list); +wait_for_completion (&dev->kobj_unregister); +per_cpu (cpuidle_devices, sys_dev->id) =NULL ; +kfree (dev);return 0 ; }
drivers/cpuidle/sysfs.c +45 -12
115 lines not on this page · raw message
include/linux/cpuidle.h +8 -5
@@ -41,8 +41,6 @@ struct cpuidle_state {int (*enter) (struct cpuidle_device *dev,struct cpuidle_state *state); - -struct kobject kobj; };/* Idle State Flags */
@@ -74,6 +72,12 @@ cpuidle_set_statedata(struct cpuidle_sta state->driver_data = data; } +struct cpuidle_state_kobj { +struct cpuidle_state *state; +struct completion kobj_unregister; +struct kobject kobj; +}; +struct cpuidle_device {unsigned int status;int cpu;
@@ -81,6 +85,7 @@ struct cpuidle_device {int last_residency;int state_count;struct cpuidle_state states[CPUIDLE_STATE_MAX ]; +struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX ];struct cpuidle_state *last_state;struct list_head device_list;
@@ -89,9 +94,7 @@ struct cpuidle_device {void *governor_data; }; -#define to_cpuidle_device (n) container_of(n, struct cpuidle_device, kobj); - -DECLARE_PER_CPU(struct cpuidle_device, cpuidle_devices); +DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);/* Device Status Flags */ #define CPUIDLE_STATUS_DETECTED (0x1)
Len Brown
reviewerQuoted 2 lines · Shaohua Li
resend the three patches per Len's request. No real change except adding patch description and diffstat.
Thanks, and next time when you break the text lines to fit into 80 columns, it will be even better:-)
1,2,3 applied to acpi-test -- though I don't like the max_cstate patch, it seemed better to stumble forward...
thanks,
-Len