Re: [v5, PATCH 4/5] cpufreq: mediatek: add opp notification for SVS support
From: Viresh Kumar
Date: Wed Mar 11 2020 - 02:06:33 EST
On 10-03-20, 16:11, andrew-sh.cheng wrote:
> On Tue, 2019-12-10 at 14:43 +0800, Viresh Kumar wrote:
> > On 09-12-19, 14:56, andrew-sh.cheng wrote:
> > > On Wed, 2019-11-27 at 14:06 +0530, Viresh Kumar wrote:
> > > > On 26-11-19, 19:50, Andrew-sh.Cheng wrote:
> > > > > + if (!IS_ERR(opp_item))
> > > > > + dev_pm_opp_put(opp_item);
> > > > > + else
> > > > > + freq = 0;
> > > > > +
> > > >
> > > > What is the purpose of the above code ?
> > > When dev_pm_opp_find_freq_ceil() doesn't find matching opp item, freq
> > > value won't be set.
> > > Set it as 0 for below checking
> > > >
> > > > > + /* case of current opp is disabled */
> > > > > + if (freq == 0 || freq != info->opp_freq) {
> > > > > + // find an enable opp item
> > > > > + freq = 1;
> > > > > + opp_item = dev_pm_opp_find_freq_ceil(info->cpu_dev,
> > > > > + &freq);
> > > > > + if (!IS_ERR(opp_item)) {
> > > > > + dev_pm_opp_put(opp_item);
> > > > > + policy = cpufreq_cpu_get(info->opp_cpu);
> > > > > + if (policy) {
> > > > > + cpufreq_driver_target(policy,
> > > > > + freq / 1000,
> > > > > + CPUFREQ_RELATION_L);
> > > >
> > > > Why don't you simply call this instead of all the code in the else
> > > > block ?
> > > These else code is used to check "current opp item is disabled or not".
> > > If not, do nothing.
> > > If current opp item is disabled, need to find an not-disabled opp item,
> > > and set frequency to it.
> >
> > Right. So this notifier helper of yours receive the opp which is getting
> > disabled, why don't you compare its frequency directly to see if the current OPP
> > is getting disabled ?
> Sorry to overlook your question.
> This is because when the opp is disabled,
> we cannot use dev_pm_opp_get_freq() to get frequency of that opp.
> There is a check:
> if (IS_ERR_OR_NULL(opp) || !opp->available) {
I think we can remove the available check here, as we are jut trying
to find frequency of an OPP we already have. Send a patch for that
please.
> pr_err("%s: Invalid parameters\n", __func__);
> return 0;
>
> >
>
--
viresh