aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsuel Smith <ansuelsmth@gmail.com>2021-05-20 23:41:57 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2021-06-30 23:14:43 +0200
commit5e52f96714ee113b7703cb5a6c4cce1aeaec4373 (patch)
tree932e7afd95102cb57bc85e214e1f58bb1677c197
parent014aac7944ab9c6d5f33f57491acea5698d77f3b (diff)
downloadupstream-5e52f96714ee113b7703cb5a6c4cce1aeaec4373.tar.gz
upstream-5e52f96714ee113b7703cb5a6c4cce1aeaec4373.tar.bz2
upstream-5e52f96714ee113b7703cb5a6c4cce1aeaec4373.zip
ipq806x: fix dedicated cpufreq driver
2 small fix for the dedicated cpufreq driver: - Fix index wrongly used as the current cpu - Exit early if a bad freq is detected. In the current state the freq is applied anyway even with invalid state. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
-rw-r--r--target/linux/ipq806x/patches-5.10/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch30
-rw-r--r--target/linux/ipq806x/patches-5.10/098-3-add-fab-scaling-support-with-cpufreq.patch6
-rw-r--r--target/linux/ipq806x/patches-5.4/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch30
-rw-r--r--target/linux/ipq806x/patches-5.4/098-3-add-fab-scaling-support-with-cpufreq.patch6
4 files changed, 38 insertions, 34 deletions
diff --git a/target/linux/ipq806x/patches-5.10/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch b/target/linux/ipq806x/patches-5.10/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch
index 42913a994c..769686220b 100644
--- a/target/linux/ipq806x/patches-5.10/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch
+++ b/target/linux/ipq806x/patches-5.10/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch
@@ -75,7 +75,7 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
##################################################################################
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq-krait.c
-@@ -0,0 +1,601 @@
+@@ -0,0 +1,603 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -115,9 +115,11 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ int cpu, ret;
+
+ if (l2_pdev) {
++ int policy_cpu = policy->cpu;
++
+ /* find the max freq across all core */
+ for_each_present_cpu(cpu)
-+ if (cpu != index)
++ if (cpu != policy_cpu)
+ target_freq = max(
+ target_freq,
+ (unsigned long)cpufreq_quick_get(cpu));
@@ -132,6 +134,18 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ level = dev_pm_opp_get_level(opp);
+ dev_pm_opp_put(opp);
+
++ /*
++ * Hardware constraint:
++ * Krait CPU cannot operate at 384MHz with L2 at 1Ghz.
++ * Assume index 0 with the idle freq and level > 0 as
++ * any L2 freq > 384MHz.
++ * Skip CPU freq change in this corner case.
++ */
++ if (unlikely(index == 0 && level != 0)) {
++ dev_err(priv->cpu_dev, "Krait CPU can't operate at idle freq with L2 at 1GHz");
++ return -EINVAL;
++ }
++
+ opp = dev_pm_opp_find_level_exact(&l2_pdev->dev, level);
+ if (IS_ERR(opp)) {
+ dev_err(&l2_pdev->dev,
@@ -144,18 +158,6 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ ret = dev_pm_opp_set_rate(&l2_pdev->dev, target_freq);
+ if (ret)
+ return ret;
-+
-+ /*
-+ * Hardware constraint:
-+ * Krait CPU cannot operate at 384MHz with L2 at 1Ghz.
-+ * Assume index 0 with the idle freq and level > 0 as
-+ * any L2 freq > 384MHz.
-+ * Skip CPU freq change in this corner case.
-+ */
-+ if (unlikely(index == 0 && level != 0)) {
-+ dev_err(priv->cpu_dev, "Krait CPU can't operate at idle freq with L2 at 1GHz");
-+ return -EINVAL;
-+ }
+ }
+
+ ret = dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000);
diff --git a/target/linux/ipq806x/patches-5.10/098-3-add-fab-scaling-support-with-cpufreq.patch b/target/linux/ipq806x/patches-5.10/098-3-add-fab-scaling-support-with-cpufreq.patch
index fe9143218f..8ce3f062cf 100644
--- a/target/linux/ipq806x/patches-5.10/098-3-add-fab-scaling-support-with-cpufreq.patch
+++ b/target/linux/ipq806x/patches-5.10/098-3-add-fab-scaling-support-with-cpufreq.patch
@@ -227,9 +227,9 @@
#include "cpufreq-dt.h"
-@@ -54,6 +55,13 @@ static int set_target(struct cpufreq_pol
- level = dev_pm_opp_get_level(opp);
- dev_pm_opp_put(opp);
+@@ -68,6 +69,13 @@ static int set_target(struct cpufreq_pol
+ return -EINVAL;
+ }
+ /*
+ * Scale fabrics with max freq across all cores
diff --git a/target/linux/ipq806x/patches-5.4/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch b/target/linux/ipq806x/patches-5.4/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch
index cfc4341ebc..d6711105da 100644
--- a/target/linux/ipq806x/patches-5.4/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch
+++ b/target/linux/ipq806x/patches-5.4/098-1-cpufreq-add-Krait-dedicated-scaling-driver.patch
@@ -75,7 +75,7 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
##################################################################################
--- /dev/null
+++ b/drivers/cpufreq/qcom-cpufreq-krait.c
-@@ -0,0 +1,601 @@
+@@ -0,0 +1,603 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -115,9 +115,11 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ int cpu, ret;
+
+ if (l2_pdev) {
++ int policy_cpu = policy->cpu;
++
+ /* find the max freq across all core */
+ for_each_present_cpu(cpu)
-+ if (cpu != index)
++ if (cpu != policy_cpu)
+ target_freq = max(
+ target_freq,
+ (unsigned long)cpufreq_quick_get(cpu));
@@ -132,6 +134,18 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ level = dev_pm_opp_get_level(opp);
+ dev_pm_opp_put(opp);
+
++ /*
++ * Hardware constraint:
++ * Krait CPU cannot operate at 384MHz with L2 at 1Ghz.
++ * Assume index 0 with the idle freq and level > 0 as
++ * any L2 freq > 384MHz.
++ * Skip CPU freq change in this corner case.
++ */
++ if (unlikely(index == 0 && level != 0)) {
++ dev_err(priv->cpu_dev, "Krait CPU can't operate at idle freq with L2 at 1GHz");
++ return -EINVAL;
++ }
++
+ opp = dev_pm_opp_find_level_exact(&l2_pdev->dev, level);
+ if (IS_ERR(opp)) {
+ dev_err(&l2_pdev->dev,
@@ -144,18 +158,6 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+ ret = dev_pm_opp_set_rate(&l2_pdev->dev, target_freq);
+ if (ret)
+ return ret;
-+
-+ /*
-+ * Hardware constraint:
-+ * Krait CPU cannot operate at 384MHz with L2 at 1Ghz.
-+ * Assume index 0 with the idle freq and level > 0 as
-+ * any L2 freq > 384MHz.
-+ * Skip CPU freq change in this corner case.
-+ */
-+ if (unlikely(index == 0 && level != 0)) {
-+ dev_err(priv->cpu_dev, "Krait CPU can't operate at idle freq with L2 at 1GHz");
-+ return -EINVAL;
-+ }
+ }
+
+ ret = dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000);
diff --git a/target/linux/ipq806x/patches-5.4/098-3-add-fab-scaling-support-with-cpufreq.patch b/target/linux/ipq806x/patches-5.4/098-3-add-fab-scaling-support-with-cpufreq.patch
index fe9143218f..8ce3f062cf 100644
--- a/target/linux/ipq806x/patches-5.4/098-3-add-fab-scaling-support-with-cpufreq.patch
+++ b/target/linux/ipq806x/patches-5.4/098-3-add-fab-scaling-support-with-cpufreq.patch
@@ -227,9 +227,9 @@
#include "cpufreq-dt.h"
-@@ -54,6 +55,13 @@ static int set_target(struct cpufreq_pol
- level = dev_pm_opp_get_level(opp);
- dev_pm_opp_put(opp);
+@@ -68,6 +69,13 @@ static int set_target(struct cpufreq_pol
+ return -EINVAL;
+ }
+ /*
+ * Scale fabrics with max freq across all cores