]> asedeno.scripts.mit.edu Git - linux.git/commit
cpufreq: Validate frequency table in the core
authorViresh Kumar <viresh.kumar@linaro.org>
Thu, 22 Feb 2018 05:59:44 +0000 (11:29 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 27 Feb 2018 17:22:12 +0000 (18:22 +0100)
commitd417e0691ac00d35c4e6b90fc3fc85631a7865ad
treef335e4959da76cd7c61542d928e72c31b68dd574
parentb24b6478e65f140610ab1ffaadc7bc6bf0be8aad
cpufreq: Validate frequency table in the core

By design, cpufreq drivers are responsible for calling
cpufreq_frequency_table_cpuinfo() from their ->init()
callbacks to validate the frequency table.

However, if a cpufreq driver is buggy and fails to do so properly, it
lead to unexpected behavior of the driver or the cpufreq core at a
later point in time.  It would be better if the core could
validate the frequency table during driver initialization.

To that end, introduce cpufreq_table_validate_and_sort() and make
the cpufreq core call it right after invoking the ->init() callback
of the driver and destroy the cpufreq policy if the table is invalid.

For the time being the validation of the table happens twice, once
from the driver and then from the core.  The individual drivers will
be updated separately to drop table validation if they don't need it
for other reasons.

The frequency table is marked "sorted" or "unsorted" by the new helper
now instead of in cpufreq_table_validate_and_show(), as it should only
be done after validating the table (which the drivers won't do going
forward).

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
[ rjw: Subject/changelog ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
drivers/cpufreq/freq_table.c
include/linux/cpufreq.h