lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H4HbZ02BdtE47gVyZGdNKj4QWzMSuZgHR6d9RHE36Nv=A@mail.gmail.com>
Date: Thu, 4 Jul 2024 15:37:13 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Viresh Kumar <viresh.kumar@...aro.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 Thu, Jul 4, 2024 at 11:15 AM Viresh Kumar <viresh.kumar@...aro.org> wrote:
>
> 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.
OK, will do.

>
> > > > +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.
OK, I have learned that devm_kzalloc() allocated memory will be
automatically freed at driver dettach.
But I have another question: can the "kfree(table)" after
do_service_request() fail be removed?  Because I think in this case
the probe will fail, then no driver detach happens.

Huacai

>
> --
> viresh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ