From: Kevin Wangtao <kevin.wangtao@hisilicon.com>
To: rjw@rjwysocki.net, viresh.kumar@linaro.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
gengyanping@hisilicon.com, sunzhaosheng@hisilicon.com,
Kevin Wangtao <kevin.wangtao@hisilicon.com>
Subject: [PATCH V2] cpufreq: reinitialize new policy min/max when writing scaling_(max|min)_freq
Date: Sat, 26 May 2018 15:16:48 +0800 [thread overview]
Message-ID: <1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com> (raw)
In-Reply-To: <1527144234-96396-1-git-send-email-kevin.wangtao@hisilicon.com>
consider such situation, current user_policy.min is 1000000,
current user_policy.max is 1200000, in cpufreq_set_policy,
other driver may update policy.min to 1200000, policy.max to
1300000. After that, If we input "echo 1300000 > scaling_min_freq",
then user_policy.min will be 1300000, and user_policy.max is
still 1200000, because the input value is checked with policy.max
not user_policy.max. if we get all related cpus offline and
online again, it will cause cpufreq_init_policy fail because
user_policy.min is higher than user_policy.max.
The solution is when user space tries to write scaling_(max|min)_freq,
the min/max of new_policy should be reinitialized with min/max
of user_policy, like what cpufreq_update_policy does.
Signed-off-by: Kevin Wangtao <kevin.wangtao@hisilicon.com>
---
drivers/cpufreq/cpufreq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b79c532..82123a1 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -697,6 +697,8 @@ static ssize_t store_##file_name \
struct cpufreq_policy new_policy; \
\
memcpy(&new_policy, policy, sizeof(*policy)); \
+ new_policy.min = policy->user_policy.min; \
+ new_policy.max = policy->user_policy.max; \
\
ret = sscanf(buf, "%u", &new_policy.object); \
if (ret != 1) \
--
2.8.1
next prev parent reply other threads:[~2018-05-26 7:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 6:43 [PATCH] cpufreq: reinitialize new policy min/max when writing scaling_(max|min)_freq Kevin Wangtao
2018-05-24 7:45 ` Rafael J. Wysocki
2018-05-25 2:54 ` Wangtao (Kevin, Kirin)
2018-05-29 8:45 ` Rafael J. Wysocki
2018-05-26 6:50 ` Wangtao (Kevin, Kirin)
2018-05-29 8:47 ` Rafael J. Wysocki
2018-05-26 7:16 ` Kevin Wangtao [this message]
2018-05-29 10:26 ` [PATCH V2] " Viresh Kumar
2018-05-30 8:03 ` Wangtao (Kevin, Kirin)
2018-05-30 7:56 ` [PATCH V3] " Kevin Wangtao
2018-05-30 11:10 ` Rafael J. Wysocki
2018-05-27 6:15 ` [PATCH] " kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1527319008-66663-1-git-send-email-kevin.wangtao@hisilicon.com \
--to=kevin.wangtao@hisilicon.com \
--cc=gengyanping@hisilicon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=sunzhaosheng@hisilicon.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).