PM / devfreq: Lock CPU online/offline in rockchip_dmcfreq_target()

To protect against races with concurrent CPU online/offline, call
get_online_cpus() before change frequency.

Change-Id: I5b97cd7eff6a1c4828ab30bc165fb2aa8b460bb3
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
This commit is contained in:
Finley Xiao
2017-05-15 09:42:29 +08:00
committed by Huang, Tao
parent f7770d6f9f
commit 08e0c3fbe7

View File

@@ -17,6 +17,7 @@
#include <drm/drmP.h>
#include <linux/arm-smccc.h>
#include <linux/clk.h>
#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/devfreq.h>
#include <linux/devfreq-event.h>
@@ -217,7 +218,16 @@ static int rockchip_dmcfreq_target(struct device *dev, unsigned long *freq,
}
}
/*
* We need to prevent cpu hotplug from happening while a dmc freq rate
* change is happening.
*/
get_online_cpus();
err = clk_set_rate(dmcfreq->dmc_clk, target_rate);
put_online_cpus();
if (err) {
dev_err(dev, "Cannot set frequency %lu (%d)\n",
target_rate, err);