intel_idle: Split up and provide per CPU initialization func
Function split up, should have no functional change. Provides entry point for physically hotplugged CPUs to initialize and activate cpuidle. Signed-off-by: Thomas Renninger <trenn@suse.de> CC: Deepthi Dharwar <deepthi@linux.vnet.ibm.com> CC: Shaohua Li <shaohua.li@intel.com> CC: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
committed by
Len Brown
parent
3bd81a8710
commit
65b7f839ce
@@ -478,64 +478,60 @@ static int intel_idle_cpuidle_driver_init(void)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* intel_idle_cpuidle_devices_init()
|
* intel_idle_cpu_init()
|
||||||
* allocate, initialize, register cpuidle_devices
|
* allocate, initialize, register cpuidle_devices
|
||||||
|
* @cpu: cpu/core to initialize
|
||||||
*/
|
*/
|
||||||
static int intel_idle_cpuidle_devices_init(void)
|
int intel_idle_cpu_init(int cpu)
|
||||||
{
|
{
|
||||||
int i, cstate;
|
int cstate;
|
||||||
struct cpuidle_device *dev;
|
struct cpuidle_device *dev;
|
||||||
|
|
||||||
intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
|
dev = per_cpu_ptr(intel_idle_cpuidle_devices, cpu);
|
||||||
if (intel_idle_cpuidle_devices == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
for_each_online_cpu(i) {
|
dev->state_count = 1;
|
||||||
dev = per_cpu_ptr(intel_idle_cpuidle_devices, i);
|
|
||||||
|
|
||||||
dev->state_count = 1;
|
for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) {
|
||||||
|
int num_substates;
|
||||||
|
|
||||||
for (cstate = 1; cstate < MWAIT_MAX_NUM_CSTATES; ++cstate) {
|
if (cstate > max_cstate) {
|
||||||
int num_substates;
|
printk(PREFIX "max_cstate %d reached\n",
|
||||||
|
max_cstate);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (cstate > max_cstate) {
|
/* does the state exist in CPUID.MWAIT? */
|
||||||
printk(PREFIX "max_cstate %d reached\n",
|
num_substates = (mwait_substates >> ((cstate) * 4))
|
||||||
max_cstate);
|
& MWAIT_SUBSTATE_MASK;
|
||||||
break;
|
if (num_substates == 0)
|
||||||
}
|
continue;
|
||||||
|
/* is the state not enabled? */
|
||||||
|
if (cpuidle_state_table[cstate].enter == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
/* does the state exist in CPUID.MWAIT? */
|
dev->states_usage[dev->state_count].driver_data =
|
||||||
num_substates = (mwait_substates >> ((cstate) * 4))
|
(void *)get_driver_data(cstate);
|
||||||
& MWAIT_SUBSTATE_MASK;
|
|
||||||
if (num_substates == 0)
|
|
||||||
continue;
|
|
||||||
/* is the state not enabled? */
|
|
||||||
if (cpuidle_state_table[cstate].enter == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->states_usage[dev->state_count].driver_data =
|
|
||||||
(void *)get_driver_data(cstate);
|
|
||||||
|
|
||||||
dev->state_count += 1;
|
dev->state_count += 1;
|
||||||
}
|
}
|
||||||
|
dev->cpu = cpu;
|
||||||
|
|
||||||
dev->cpu = i;
|
if (cpuidle_register_device(dev)) {
|
||||||
if (cpuidle_register_device(dev)) {
|
pr_debug(PREFIX "cpuidle_register_device %d failed!\n", cpu);
|
||||||
pr_debug(PREFIX "cpuidle_register_device %d failed!\n",
|
intel_idle_cpuidle_devices_uninit();
|
||||||
i);
|
return -EIO;
|
||||||
intel_idle_cpuidle_devices_uninit();
|
|
||||||
return -EIO;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto_demotion_disable_flags)
|
||||||
|
smp_call_function_single(cpu, auto_demotion_disable, NULL, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int __init intel_idle_init(void)
|
static int __init intel_idle_init(void)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval, i;
|
||||||
|
|
||||||
/* Do not load intel_idle at all for now if idle= is passed */
|
/* Do not load intel_idle at all for now if idle= is passed */
|
||||||
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
|
if (boot_option_idle_override != IDLE_NO_OVERRIDE)
|
||||||
@@ -553,10 +549,16 @@ static int __init intel_idle_init(void)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = intel_idle_cpuidle_devices_init();
|
intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
|
||||||
if (retval) {
|
if (intel_idle_cpuidle_devices == NULL)
|
||||||
cpuidle_unregister_driver(&intel_idle_driver);
|
return -ENOMEM;
|
||||||
return retval;
|
|
||||||
|
for_each_online_cpu(i) {
|
||||||
|
retval = intel_idle_cpu_init(i);
|
||||||
|
if (retval) {
|
||||||
|
cpuidle_unregister_driver(&intel_idle_driver);
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -188,7 +188,14 @@ struct cpuidle_governor {
|
|||||||
extern int cpuidle_register_governor(struct cpuidle_governor *gov);
|
extern int cpuidle_register_governor(struct cpuidle_governor *gov);
|
||||||
extern void cpuidle_unregister_governor(struct cpuidle_governor *gov);
|
extern void cpuidle_unregister_governor(struct cpuidle_governor *gov);
|
||||||
|
|
||||||
|
#ifdef CONFIG_INTEL_IDLE
|
||||||
|
extern int intel_idle_cpu_init(int cpu);
|
||||||
#else
|
#else
|
||||||
|
static inline int intel_idle_cpu_init(int cpu) { return -1; }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
static inline int intel_idle_cpu_init(int cpu) { return -1; }
|
||||||
|
|
||||||
static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
|
static inline int cpuidle_register_governor(struct cpuidle_governor *gov)
|
||||||
{return 0;}
|
{return 0;}
|
||||||
|
Reference in New Issue
Block a user