* [PATCH v3] cpufreq: s3c: fix unbalances of cpufreq policy refcount
@ 2020-01-07 7:53 qiwuchen55
2020-01-07 8:01 ` Viresh Kumar
0 siblings, 1 reply; 4+ messages in thread
From: qiwuchen55 @ 2020-01-07 7:53 UTC (permalink / raw)
To: kgene, krzk, rjw, viresh.kumar
Cc: linux-arm-kernel, linux-samsung-soc, linux-pm, chenqiwu
From: chenqiwu <chenqiwu@xiaomi.com>
The cpufreq_reboot_notifier_evt() call cpufreq_cpu_get() to get the
cpufreq policy of cpu0, meanwhile, it also increments the kobject
reference count to mark it busy. However, a corresponding call of
cpufreq_cpu_put() is ignored to decrement the kobject reference count
back, which may lead to a potential stuck risk that the cpuhp thread
deadly waits for dropping of kobject refcount when cpufreq policy free.
With this patch, the cpuhp thread can be easily exercised by attempting
to force an unbind of the CPUfreq driver.
Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
---
changes in v3:
- Rewrite title and commit message.
---
drivers/cpufreq/s3c2416-cpufreq.c | 12 +++++++++++-
drivers/cpufreq/s5pv210-cpufreq.c | 11 ++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/s3c2416-cpufreq.c b/drivers/cpufreq/s3c2416-cpufreq.c
index 1069103..5c221bc 100644
--- a/drivers/cpufreq/s3c2416-cpufreq.c
+++ b/drivers/cpufreq/s3c2416-cpufreq.c
@@ -304,6 +304,7 @@ static int s3c2416_cpufreq_reboot_notifier_evt(struct notifier_block *this,
{
struct s3c2416_data *s3c_freq = &s3c2416_cpufreq;
int ret;
+ struct cpufreq_policy *policy;
mutex_lock(&cpufreq_lock);
@@ -318,7 +319,16 @@ static int s3c2416_cpufreq_reboot_notifier_evt(struct notifier_block *this,
*/
if (s3c_freq->is_dvs) {
pr_debug("cpufreq: leave dvs on reboot\n");
- ret = cpufreq_driver_target(cpufreq_cpu_get(0), FREQ_SLEEP, 0);
+
+ policy = cpufreq_cpu_get(0);
+ if (!policy) {
+ pr_debug("cpufreq: get no policy for cpu0\n");
+ return NOTIFY_BAD;
+ }
+
+ ret = cpufreq_driver_target(policy, FREQ_SLEEP, 0);
+ cpufreq_cpu_put(policy);
+
if (ret < 0)
return NOTIFY_BAD;
}
diff --git a/drivers/cpufreq/s5pv210-cpufreq.c b/drivers/cpufreq/s5pv210-cpufreq.c
index 5d10030..e84281e 100644
--- a/drivers/cpufreq/s5pv210-cpufreq.c
+++ b/drivers/cpufreq/s5pv210-cpufreq.c
@@ -555,8 +555,17 @@ static int s5pv210_cpufreq_reboot_notifier_event(struct notifier_block *this,
unsigned long event, void *ptr)
{
int ret;
+ struct cpufreq_policy *policy;
+
+ policy = cpufreq_cpu_get(0);
+ if (!policy) {
+ pr_debug("cpufreq: get no policy for cpu0\n");
+ return NOTIFY_BAD;
+ }
+
+ ret = cpufreq_driver_target(policy, SLEEP_FREQ, 0);
+ cpufreq_cpu_put(policy);
- ret = cpufreq_driver_target(cpufreq_cpu_get(0), SLEEP_FREQ, 0);
if (ret < 0)
return NOTIFY_BAD;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] cpufreq: s3c: fix unbalances of cpufreq policy refcount
2020-01-07 7:53 [PATCH v3] cpufreq: s3c: fix unbalances of cpufreq policy refcount qiwuchen55
@ 2020-01-07 8:01 ` Viresh Kumar
[not found] ` <CAD1-QrohtJFLWDMCYmVs2G5WDcDN_E8xcsNZqJ428cEkohcB0Q@mail.gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2020-01-07 8:01 UTC (permalink / raw)
To: qiwuchen55
Cc: kgene, krzk, rjw, linux-arm-kernel, linux-samsung-soc, linux-pm,
chenqiwu
On 07-01-20, 15:53, qiwuchen55@gmail.com wrote:
> From: chenqiwu <chenqiwu@xiaomi.com>
>
> The cpufreq_reboot_notifier_evt() call cpufreq_cpu_get() to get the
> cpufreq policy of cpu0, meanwhile, it also increments the kobject
> reference count to mark it busy. However, a corresponding call of
> cpufreq_cpu_put() is ignored to decrement the kobject reference count
> back, which may lead to a potential stuck risk that the cpuhp thread
> deadly waits for dropping of kobject refcount when cpufreq policy free.
>
> With this patch, the cpuhp thread can be easily exercised by attempting
> to force an unbind of the CPUfreq driver.
>
> Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> ---
> changes in v3:
> - Rewrite title and commit message.
> ---
> drivers/cpufreq/s3c2416-cpufreq.c | 12 +++++++++++-
> drivers/cpufreq/s5pv210-cpufreq.c | 11 ++++++++++-
> 2 files changed, 21 insertions(+), 2 deletions(-)
Applied. Thanks.
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] cpufreq: s3c: fix unbalances of cpufreq policy refcount
[not found] ` <CAD1-QrohtJFLWDMCYmVs2G5WDcDN_E8xcsNZqJ428cEkohcB0Q@mail.gmail.com>
@ 2020-01-20 5:28 ` Viresh Kumar
2020-01-20 5:43 ` chenqiwu
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2020-01-20 5:28 UTC (permalink / raw)
To: qiwu chen
Cc: kgene, krzk, rjw, linux-arm-kernel, linux-samsung-soc, linux-pm,
chenqiwu
On 19-01-20, 10:25, qiwu chen wrote:
> Hi
> Any progress about this patch?
I already applied it in my tree, it will be part for v5.5-rc1.
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] cpufreq: s3c: fix unbalances of cpufreq policy refcount
2020-01-20 5:28 ` Viresh Kumar
@ 2020-01-20 5:43 ` chenqiwu
0 siblings, 0 replies; 4+ messages in thread
From: chenqiwu @ 2020-01-20 5:43 UTC (permalink / raw)
To: Viresh Kumar
Cc: kgene, krzk, rjw, linux-arm-kernel, linux-samsung-soc, linux-pm,
chenqiwu
On Mon, Jan 20, 2020 at 10:58:21AM +0530, Viresh Kumar wrote:
> On 19-01-20, 10:25, qiwu chen wrote:
> > Hi
> > Any progress about this patch?
>
> I already applied it in my tree, it will be part for v5.5-rc1.
>
> --
> viresh
OK, Thanks a lot!
Qiwu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-20 5:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07 7:53 [PATCH v3] cpufreq: s3c: fix unbalances of cpufreq policy refcount qiwuchen55
2020-01-07 8:01 ` Viresh Kumar
[not found] ` <CAD1-QrohtJFLWDMCYmVs2G5WDcDN_E8xcsNZqJ428cEkohcB0Q@mail.gmail.com>
2020-01-20 5:28 ` Viresh Kumar
2020-01-20 5:43 ` chenqiwu
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).