From: Finley Xiao <finley.xiao@rock-chips.com>
Date: Mon, 12 Dec 2016 01:46:29 +0000 (+0800)
Subject: cpufreq: dt: fix the warning occurred when upped cpu5 before cpu4
X-Git-Tag: firefly_0821_release~1080
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b226c47d097d2591e58379f434e5115bbbfc87d2;p=firefly-linux-kernel-4.4.55.git

cpufreq: dt: fix the warning occurred when upped cpu5 before cpu4

root@rk3399:/ # echo 0 > /sys/devices/system/cpu/cpu4/online
CPU4: shutdown
psci: CPU4 killed.
root@rk3399:/ # echo 0 > /sys/devices/system/cpu/cpu5/online
IRQ17 no longer affine to CPU5
CPU5: shutdown
psci: CPU5 killed.
root@rk3399:/ # echo 1 > /sys/devices/system/cpu/cpu5/online
Detected PIPT I-cache on CPU5
CPU5: found redistributor 101 region 0:0x00000000fefa0000
CPU5: update cpu_capacity 1024
CPU5: Booted secondary processor [410fd082]
cpu cpu5: opp_list_debug_create_link: Failed to create link
cpu cpu5: _add_opp_dev: Failed to register opp debugfs (-12)
cpu cpu5: dev_pm_opp_get_max_volt_latency: Invalid regulator (-6)

Change-Id: I9b066f9712b7f8426561e03a538a9a5c45138ab0
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
---

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 73d8102ff19d..d5166b0f4576 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -149,6 +149,9 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 	struct device *cpu_dev;
 	struct clk *cpu_clk;
 	struct dev_pm_opp *suspend_opp;
+#ifdef CONFIG_ARCH_ROCKCHIP
+	struct cpumask cpus;
+#endif
 	unsigned int transition_latency;
 	bool opp_v1 = false;
 	const char *name;
@@ -204,7 +207,20 @@ static int cpufreq_init(struct cpufreq_policy *policy)
 	 *
 	 * OPPs might be populated at runtime, don't check for error here
 	 */
+#ifdef CONFIG_ARCH_ROCKCHIP
+	ret = dev_pm_opp_of_add_table(cpu_dev);
+	if (ret) {
+		dev_err(cpu_dev, "couldn't find opp table for cpu:%d, %d\n",
+			policy->cpu, ret);
+	} else {
+		cpumask_copy(&cpus, policy->cpus);
+		cpumask_clear_cpu(policy->cpu, &cpus);
+		if (dev_pm_opp_of_cpumask_add_table(&cpus))
+			dev_pm_opp_of_remove_table(cpu_dev);
+	}
+#else
 	dev_pm_opp_of_cpumask_add_table(policy->cpus);
+#endif
 
 	/*
 	 * But we need OPP table to function so if it is not there let's