From 72d67d6b3447303a441a8cedc34f7224b75f64b5 Mon Sep 17 00:00:00 2001 From: Yang Yingliang Date: Tue, 17 May 2022 21:34:50 +0800 Subject: [PATCH 01/11] cpufreq: mediatek: fix error return code in mtk_cpu_dvfs_info_init() If regulator_get_voltage() fails, it should return the error code in mtk_cpu_dvfs_info_init(). Fixes: 0daa47325bae ("cpufreq: mediatek: Link CCI device to CPU") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Rex-BC Chen Signed-off-by: Viresh Kumar --- drivers/cpufreq/mediatek-cpufreq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/cpufreq/mediatek-cpufreq.c b/drivers/cpufreq/mediatek-cpufreq.c index 76f6b3884e6b..7f2680bc9a0f 100644 --- a/drivers/cpufreq/mediatek-cpufreq.c +++ b/drivers/cpufreq/mediatek-cpufreq.c @@ -478,6 +478,7 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu) if (info->soc_data->ccifreq_supported) { info->vproc_on_boot = regulator_get_voltage(info->proc_reg); if (info->vproc_on_boot < 0) { + ret = info->vproc_on_boot; dev_err(info->cpu_dev, "invalid Vproc value: %d\n", info->vproc_on_boot); goto out_disable_inter_clock; From 9de0d75bb379c06e6d22e4b39552069fd9c869aa Mon Sep 17 00:00:00 2001 From: Yicong Yang Date: Fri, 10 Jun 2022 15:53:09 +0800 Subject: [PATCH 02/11] cpufreq: qcom-cpufreq-hw: use HZ_PER_KHZ macro in units.h HZ macros has been centralized in units.h since [1]. Use it to avoid duplicated definition. [1] commit e2c77032fcbe ("units: add the HZ macros") Signed-off-by: Yicong Yang Signed-off-by: Viresh Kumar --- drivers/cpufreq/qcom-cpufreq-hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 36c79580fba2..072a4b31f98e 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -15,6 +15,7 @@ #include #include #include +#include #define LUT_MAX_ENTRIES 40U #define LUT_SRC GENMASK(31, 30) @@ -26,8 +27,6 @@ #define GT_IRQ_STATUS BIT(2) -#define HZ_PER_KHZ 1000 - struct qcom_cpufreq_soc_data { u32 reg_enable; u32 reg_domain_state; From cdcf8eb3e7d0557405414459c6ead0385a5c6cc7 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Mon, 4 Jul 2022 13:27:36 +0200 Subject: [PATCH 03/11] cpufreq: qcom-hw: Reset cancel_throttle when policy is re-enabled If LMH (Limits Management Hardware) is available, when a policy is disabled by unplugging the last online CPU of policy->cpus, qcom_cpufreq_hw_cpu_offline() sets cancel_throttle=true. cancel_throttle is not reset when the policy is re-enabled with any of the CPU in policy->cpus being plugged in. So reset it. This patch also adds an early exit check. Signed-off-by: Pierre Gondois Signed-off-by: Viresh Kumar --- drivers/cpufreq/qcom-cpufreq-hw.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 072a4b31f98e..b57a1e508a8c 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -444,6 +444,10 @@ static int qcom_cpufreq_hw_cpu_online(struct cpufreq_policy *policy) if (data->throttle_irq <= 0) return 0; + mutex_lock(&data->throttle_lock); + data->cancel_throttle = false; + mutex_unlock(&data->throttle_lock); + ret = irq_set_affinity_hint(data->throttle_irq, policy->cpus); if (ret) dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", From f7fca54a18990ab465a6d530aadb90769ded1707 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Mon, 4 Jul 2022 13:27:37 +0200 Subject: [PATCH 04/11] cpufreq: qcom-hw: Disable LMH irq when disabling policy If LMH (Limits Management Hardware) is available, when a policy is disabled by unplugging the last online CPU of policy->cpus, the LMH irq is left enabled. When the policy is re-enabled with any of the CPU in policy->cpus being plugged in, qcom_cpufreq_ready() re-enables the irq. This triggers the following warning: [ 379.160106] Unbalanced enable for IRQ 154 [ 379.160120] WARNING: CPU: 7 PID: 48 at kernel/irq/manage.c:774 __enable_irq+0x84/0xc0 Thus disable the irq. Signed-off-by: Pierre Gondois Signed-off-by: Viresh Kumar --- drivers/cpufreq/qcom-cpufreq-hw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index b57a1e508a8c..6e3deb420359 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -469,6 +469,7 @@ static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy) cancel_delayed_work_sync(&data->throttle_work); irq_set_affinity_hint(data->throttle_irq, NULL); + disable_irq_nosync(data->throttle_irq); return 0; } From f2b03dffa62e496df97b2b0d68fba2324c8d13c7 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Mon, 4 Jul 2022 13:27:38 +0200 Subject: [PATCH 05/11] cpufreq: qcom-hw: Remove deprecated irq_set_affinity_hint() call commit 65c7cdedeb30 ("genirq: Provide new interfaces for affinity hints") deprecates irq_set_affinity_hint(). Use the new irq_set_affinity_and_hint() instead. Signed-off-by: Pierre Gondois Signed-off-by: Viresh Kumar --- drivers/cpufreq/qcom-cpufreq-hw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 6e3deb420359..d5ef3c66c762 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -427,7 +427,7 @@ static int qcom_cpufreq_hw_lmh_init(struct cpufreq_policy *policy, int index) return 0; } - ret = irq_set_affinity_hint(data->throttle_irq, policy->cpus); + ret = irq_set_affinity_and_hint(data->throttle_irq, policy->cpus); if (ret) dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", data->irq_name, data->throttle_irq); @@ -448,7 +448,7 @@ static int qcom_cpufreq_hw_cpu_online(struct cpufreq_policy *policy) data->cancel_throttle = false; mutex_unlock(&data->throttle_lock); - ret = irq_set_affinity_hint(data->throttle_irq, policy->cpus); + ret = irq_set_affinity_and_hint(data->throttle_irq, policy->cpus); if (ret) dev_err(&pdev->dev, "Failed to set CPU affinity of %s[%d]\n", data->irq_name, data->throttle_irq); @@ -468,7 +468,7 @@ static int qcom_cpufreq_hw_cpu_offline(struct cpufreq_policy *policy) mutex_unlock(&data->throttle_lock); cancel_delayed_work_sync(&data->throttle_work); - irq_set_affinity_hint(data->throttle_irq, NULL); + irq_set_affinity_and_hint(data->throttle_irq, NULL); disable_irq_nosync(data->throttle_irq); return 0; From 68315f1a5f1333d8aa67bb7061b5a9da1134f474 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Mon, 4 Jul 2022 13:27:39 +0200 Subject: [PATCH 06/11] cpufreq: Change order of online() CB and policy->cpus modification From a state where all policy->related_cpus are offline, putting one of the policy's CPU back online re-activates the policy by: 1. Calling cpufreq_driver->online() 2. Setting the CPU in policy->cpus qcom_cpufreq_hw_cpu_online() makes use of policy->cpus. Thus 1. and 2. should be inverted to avoid having a policy->cpus empty. The qcom-cpufreq-hw is the only driver affected by this. Signed-off-by: Pierre Gondois Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2cad42774164..36043be16d8e 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1350,15 +1350,15 @@ static int cpufreq_online(unsigned int cpu) } if (!new_policy && cpufreq_driver->online) { + /* Recover policy->cpus using related_cpus */ + cpumask_copy(policy->cpus, policy->related_cpus); + ret = cpufreq_driver->online(policy); if (ret) { pr_debug("%s: %d: initialization failed\n", __func__, __LINE__); goto out_exit_policy; } - - /* Recover policy->cpus using related_cpus */ - cpumask_copy(policy->cpus, policy->related_cpus); } else { cpumask_copy(policy->cpus, cpumask_of(cpu)); From 3b4916a6e422394aa129fe9b204f4d489ae484a6 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Fri, 8 Jul 2022 13:11:54 +0100 Subject: [PATCH 07/11] dt-bindings: opp: opp-v2-kryo-cpu: Fix example binding checks Adding missing compat entries to the cpufreq node Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml shows up a dt_binding_check in this file. opp-v2-kryo-cpu.example.dtb: /: cpus:cpu@0: 'power-domains' is a required property opp-v2-kryo-cpu.example.dtb: /: cpus:cpu@0: 'power-domain-names' is a required property opp-v2-kryo-cpu.example.dtb: /: opp-table-0:opp-307200000: 'required-opps' is a required property Fixes: ec24d1d55469 ("dt-bindings: opp: Convert qcom-nvmem-cpufreq to DT schema") Signed-off-by: Bryan O'Donoghue Signed-off-by: Viresh Kumar --- .../devicetree/bindings/opp/opp-v2-kryo-cpu.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/devicetree/bindings/opp/opp-v2-kryo-cpu.yaml b/Documentation/devicetree/bindings/opp/opp-v2-kryo-cpu.yaml index 30f7b596d609..59663e897dae 100644 --- a/Documentation/devicetree/bindings/opp/opp-v2-kryo-cpu.yaml +++ b/Documentation/devicetree/bindings/opp/opp-v2-kryo-cpu.yaml @@ -98,6 +98,8 @@ examples: capacity-dmips-mhz = <1024>; clocks = <&kryocc 0>; operating-points-v2 = <&cluster0_opp>; + power-domains = <&cpr>; + power-domain-names = "cpr"; #cooling-cells = <2>; next-level-cache = <&L2_0>; L2_0: l2-cache { @@ -115,6 +117,8 @@ examples: capacity-dmips-mhz = <1024>; clocks = <&kryocc 0>; operating-points-v2 = <&cluster0_opp>; + power-domains = <&cpr>; + power-domain-names = "cpr"; #cooling-cells = <2>; next-level-cache = <&L2_0>; }; @@ -128,6 +132,8 @@ examples: capacity-dmips-mhz = <1024>; clocks = <&kryocc 1>; operating-points-v2 = <&cluster1_opp>; + power-domains = <&cpr>; + power-domain-names = "cpr"; #cooling-cells = <2>; next-level-cache = <&L2_1>; L2_1: l2-cache { @@ -145,6 +151,8 @@ examples: capacity-dmips-mhz = <1024>; clocks = <&kryocc 1>; operating-points-v2 = <&cluster1_opp>; + power-domains = <&cpr>; + power-domain-names = "cpr"; #cooling-cells = <2>; next-level-cache = <&L2_1>; }; @@ -182,18 +190,21 @@ examples: opp-microvolt = <905000 905000 1140000>; opp-supported-hw = <0x7>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp1>; }; opp-1401600000 { opp-hz = /bits/ 64 <1401600000>; opp-microvolt = <1140000 905000 1140000>; opp-supported-hw = <0x5>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp2>; }; opp-1593600000 { opp-hz = /bits/ 64 <1593600000>; opp-microvolt = <1140000 905000 1140000>; opp-supported-hw = <0x1>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp3>; }; }; @@ -207,24 +218,28 @@ examples: opp-microvolt = <905000 905000 1140000>; opp-supported-hw = <0x7>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp1>; }; opp-1804800000 { opp-hz = /bits/ 64 <1804800000>; opp-microvolt = <1140000 905000 1140000>; opp-supported-hw = <0x6>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp4>; }; opp-1900800000 { opp-hz = /bits/ 64 <1900800000>; opp-microvolt = <1140000 905000 1140000>; opp-supported-hw = <0x4>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp5>; }; opp-2150400000 { opp-hz = /bits/ 64 <2150400000>; opp-microvolt = <1140000 905000 1140000>; opp-supported-hw = <0x1>; clock-latency-ns = <200000>; + required-opps = <&cpr_opp6>; }; }; From 228f901ccec83b05e4657897aeb460beb294d2e5 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Fri, 8 Jul 2022 13:11:55 +0100 Subject: [PATCH 08/11] dt-bindings: opp: Add missing compat devices A number of devices listed in drivers/cpufreq/qcom-cpufreq-nvmem.c appear to be missing from the compatible list. Acked-by: Krzysztof Kozlowski Acked-by: Rob Herring Signed-off-by: Bryan O'Donoghue Signed-off-by: Viresh Kumar --- .../devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml b/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml index a9a776da5505..5eb1dba13fe2 100644 --- a/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml +++ b/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml @@ -22,6 +22,12 @@ select: compatible: contains: enum: + - qcom,apq8064 + - qcom,apq8096 + - qcom,ipq8064 + - qcom,msm8960 + - qcom,msm8974 + - qcom,msm8996 - qcom,qcs404 required: - compatible From a0c999b8a7b9c7ac4ba11b0dff37f9536a728be6 Mon Sep 17 00:00:00 2001 From: Bryan O'Donoghue Date: Fri, 8 Jul 2022 13:11:56 +0100 Subject: [PATCH 09/11] dt-bindings: opp: Add msm8939 to the compatible list msm8939 will uses this driver instead of the generic dt-cpufreq. Add to the compatible list. Acked-by: Krzysztof Kozlowski Signed-off-by: Bryan O'Donoghue Signed-off-by: Viresh Kumar --- .../devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml b/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml index 5eb1dba13fe2..7efae476c02e 100644 --- a/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml +++ b/Documentation/devicetree/bindings/cpufreq/qcom-cpufreq-nvmem.yaml @@ -25,6 +25,7 @@ select: - qcom,apq8064 - qcom,apq8096 - qcom,ipq8064 + - qcom,msm8939 - qcom,msm8960 - qcom,msm8974 - qcom,msm8996 From 172a672af95c022071b9dacdf8a647c193d0edbd Mon Sep 17 00:00:00 2001 From: Konrad Dybcio Date: Sat, 16 Jul 2022 21:32:55 +0200 Subject: [PATCH 10/11] dt-bindings: cpufreq: cpufreq-qcom-hw: Add SM6375 compatible Add compatible for EPSS CPUFREQ-HW on SM6375. Signed-off-by: Konrad Dybcio Signed-off-by: Viresh Kumar --- Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml b/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml index 2f1b8b6852a0..24fa3d87a40b 100644 --- a/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-qcom-hw.yaml @@ -25,6 +25,7 @@ properties: - description: v2 of CPUFREQ HW (EPSS) items: - enum: + - qcom,sm6375-cpufreq-epss - qcom,sm8250-cpufreq-epss - const: qcom,cpufreq-epss From 33fe1cb20cf44af9c12048b2bfdebae0408cd4aa Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Mon, 18 Jul 2022 07:32:14 +0530 Subject: [PATCH 11/11] cpufreq: tegra194: Staticize struct tegra_cpufreq_soc instances Fix sparse warnings by marking these structures static. Fixes: 273bc890a2a8 ("cpufreq: tegra194: Add support for Tegra234") Reported-by: kernel test robot Reviewed-by: Sumit Gupta Signed-off-by: Viresh Kumar --- drivers/cpufreq/tegra194-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c index 2a6a98764a8c..1216046cf4c2 100644 --- a/drivers/cpufreq/tegra194-cpufreq.c +++ b/drivers/cpufreq/tegra194-cpufreq.c @@ -162,7 +162,7 @@ static struct tegra_cpufreq_ops tegra234_cpufreq_ops = { .set_cpu_ndiv = tegra234_set_cpu_ndiv, }; -const struct tegra_cpufreq_soc tegra234_cpufreq_soc = { +static const struct tegra_cpufreq_soc tegra234_cpufreq_soc = { .ops = &tegra234_cpufreq_ops, .actmon_cntr_base = 0x9000, .maxcpus_per_cluster = 4, @@ -430,7 +430,7 @@ static struct tegra_cpufreq_ops tegra194_cpufreq_ops = { .set_cpu_ndiv = tegra194_set_cpu_ndiv, }; -const struct tegra_cpufreq_soc tegra194_cpufreq_soc = { +static const struct tegra_cpufreq_soc tegra194_cpufreq_soc = { .ops = &tegra194_cpufreq_ops, .maxcpus_per_cluster = 2, };