• Yadwinder Singh Brar's avatar
    thermal: cpu_cooling: Update always cpufreq policy with thermal constraints · 2dcd851f
    Yadwinder Singh Brar authored
    Existing code updates cupfreq policy only while executing
    cpufreq_apply_cooling() function (i.e. when notify_device != NOTIFY_INVALID).
    It doesn't apply constraints when cpufreq policy update happens from any other
    place but it should update the cpufreq policy with thermal constraints every
    time when there is a cpufreq policy update, to keep state of
    cpufreq_cooling_device and max_feq of cpufreq policy in sync. For instance
    while resuming cpufreq updates cpufreq_policy and it restores default
    policy->usr_policy values irrespective of cooling device's cpufreq_state since
    notification gets missed because (notify_device == NOTIFY_INVALID).
    Another problem, is that userspace is able to change max_freq irrespective of
    cooling device's state, as notification gets missed.
    
    This patch modifies code to maintain a global cpufreq_dev_list and applies
    constraints of all matching cooling devices for policy's cpu when there is any
    policy update(ends up applying the lowest max_freq among the matching cpu
    cooling devices).
    
    This patch also removes redundant check (max_freq > policy->user_policy.max),
    as cpufreq framework takes care of user_policy constraints already where ever
    required, otherwise its causing an issue while increasing max_freq in normal
    scenerio as it restores max_freq with policy->user_policy.max which is old
    (smaller) value.
    Signed-off-by: default avatarYadwinder Singh Brar <yadi.brar@samsung.com>
    Signed-off-by: default avatarEduardo Valentin <edubezval@gmail.com>
    2dcd851f
cpu_cooling.c 16.5 KB