Commit 918c1fe9 authored by Zhenzhong Duan's avatar Zhenzhong Duan Committed by Rafael J. Wysocki

cpuidle: Do not unset the driver if it is there already

Fix __cpuidle_set_driver() to check if any of the CPUs in the mask has
a driver different from drv already and, if so, return -EBUSY before
updating any cpuidle_drivers per-CPU pointers.

Fixes: 82467a5a ("cpuidle: simplify multiple driver support")
Cc: 3.11+ <stable@vger.kernel.org> # 3.11+
Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
[ rjw: Subject & changelog ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 2c2a83d3
...@@ -62,24 +62,23 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv) ...@@ -62,24 +62,23 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv)
* __cpuidle_set_driver - set per CPU driver variables for the given driver. * __cpuidle_set_driver - set per CPU driver variables for the given driver.
* @drv: a valid pointer to a struct cpuidle_driver * @drv: a valid pointer to a struct cpuidle_driver
* *
* For each CPU in the driver's cpumask, unset the registered driver per CPU * Returns 0 on success, -EBUSY if any CPU in the cpumask have a driver
* to @drv. * different from drv already.
*
* Returns 0 on success, -EBUSY if the CPUs have driver(s) already.
*/ */
static inline int __cpuidle_set_driver(struct cpuidle_driver *drv) static inline int __cpuidle_set_driver(struct cpuidle_driver *drv)
{ {
int cpu; int cpu;
for_each_cpu(cpu, drv->cpumask) { for_each_cpu(cpu, drv->cpumask) {
struct cpuidle_driver *old_drv;
if (__cpuidle_get_cpu_driver(cpu)) { old_drv = __cpuidle_get_cpu_driver(cpu);
__cpuidle_unset_driver(drv); if (old_drv && old_drv != drv)
return -EBUSY; return -EBUSY;
} }
for_each_cpu(cpu, drv->cpumask)
per_cpu(cpuidle_drivers, cpu) = drv; per_cpu(cpuidle_drivers, cpu) = drv;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment