]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
cpufreq: Improve code around unlisted freq check
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 13 Oct 2020 05:12:47 +0000 (10:42 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 16 Oct 2020 14:19:08 +0000 (16:19 +0200)
The cpufreq core checks if the frequency programmed by the bootloaders
is not listed in the freq table and programs one from the table in such
a case. This is done only if the driver has set the
CPUFREQ_NEED_INITIAL_FREQ_CHECK flag.

Currently we print two separate messages, with almost the same content,
and do this with a pr_warn() which may be a bit too much as the driver
only asked us to check this as it expected this to be the case. Lower
down the severity of the print message by switching to pr_info() instead
and print a single message only.

Reported-by: Sumit Gupta <sumitg@nvidia.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Sumit Gupta <sumitg@nvidia.com>
Tested-by: Sumit Gupta <sumitg@nvidia.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c

index 1877f5e2e5b06cc18ee82ba0262e23bde7e54476..f4b60663efe65335b0501db403a6315a43227566 100644 (file)
@@ -1454,14 +1454,13 @@ static int cpufreq_online(unsigned int cpu)
         */
        if ((cpufreq_driver->flags & CPUFREQ_NEED_INITIAL_FREQ_CHECK)
            && has_target()) {
+               unsigned int old_freq = policy->cur;
+
                /* Are we running at unknown frequency ? */
-               ret = cpufreq_frequency_table_get_index(policy, policy->cur);
+               ret = cpufreq_frequency_table_get_index(policy, old_freq);
                if (ret == -EINVAL) {
-                       /* Warn user and fix it */
-                       pr_warn("%s: CPU%d: Running at unlisted freq: %u KHz\n",
-                               __func__, policy->cpu, policy->cur);
-                       ret = __cpufreq_driver_target(policy, policy->cur - 1,
-                               CPUFREQ_RELATION_L);
+                       ret = __cpufreq_driver_target(policy, old_freq - 1,
+                                                     CPUFREQ_RELATION_L);
 
                        /*
                         * Reaching here after boot in a few seconds may not
@@ -1469,8 +1468,8 @@ static int cpufreq_online(unsigned int cpu)
                         * frequency for longer duration. Hence, a BUG_ON().
                         */
                        BUG_ON(ret);
-                       pr_warn("%s: CPU%d: Unlisted initial frequency changed to: %u KHz\n",
-                               __func__, policy->cpu, policy->cur);
+                       pr_info("%s: CPU%d: Running at unlisted initial frequency: %u KHz, changing to: %u KHz\n",
+                               __func__, policy->cpu, old_freq, policy->cur);
                }
        }