[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190617030228.3ubbmpgyl6nvesu2@vireshk-i7>
Date: Mon, 17 Jun 2019 08:32:28 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Matthias Kaehlcke <mka@...omium.org>
Cc: Rafael Wysocki <rjw@...ysocki.net>, linux-pm@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>,
Qais.Yousef@....com, juri.lelli@...il.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH V3 4/5] cpufreq: Register notifiers with the PM QoS
framework
On 14-06-19, 09:46, Matthias Kaehlcke wrote:
> Hi Viresh,
>
> On Mon, Jun 10, 2019 at 04:21:35PM +0530, Viresh Kumar wrote:
> > This registers the notifiers for min/max frequency constraints with the
> > PM QoS framework. The constraints are also taken into consideration in
> > cpufreq_set_policy().
> >
> > This also relocates cpufreq_policy_put_kobj() as it is required to be
> > called from cpufreq_policy_alloc() now.
> >
> > No constraints are added until now though.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
> > ---
> > drivers/cpufreq/cpufreq.c | 139 +++++++++++++++++++++++++++++++-------
> > include/linux/cpufreq.h | 4 ++
> > 2 files changed, 120 insertions(+), 23 deletions(-)
> >
> > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > index 85ff958e01f1..547d221b2ff2 100644
> > --- a/drivers/cpufreq/cpufreq.c
> > +++ b/drivers/cpufreq/cpufreq.c
> > @@ -26,6 +26,7 @@
> > #include <linux/kernel_stat.h>
> > #include <linux/module.h>
> > #include <linux/mutex.h>
> > +#include <linux/pm_qos.h>
> > #include <linux/slab.h>
> > #include <linux/suspend.h>
> > #include <linux/syscore_ops.h>
> > @@ -1126,11 +1127,77 @@ static void handle_update(struct work_struct *work)
> > cpufreq_update_policy(cpu);
> > }
> >
> > +static void cpufreq_update_freq_work(struct work_struct *work)
> > +{
> > + struct cpufreq_policy *policy =
> > + container_of(work, struct cpufreq_policy, req_work);
> > + struct cpufreq_policy new_policy = *policy;
> > +
> > + /* We should read constraint values from QoS layer */
> > + new_policy.min = 0;
> > + new_policy.max = UINT_MAX;
> > +
> > + down_write(&policy->rwsem);
> > +
> > + if (!policy_is_inactive(policy))
> > + cpufreq_set_policy(policy, &new_policy);
> > +
> > + up_write(&policy->rwsem);
> > +}
> > +
> > +static int cpufreq_update_freq(struct cpufreq_policy *policy)
> > +{
> > + schedule_work(&policy->req_work);
>
> I think you need to add a cancel_work_sync() in cpufreq_policy_free()
> to make sure the work doesn't run after the policy has been freed.
Right, added this to the commit.
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 547d221b2ff2..878add2cac3c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1289,6 +1289,8 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy)
DEV_PM_QOS_MAX_FREQUENCY);
dev_pm_qos_remove_notifier(dev, &policy->nb_min,
DEV_PM_QOS_MIN_FREQUENCY);
+ cancel_work_sync(&policy->req_work);
+
cpufreq_policy_put_kobj(policy);
free_cpumask_var(policy->real_cpus);
free_cpumask_var(policy->related_cpus);
--
viresh
Powered by blists - more mailing lists