• Viresh Kumar's avatar
    cpufreq: Validate frequency table in the core · d417e069
    Viresh Kumar authored
    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: default avatarViresh Kumar <viresh.kumar@linaro.org>
    [ rjw: Subject/changelog ]
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    d417e069
freq_table.c 9.17 KB