Skip to content

Commit c7d1f11

Browse files
Kevin-WangTaorafaeljw
authored andcommitted
cpufreq: Fix new policy initialization during limits updates via sysfs
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 <[email protected]> Acked-by: Viresh Kumar <[email protected]> [ rjw: Subject & changelog ] Cc: All applicable <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent dc628cd commit c7d1f11

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,8 @@ static ssize_t store_##file_name \
697697
struct cpufreq_policy new_policy; \
698698
\
699699
memcpy(&new_policy, policy, sizeof(*policy)); \
700+
new_policy.min = policy->user_policy.min; \
701+
new_policy.max = policy->user_policy.max; \
700702
\
701703
ret = sscanf(buf, "%u", &new_policy.object); \
702704
if (ret != 1) \

0 commit comments

Comments
 (0)