dt-binding: arm/cpus.txt: fix dynamic-power-coefficient unit
diff mbox series

Message ID 1534869685-22221-1-git-send-email-vincent.guittot@linaro.org
State Superseded
Headers show
Series
  • dt-binding: arm/cpus.txt: fix dynamic-power-coefficient unit
Related show

Commit Message

Vincent Guittot Aug. 21, 2018, 4:41 p.m. UTC
The unit of dynamic-power-coefficient is described as mW/MHz/uV^2 whereas
its usage in the code assumes that unit is mW/GHz/V^2

In drivers/thermal/cpu_cooling.c, the code is :

power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv;
do_div(power, 1000000000);

which can be summarized as :
power (mW) = capacitance * freq_mhz/1000 * (voltage_mv/1000)^2

Furthermore, if we test basic values like :
voltage_mv = 1000mV = 1V
freq_mhz = 1000Mhz = 1Ghz

The minimum possible power, when dynamic-power-coefficient equals 1, will
be :
min power = 1 * 1000  * (1000000)^2 = 10^15 mW
which is not realistic

With the unit used by the code, the min power is
min power =  1 * 1 * 1^2 = 1mW which is far more realistic

Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---
 Documentation/devicetree/bindings/arm/cpus.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Punit Agrawal Aug. 22, 2018, 10:11 a.m. UTC | #1
Hi Vincent,

Thanks for the patch. One comment about the choice of units below.

Vincent Guittot <vincent.guittot@linaro.org> writes:

> The unit of dynamic-power-coefficient is described as mW/MHz/uV^2 whereas
> its usage in the code assumes that unit is mW/GHz/V^2

Instead of choosing GHz as the base, I'd prefer to use uW/MHz/V^2. It'll
avoid introducing fractional GHz value for frequency calculations.

> In drivers/thermal/cpu_cooling.c, the code is :
>
> power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv;
> do_div(power, 1000000000);
>
> which can be summarized as :
> power (mW) = capacitance * freq_mhz/1000 * (voltage_mv/1000)^2

Which would then translate to -

power (mW) = power (uW) / 1000 = capacitance * freq_mhz * (voltage_mv/1000)^2

Thanks,
Punit

>
> Furthermore, if we test basic values like :
> voltage_mv = 1000mV = 1V
> freq_mhz = 1000Mhz = 1Ghz
>
> The minimum possible power, when dynamic-power-coefficient equals 1, will
> be :
> min power = 1 * 1000  * (1000000)^2 = 10^15 mW
> which is not realistic
>
> With the unit used by the code, the min power is
> min power =  1 * 1 * 1^2 = 1mW which is far more realistic
>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
>  Documentation/devicetree/bindings/arm/cpus.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
> index 29e1dc5..0148d7d 100644
> --- a/Documentation/devicetree/bindings/arm/cpus.txt
> +++ b/Documentation/devicetree/bindings/arm/cpus.txt
> @@ -274,7 +274,7 @@ described below.
>  		Usage: optional
>  		Value type: <prop-encoded-array>
>  		Definition: A u32 value that represents the running time dynamic
> -			    power coefficient in units of mW/MHz/uV^2. The
> +			    power coefficient in units of mW/GHz/V^2. The
>  			    coefficient can either be calculated from power
>  			    measurements or derived by analysis.
>  
> @@ -285,7 +285,7 @@ described below.
>  
>  			    Pdyn = dynamic-power-coefficient * V^2 * f
>  
> -			    where voltage is in uV, frequency is in MHz.
> +			    where voltage is in V, frequency is in GHz.
>  
>  Example 1 (dual-cluster big.LITTLE system 32-bit):
Vincent Guittot Aug. 22, 2018, 2:32 p.m. UTC | #2
Hi Amit,

On Wed, 22 Aug 2018 at 12:11, Punit Agrawal <punit.agrawal@arm.com> wrote:
>
> Hi Vincent,
>
> Thanks for the patch. One comment about the choice of units below.
>
> Vincent Guittot <vincent.guittot@linaro.org> writes:
>
> > The unit of dynamic-power-coefficient is described as mW/MHz/uV^2 whereas
> > its usage in the code assumes that unit is mW/GHz/V^2
>
> Instead of choosing GHz as the base, I'd prefer to use uW/MHz/V^2. It'll
> avoid introducing fractional GHz value for frequency calculations.

I don't understand your concern about fractional Ghz value for
frequency calculation ?
I mean, why it's a problem for frequency with Ghz vs Mhz but not a
problem for voltage with V vs mV ?
Don't we have the same "problem" in both case ?

>
> > In drivers/thermal/cpu_cooling.c, the code is :
> >
> > power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv;
> > do_div(power, 1000000000);
> >
> > which can be summarized as :
> > power (mW) = capacitance * freq_mhz/1000 * (voltage_mv/1000)^2
>
> Which would then translate to -
>
> power (mW) = power (uW) / 1000 = capacitance * freq_mhz * (voltage_mv/1000)^2

Not sure that the equation above is correct. If we consider uW/MHz/V^2
for the unit, the equation becomes :
power (mW) = power (uW) / 1000 = capacitance * freq_mhz *
(voltage_mv/1000)^2 / 1000
which can be rearranged as
power (mW) = power (uW) / 1000 = capacitance * freq_mhz/ 1000 *
(voltage_mv/1000)^2

TBH, I don't really mind between  mW/GHz/V^2 or uW/MHz/V^2 as they are
the same at the end
but I don't catch your reasoning

Regards,
Vincent

>
> Thanks,
> Punit
>
> >
> > Furthermore, if we test basic values like :
> > voltage_mv = 1000mV = 1V
> > freq_mhz = 1000Mhz = 1Ghz
> >
> > The minimum possible power, when dynamic-power-coefficient equals 1, will
> > be :
> > min power = 1 * 1000  * (1000000)^2 = 10^15 mW
> > which is not realistic
> >
> > With the unit used by the code, the min power is
> > min power =  1 * 1 * 1^2 = 1mW which is far more realistic
> >
> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> > ---
> >  Documentation/devicetree/bindings/arm/cpus.txt | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
> > index 29e1dc5..0148d7d 100644
> > --- a/Documentation/devicetree/bindings/arm/cpus.txt
> > +++ b/Documentation/devicetree/bindings/arm/cpus.txt
> > @@ -274,7 +274,7 @@ described below.
> >               Usage: optional
> >               Value type: <prop-encoded-array>
> >               Definition: A u32 value that represents the running time dynamic
> > -                         power coefficient in units of mW/MHz/uV^2. The
> > +                         power coefficient in units of mW/GHz/V^2. The
> >                           coefficient can either be calculated from power
> >                           measurements or derived by analysis.
> >
> > @@ -285,7 +285,7 @@ described below.
> >
> >                           Pdyn = dynamic-power-coefficient * V^2 * f
> >
> > -                         where voltage is in uV, frequency is in MHz.
> > +                         where voltage is in V, frequency is in GHz.
> >
> >  Example 1 (dual-cluster big.LITTLE system 32-bit):
Punit Agrawal Aug. 28, 2018, 2:42 p.m. UTC | #3
Vincent Guittot <vincent.guittot@linaro.org> writes:

> Hi Amit,
>
> On Wed, 22 Aug 2018 at 12:11, Punit Agrawal <punit.agrawal@arm.com> wrote:
>>
>> Hi Vincent,
>>
>> Thanks for the patch. One comment about the choice of units below.
>>
>> Vincent Guittot <vincent.guittot@linaro.org> writes:
>>
>> > The unit of dynamic-power-coefficient is described as mW/MHz/uV^2 whereas
>> > its usage in the code assumes that unit is mW/GHz/V^2
>>
>> Instead of choosing GHz as the base, I'd prefer to use uW/MHz/V^2. It'll
>> avoid introducing fractional GHz value for frequency calculations.
>
> I don't understand your concern about fractional Ghz value for
> frequency calculation ?
> I mean, why it's a problem for frequency with Ghz vs Mhz but not a
> problem for voltage with V vs mV ?
> Don't we have the same "problem" in both case ?

You're right. It's the same problem in both cases.

>>
>> > In drivers/thermal/cpu_cooling.c, the code is :
>> >
>> > power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv;
>> > do_div(power, 1000000000);
>> >
>> > which can be summarized as :
>> > power (mW) = capacitance * freq_mhz/1000 * (voltage_mv/1000)^2
>>
>> Which would then translate to -
>>
>> power (mW) = power (uW) / 1000 = capacitance * freq_mhz * (voltage_mv/1000)^2
>
> Not sure that the equation above is correct. If we consider uW/MHz/V^2
> for the unit, the equation becomes :
> power (mW) = power (uW) / 1000 = capacitance * freq_mhz *
> (voltage_mv/1000)^2 / 1000

Yes, I missed the "/ 1000" at the end.

> which can be rearranged as
> power (mW) = power (uW) / 1000 = capacitance * freq_mhz/ 1000 *
> (voltage_mv/1000)^2
>
> TBH, I don't really mind between  mW/GHz/V^2 or uW/MHz/V^2 as they are
> the same at the end
> but I don't catch your reasoning

The problem I was thinking of doesn't hold as it's the same issue with
voltage.

One benefit to go with uW/MHz/V^2 might be the extra resolution that it
provides. I'd prefer to go with uW/MHz/V^2 if there's no compelling
reason to go with anything else.


[...]

>> >
>> > Furthermore, if we test basic values like :
>> > voltage_mv = 1000mV = 1V
>> > freq_mhz = 1000Mhz = 1Ghz
>> >
>> > The minimum possible power, when dynamic-power-coefficient equals 1, will
>> > be :
>> > min power = 1 * 1000  * (1000000)^2 = 10^15 mW
>> > which is not realistic
>> >
>> > With the unit used by the code, the min power is
>> > min power =  1 * 1 * 1^2 = 1mW which is far more realistic
>> >
>> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
>> > ---
>> >  Documentation/devicetree/bindings/arm/cpus.txt | 4 ++--
>> >  1 file changed, 2 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
>> > index 29e1dc5..0148d7d 100644
>> > --- a/Documentation/devicetree/bindings/arm/cpus.txt
>> > +++ b/Documentation/devicetree/bindings/arm/cpus.txt
>> > @@ -274,7 +274,7 @@ described below.
>> >               Usage: optional
>> >               Value type: <prop-encoded-array>
>> >               Definition: A u32 value that represents the running time dynamic
>> > -                         power coefficient in units of mW/MHz/uV^2. The
>> > +                         power coefficient in units of mW/GHz/V^2. The
>> >                           coefficient can either be calculated from power
>> >                           measurements or derived by analysis.
>> >
>> > @@ -285,7 +285,7 @@ described below.
>> >
>> >                           Pdyn = dynamic-power-coefficient * V^2 * f
>> >
>> > -                         where voltage is in uV, frequency is in MHz.
>> > +                         where voltage is in V, frequency is in GHz.
>> >
>> >  Example 1 (dual-cluster big.LITTLE system 32-bit):
Vincent Guittot Aug. 29, 2018, 6:48 a.m. UTC | #4
On Tue, 28 Aug 2018 at 16:42, Punit Agrawal <punit.agrawal@arm.com> wrote:
>
> Vincent Guittot <vincent.guittot@linaro.org> writes:
>
> > Hi Amit,
> >
> > On Wed, 22 Aug 2018 at 12:11, Punit Agrawal <punit.agrawal@arm.com> wrote:
> >>
> >> Hi Vincent,
> >>
> >> Thanks for the patch. One comment about the choice of units below.
> >>
> >> Vincent Guittot <vincent.guittot@linaro.org> writes:
> >>
> >> > The unit of dynamic-power-coefficient is described as mW/MHz/uV^2 whereas
> >> > its usage in the code assumes that unit is mW/GHz/V^2
> >>
> >> Instead of choosing GHz as the base, I'd prefer to use uW/MHz/V^2. It'll
> >> avoid introducing fractional GHz value for frequency calculations.
> >
> > I don't understand your concern about fractional Ghz value for
> > frequency calculation ?
> > I mean, why it's a problem for frequency with Ghz vs Mhz but not a
> > problem for voltage with V vs mV ?
> > Don't we have the same "problem" in both case ?
>
> You're right. It's the same problem in both cases.
>
> >>
> >> > In drivers/thermal/cpu_cooling.c, the code is :
> >> >
> >> > power = (u64)capacitance * freq_mhz * voltage_mv * voltage_mv;
> >> > do_div(power, 1000000000);
> >> >
> >> > which can be summarized as :
> >> > power (mW) = capacitance * freq_mhz/1000 * (voltage_mv/1000)^2
> >>
> >> Which would then translate to -
> >>
> >> power (mW) = power (uW) / 1000 = capacitance * freq_mhz * (voltage_mv/1000)^2
> >
> > Not sure that the equation above is correct. If we consider uW/MHz/V^2
> > for the unit, the equation becomes :
> > power (mW) = power (uW) / 1000 = capacitance * freq_mhz *
> > (voltage_mv/1000)^2 / 1000
>
> Yes, I missed the "/ 1000" at the end.
>
> > which can be rearranged as
> > power (mW) = power (uW) / 1000 = capacitance * freq_mhz/ 1000 *
> > (voltage_mv/1000)^2
> >
> > TBH, I don't really mind between  mW/GHz/V^2 or uW/MHz/V^2 as they are
> > the same at the end
> > but I don't catch your reasoning
>
> The problem I was thinking of doesn't hold as it's the same issue with
> voltage.
>
> One benefit to go with uW/MHz/V^2 might be the extra resolution that it
> provides. I'd prefer to go with uW/MHz/V^2 if there's no compelling
> reason to go with anything else.

Ok, I'm going to update the patch with uW/MHz/V^2

Thanks
>
>
> [...]
>
> >> >
> >> > Furthermore, if we test basic values like :
> >> > voltage_mv = 1000mV = 1V
> >> > freq_mhz = 1000Mhz = 1Ghz
> >> >
> >> > The minimum possible power, when dynamic-power-coefficient equals 1, will
> >> > be :
> >> > min power = 1 * 1000  * (1000000)^2 = 10^15 mW
> >> > which is not realistic
> >> >
> >> > With the unit used by the code, the min power is
> >> > min power =  1 * 1 * 1^2 = 1mW which is far more realistic
> >> >
> >> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> >> > ---
> >> >  Documentation/devicetree/bindings/arm/cpus.txt | 4 ++--
> >> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
> >> > index 29e1dc5..0148d7d 100644
> >> > --- a/Documentation/devicetree/bindings/arm/cpus.txt
> >> > +++ b/Documentation/devicetree/bindings/arm/cpus.txt
> >> > @@ -274,7 +274,7 @@ described below.
> >> >               Usage: optional
> >> >               Value type: <prop-encoded-array>
> >> >               Definition: A u32 value that represents the running time dynamic
> >> > -                         power coefficient in units of mW/MHz/uV^2. The
> >> > +                         power coefficient in units of mW/GHz/V^2. The
> >> >                           coefficient can either be calculated from power
> >> >                           measurements or derived by analysis.
> >> >
> >> > @@ -285,7 +285,7 @@ described below.
> >> >
> >> >                           Pdyn = dynamic-power-coefficient * V^2 * f
> >> >
> >> > -                         where voltage is in uV, frequency is in MHz.
> >> > +                         where voltage is in V, frequency is in GHz.
> >> >
> >> >  Example 1 (dual-cluster big.LITTLE system 32-bit):

Patch
diff mbox series

diff --git a/Documentation/devicetree/bindings/arm/cpus.txt b/Documentation/devicetree/bindings/arm/cpus.txt
index 29e1dc5..0148d7d 100644
--- a/Documentation/devicetree/bindings/arm/cpus.txt
+++ b/Documentation/devicetree/bindings/arm/cpus.txt
@@ -274,7 +274,7 @@  described below.
 		Usage: optional
 		Value type: <prop-encoded-array>
 		Definition: A u32 value that represents the running time dynamic
-			    power coefficient in units of mW/MHz/uV^2. The
+			    power coefficient in units of mW/GHz/V^2. The
 			    coefficient can either be calculated from power
 			    measurements or derived by analysis.
 
@@ -285,7 +285,7 @@  described below.
 
 			    Pdyn = dynamic-power-coefficient * V^2 * f
 
-			    where voltage is in uV, frequency is in MHz.
+			    where voltage is in V, frequency is in GHz.
 
 Example 1 (dual-cluster big.LITTLE system 32-bit):