From: Viresh Kumar <viresh.kumar@linaro.org> To: qiwuchen55@gmail.com Cc: mmayer@broadcom.com, rjw@rjwysocki.net, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chenqiwu <chenqiwu@xiaomi.com> Subject: Re: [PATCH v4] cpufreq: brcmstb-avs: fix imbalance of cpufreq policy refcount Date: Mon, 20 Jan 2020 13:24:38 +0530 [thread overview] Message-ID: <20200120075438.pxscoeluf4qwblag@vireshk-i7> (raw) In-Reply-To: <1579506088-6736-1-git-send-email-qiwuchen55@gmail.com> On 20-01-20, 15:41, qiwuchen55@gmail.com wrote: > From: chenqiwu <chenqiwu@xiaomi.com> > > brcm_avs_cpufreq_get() calls cpufreq_cpu_get() to get the cpufreq > policy, 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 v4: > - Rewrit commit message. > - Use cpufreq_cpu_get() and a corresponding cpufreq_cpu_put() > instead of cpufreq_get_policy() for promoting efficiency. > --- > drivers/cpufreq/brcmstb-avs-cpufreq.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c > index 77b0e5d..0767206 100644 > --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c > +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c > @@ -453,7 +453,13 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv) > static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) > { > struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); > - struct private_data *priv = policy->driver_data; > + struct private_data *priv; > + > + if (!policy) > + return 0; > + As I told you earlier, this isn't required as policy can't be NULL here. > + priv = policy->driver_data; > + cpufreq_cpu_put(policy); > > return brcm_avs_get_frequency(priv->base); > } Applied the patch with following diff: req/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c index 77b0e5d0fb13..4f86ce2db34f 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c @@ -455,6 +455,8 @@ static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); struct private_data *priv = policy->driver_data; + cpufreq_cpu_put(policy); + return brcm_avs_get_frequency(priv->base); } -- viresh
WARNING: multiple messages have this Message-ID (diff)
From: Viresh Kumar <viresh.kumar@linaro.org> To: qiwuchen55@gmail.com Cc: f.fainelli@gmail.com, linux-pm@vger.kernel.org, rjw@rjwysocki.net, bcm-kernel-feedback-list@broadcom.com, mmayer@broadcom.com, chenqiwu <chenqiwu@xiaomi.com>, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v4] cpufreq: brcmstb-avs: fix imbalance of cpufreq policy refcount Date: Mon, 20 Jan 2020 13:24:38 +0530 [thread overview] Message-ID: <20200120075438.pxscoeluf4qwblag@vireshk-i7> (raw) In-Reply-To: <1579506088-6736-1-git-send-email-qiwuchen55@gmail.com> On 20-01-20, 15:41, qiwuchen55@gmail.com wrote: > From: chenqiwu <chenqiwu@xiaomi.com> > > brcm_avs_cpufreq_get() calls cpufreq_cpu_get() to get the cpufreq > policy, 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 v4: > - Rewrit commit message. > - Use cpufreq_cpu_get() and a corresponding cpufreq_cpu_put() > instead of cpufreq_get_policy() for promoting efficiency. > --- > drivers/cpufreq/brcmstb-avs-cpufreq.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c > index 77b0e5d..0767206 100644 > --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c > +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c > @@ -453,7 +453,13 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv) > static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) > { > struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); > - struct private_data *priv = policy->driver_data; > + struct private_data *priv; > + > + if (!policy) > + return 0; > + As I told you earlier, this isn't required as policy can't be NULL here. > + priv = policy->driver_data; > + cpufreq_cpu_put(policy); > > return brcm_avs_get_frequency(priv->base); > } Applied the patch with following diff: req/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c index 77b0e5d0fb13..4f86ce2db34f 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c @@ -455,6 +455,8 @@ static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); struct private_data *priv = policy->driver_data; + cpufreq_cpu_put(policy); + return brcm_avs_get_frequency(priv->base); } -- viresh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-01-20 7:54 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-20 7:41 [PATCH v4] cpufreq: brcmstb-avs: fix imbalance of cpufreq policy refcount qiwuchen55 2020-01-20 7:41 ` qiwuchen55 2020-01-20 7:54 ` Viresh Kumar [this message] 2020-01-20 7:54 ` Viresh Kumar
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=20200120075438.pxscoeluf4qwblag@vireshk-i7 \ --to=viresh.kumar@linaro.org \ --cc=bcm-kernel-feedback-list@broadcom.com \ --cc=chenqiwu@xiaomi.com \ --cc=f.fainelli@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-pm@vger.kernel.org \ --cc=mmayer@broadcom.com \ --cc=qiwuchen55@gmail.com \ --cc=rjw@rjwysocki.net \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.