]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ACPI: processor: Add QoS requests for all CPUs
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 25 Oct 2019 00:41:40 +0000 (02:41 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 25 Oct 2019 09:33:48 +0000 (11:33 +0200)
The _PPC change notifications from the platform firmware are per-CPU,
so acpi_processor_ppc_init() needs to add a frequency QoS request
for each CPU covered by a cpufreq policy to take all of them into
account.

Even though ACPI thermal control of CPUs sets frequency limits
per processor package, it also needs a frequency QoS request for each
CPU in a cpufreq policy in case some of them are taken offline and
the frequency limit needs to be set through the remaining online
ones (this is slightly excessive, because all CPUs covered by one
cpufreq policy will set the same frequency limit through their QoS
requests, but it is not incorrect).

Modify the code in accordance with the above observations.

Fixes: b9e90816e071 ("ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/acpi/processor_perflib.c
drivers/acpi/processor_thermal.c

index 753e171de006caab2e087811821fa9e9ed689926..5909e8fa4013f2c6c831b1a28d9d69ca4cec98fb 100644 (file)
@@ -159,26 +159,34 @@ void acpi_processor_ignore_ppc_init(void)
 
 void acpi_processor_ppc_init(struct cpufreq_policy *policy)
 {
-       int cpu = policy->cpu;
-       struct acpi_processor *pr = per_cpu(processors, cpu);
-       int ret;
+       unsigned int cpu;
 
-       if (!pr)
-               return;
+       for_each_cpu(cpu, policy->related_cpus) {
+               struct acpi_processor *pr = per_cpu(processors, cpu);
+               int ret;
+
+               if (!pr)
+                       continue;
 
-       ret = freq_qos_add_request(&policy->constraints, &pr->perflib_req,
-                                  FREQ_QOS_MAX, INT_MAX);
-       if (ret < 0)
-               pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu,
-                      ret);
+               ret = freq_qos_add_request(&policy->constraints,
+                                          &pr->perflib_req,
+                                          FREQ_QOS_MAX, INT_MAX);
+               if (ret < 0)
+                       pr_err("Failed to add freq constraint for CPU%d (%d)\n",
+                              cpu, ret);
+       }
 }
 
 void acpi_processor_ppc_exit(struct cpufreq_policy *policy)
 {
-       struct acpi_processor *pr = per_cpu(processors, policy->cpu);
+       unsigned int cpu;
 
-       if (pr)
-               freq_qos_remove_request(&pr->perflib_req);
+       for_each_cpu(cpu, policy->related_cpus) {
+               struct acpi_processor *pr = per_cpu(processors, cpu);
+
+               if (pr)
+                       freq_qos_remove_request(&pr->perflib_req);
+       }
 }
 
 static int acpi_processor_get_performance_control(struct acpi_processor *pr)
index c77a5b1fb1079467180c5015657d7d20fcd231db..41feb88ee92d69380af6e4d30c92199e3e4dd4d1 100644 (file)
@@ -127,26 +127,34 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
 
 void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy)
 {
-       int cpu = policy->cpu;
-       struct acpi_processor *pr = per_cpu(processors, cpu);
-       int ret;
+       unsigned int cpu;
 
-       if (!pr)
-               return;
+       for_each_cpu(cpu, policy->related_cpus) {
+               struct acpi_processor *pr = per_cpu(processors, cpu);
+               int ret;
+
+               if (!pr)
+                       continue;
 
-       ret = freq_qos_add_request(&policy->constraints, &pr->thermal_req,
-                                  FREQ_QOS_MAX, INT_MAX);
-       if (ret < 0)
-               pr_err("Failed to add freq constraint for CPU%d (%d)\n", cpu,
-                      ret);
+               ret = freq_qos_add_request(&policy->constraints,
+                                          &pr->thermal_req,
+                                          FREQ_QOS_MAX, INT_MAX);
+               if (ret < 0)
+                       pr_err("Failed to add freq constraint for CPU%d (%d)\n",
+                              cpu, ret);
+       }
 }
 
 void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy)
 {
-       struct acpi_processor *pr = per_cpu(processors, policy->cpu);
+       unsigned int cpu;
+
+       for_each_cpu(cpu, policy->related_cpus) {
+               struct acpi_processor *pr = per_cpu(processors, policy->cpu);
 
-       if (pr)
-               freq_qos_remove_request(&pr->thermal_req);
+               if (pr)
+                       freq_qos_remove_request(&pr->thermal_req);
+       }
 }
 #else                          /* ! CONFIG_CPU_FREQ */
 static int cpufreq_get_max_state(unsigned int cpu)