[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180706101858.GC11862@e108498-lin.cambridge.arm.com>
Date: Fri, 6 Jul 2018 11:18:58 +0100
From: Quentin Perret <quentin.perret@....com>
To: Vincent Guittot <vincent.guittot@...aro.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
"Rafael J. Wysocki" <rjw@...ysocki.net>,
linux-kernel <linux-kernel@...r.kernel.org>,
"open list:THERMAL" <linux-pm@...r.kernel.org>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
Ingo Molnar <mingo@...hat.com>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Morten Rasmussen <morten.rasmussen@....com>,
Chris Redpath <chris.redpath@....com>,
Patrick Bellasi <patrick.bellasi@....com>,
Valentin Schneider <valentin.schneider@....com>,
Thara Gopinath <thara.gopinath@...aro.org>,
viresh kumar <viresh.kumar@...aro.org>,
Todd Kjos <tkjos@...gle.com>,
Joel Fernandes <joel@...lfernandes.org>,
"Cc: Steve Muckle" <smuckle@...gle.com>, adharmap@...cinc.com,
"Kannan, Saravana" <skannan@...cinc.com>, pkondeti@...eaurora.org,
Juri Lelli <juri.lelli@...hat.com>,
Eduardo Valentin <edubezval@...il.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
currojerez@...eup.net, Javi Merino <javi.merino@...nel.org>
Subject: Re: [RFC PATCH v4 12/12] OPTIONAL: cpufreq: dt: Register an Energy
Model
On Friday 06 Jul 2018 at 12:10:02 (+0200), Vincent Guittot wrote:
> On Thu, 28 Jun 2018 at 13:41, Quentin Perret <quentin.perret@....com> wrote:
> > +static int of_est_power(unsigned long *mW, unsigned long *KHz, int cpu)
> > +{
> > + unsigned long mV, Hz, MHz;
> > + struct device *cpu_dev;
> > + struct dev_pm_opp *opp;
> > + struct device_node *np;
> > + u32 cap;
> > + u64 tmp;
> > +
> > + cpu_dev = get_cpu_device(cpu);
> > + if (!cpu_dev)
> > + return -ENODEV;
> > +
> > + np = of_node_get(cpu_dev->of_node);
> > + if (!np)
> > + return -EINVAL;
> > +
> > + if (of_property_read_u32(np, "dynamic-power-coefficient", &cap))
> > + return -EINVAL;
> > +
> > + Hz = *KHz * 1000;
> > + opp = dev_pm_opp_find_freq_ceil(cpu_dev, &Hz);
> > + if (IS_ERR(opp))
> > + return -EINVAL;
> > +
> > + mV = dev_pm_opp_get_voltage(opp) / 1000;
> > + dev_pm_opp_put(opp);
> > +
> > + MHz = Hz / 1000000;
> > + tmp = (u64)cap * mV * mV * MHz;
> > + do_div(tmp, 1000000000);
>
> Could you explain the formula above ? and especially the 1000000000 it
> seems related to the use of mV and mW instead of uV and uW ...
That's correct, this is just a matter of units. I simply tried to
reproduce here what is currently done for IPA:
https://elixir.bootlin.com/linux/latest/source/drivers/thermal/cpu_cooling.c#L252
>
> Can't you just optimize that into
> tmp = (u64)cap * mV * mV * Hz;
> do_div(tmp, 1000);
I don't think that'll work. If you use Hz instead of MHz you'll need to
divide tmp by 1000000000000000 to get milli-watts, as specified by the
EM framework.
FYI, I don't consider this patch to be ready to be merged. I kept it
self-contained and simple for the example but I actually think that this
of_est_power function should probably be factored-out somewhere else.
scpi-cpufreq could use it as well. Anyway, I guess we can discuss that
later once the APIs of the EM framework are agreed :-)
Thanks,
Quentin
Powered by blists - more mailing lists