Skip to content

Commit 918c1fe

Browse files
Zhenzhong Duanrafaeljw
authored andcommitted
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: 82467a5 ("cpuidle: simplify multiple driver support") Cc: 3.11+ <[email protected]> # 3.11+ Signed-off-by: Zhenzhong Duan <[email protected]> [ rjw: Subject & changelog ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 2c2a83d commit 918c1fe

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/cpuidle/driver.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,23 @@ static inline void __cpuidle_unset_driver(struct cpuidle_driver *drv)
6262
* __cpuidle_set_driver - set per CPU driver variables for the given driver.
6363
* @drv: a valid pointer to a struct cpuidle_driver
6464
*
65-
* For each CPU in the driver's cpumask, unset the registered driver per CPU
66-
* to @drv.
67-
*
68-
* Returns 0 on success, -EBUSY if the CPUs have driver(s) already.
65+
* Returns 0 on success, -EBUSY if any CPU in the cpumask have a driver
66+
* different from drv already.
6967
*/
7068
static inline int __cpuidle_set_driver(struct cpuidle_driver *drv)
7169
{
7270
int cpu;
7371

7472
for_each_cpu(cpu, drv->cpumask) {
73+
struct cpuidle_driver *old_drv;
7574

76-
if (__cpuidle_get_cpu_driver(cpu)) {
77-
__cpuidle_unset_driver(drv);
75+
old_drv = __cpuidle_get_cpu_driver(cpu);
76+
if (old_drv && old_drv != drv)
7877
return -EBUSY;
79-
}
78+
}
8079

80+
for_each_cpu(cpu, drv->cpumask)
8181
per_cpu(cpuidle_drivers, cpu) = drv;
82-
}
8382

8483
return 0;
8584
}

0 commit comments

Comments
 (0)