]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
cpufreq: Fix new policy initialization during limits updates via sysfs
authorTao Wang <kevin.wangtao@hisilicon.com>
Sat, 26 May 2018 07:16:48 +0000 (15:16 +0800)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 9 Nov 2018 19:00:22 +0000 (17:00 -0200)
commit412b2b9ac6fbd51f29a085dd82f3185e03650efe
tree4fb0276ceac9a54b3523260123431da88a7e6e61
parentabe6123b4da1a123aea6a99f96bd1a317c71247d
cpufreq: Fix new policy initialization during limits updates via sysfs

BugLink: http://bugs.launchpad.net/bugs/1800537
commit c7d1f119c48f64bebf0fa1e326af577c6152fe30 upstream.

If the policy limits are updated via cpufreq_update_policy() and
subsequently via sysfs, the limits stored in user_policy may be
set incorrectly.

For example, if both min and max are set via sysfs to the maximum
available frequency, user_policy.min and user_policy.max will also
be the maximum.  If a policy notifier triggered by
cpufreq_update_policy() lowers both the min and the max at this
point, that change is not reflected by the user_policy limits, so
if the max is updated again via sysfs to the same lower value,
then user_policy.max will be lower than user_policy.min which
shouldn't happen.  In particular, if one of the policy CPUs is
then taken offline and back online, cpufreq_set_policy() will
fail for it due to a failing limits check.

To prevent that from happening, initialize the min and max fields
of the new_policy object to the ones stored in user_policy that
were previously set via sysfs.

Signed-off-by: Kevin Wangtao <kevin.wangtao@hisilicon.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
[ rjw: Subject & changelog ]
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/cpufreq/cpufreq.c