[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240704031532.5bkh4nr7d3vcvzwq@vireshk-i7>
Date: Thu, 4 Jul 2024 08:45:32 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: Huacai Chen <chenhuacai@...ngson.cn>,
"Rafael J . Wysocki" <rafael@...nel.org>, loongarch@...ts.linux.dev,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
Xuerui Wang <kernel@...0n.name>,
Jiaxun Yang <jiaxun.yang@...goat.com>,
Binbin Zhou <zhoubinbin@...ngson.cn>
Subject: Re: [PATCH V2 2/2] cpufreq: Add Loongson-3 CPUFreq driver support
On 03-07-24, 22:37, Huacai Chen wrote:
> On Wed, Jul 3, 2024 at 6:18 PM Viresh Kumar <viresh.kumar@...aro.org> wrote:
> > > +static int loongson3_cpufreq_target(struct cpufreq_policy *policy, unsigned int index)
> > > +{
> > > + /* setting the cpu frequency */
> > > + return loongson3_cpufreq_set(policy, index);
> >
> > Why use a separate function for calling do_service_request() ? Just
> > open code it here.
> Hmm, there is a loongson3_cpufreq_get() function, so I make a
> loongson3_cpufreq_set() function, too.
The counterpart of _get is _target and so a separate set function
isn't required at all. Just get rid of it.
> > > +static int loongson3_cpufreq_get_freq_table(int cpu)
> > > +{
> > > + int i, ret, boost_level, max_level, freq_level;
> > > + struct cpufreq_frequency_table *table;
> > > +
> > > + if (per_cpu(freq_table, cpu))
> > > + return 0;
> > > +
> > > + ret = do_service_request(cpu, 0, CMD_GET_FREQ_LEVEL_NUM, 0, 0);
> > > + if (ret < 0)
> > > + return ret;
> > > + max_level = ret;
> > > +
> > > + ret = do_service_request(cpu, 0, CMD_GET_FREQ_BOOST_LEVEL, 0, 0);
> > > + if (ret < 0)
> > > + return ret;
> > > + boost_level = ret;
> > > +
> > > + freq_level = min(max_level, FREQ_MAX_LEVEL);
> > > + table = kzalloc(sizeof(struct cpufreq_frequency_table) * (freq_level + 1), GFP_KERNEL);
> >
> > devm_kcalloc(pdev, ...) instead ?
> I remember you told me this in V1, but devm_kalloc() needs a pdev
> instance, which doesn't exist here, so I keep kzalloc().
See how drivers/cpufreq/brcmstb-avs-cpufreq.c stores the pdev in
cpufreq_driver's driver_data and reuses later on.
--
viresh
Powered by blists - more mailing lists