diff mbox

[RFC] Migrate to Hz resolution for OPP binding

Message ID 672dd8e9-2857-49fb-848f-d38d38b23c9b@BN1BFFO11FD024.protection.gbl (mailing list archive)
State RFC, archived
Headers show

Commit Message

Soren Brinkmann May 20, 2014, 10:30 p.m. UTC
Hi,

I guess this is just to evaluate how big the lynch mob will be. Anyway:
Triggered by this discussion https://lkml.org/lkml/2014/5/15/46, I
looked a little into what it would take to migrate everybody to Hz
frequency resolutions to avoid all the conversions between cpufreq, CCF,
OPPs, etc.
Turns out, OPPs are already stored in Hz resolution in the kernel, but the DT
bindings use kHz resolution to specify them in DT. So, code-wise there
is just a removal of a multiplication in the OPP parser (see below), but
then there are the DT bindings...

As plan B, I was thinking to add the property 'operating-points-hz'...

Any better ideas?




	Thanks,
	Sören

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Nishanth Menon May 20, 2014, 11:11 p.m. UTC | #1
On Tue, May 20, 2014 at 5:30 PM, Sören Brinkmann
<soren.brinkmann@xilinx.com> wrote:
> Hi,
>
> I guess this is just to evaluate how big the lynch mob will be. Anyway:
> Triggered by this discussion https://lkml.org/lkml/2014/5/15/46, I
> looked a little into what it would take to migrate everybody to Hz
> frequency resolutions to avoid all the conversions between cpufreq, CCF,
> OPPs, etc.
> Turns out, OPPs are already stored in Hz resolution in the kernel, but the DT
> bindings use kHz resolution to specify them in DT. So, code-wise there
> is just a removal of a multiplication in the OPP parser (see below), but
> then there are the DT bindings...

Yep :( unfortunately, so :(

>
> As plan B, I was thinking to add the property 'operating-points-hz'...
>
> Any better ideas?

property operating-points-hz as a bool perhaps -> that modifies the
description and maintains legacy dtb support sounds OK to me if DT
folks and Rafael are ok with it as well.

Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pavel Machek May 21, 2014, 2:05 p.m. UTC | #2
> > As plan B, I was thinking to add the property 'operating-points-hz'...
> >
> > Any better ideas?
> 
> property operating-points-hz as a bool perhaps -> that modifies the
> description and maintains legacy dtb support sounds OK to me if DT
> folks and Rafael are ok with it as well.

That should like a terrible hack :-(.
Rob Herring May 22, 2014, 1:27 p.m. UTC | #3
On Tue, May 20, 2014 at 5:30 PM, Sören Brinkmann
<soren.brinkmann@xilinx.com> wrote:
> Hi,
>
> I guess this is just to evaluate how big the lynch mob will be. Anyway:
> Triggered by this discussion https://lkml.org/lkml/2014/5/15/46, I
> looked a little into what it would take to migrate everybody to Hz
> frequency resolutions to avoid all the conversions between cpufreq, CCF,
> OPPs, etc.
> Turns out, OPPs are already stored in Hz resolution in the kernel, but the DT
> bindings use kHz resolution to specify them in DT. So, code-wise there
> is just a removal of a multiplication in the OPP parser (see below), but
> then there are the DT bindings...

Add this to the list of issues with the current OPP binding and define
a new binding, not a band-aid.

> As plan B, I was thinking to add the property 'operating-points-hz'...
>
> Any better ideas?

Fix clk_round_rate to specify how you want to round. There are
usecases for both rounding up and down. Don't you have the same
rounding problem with hz? Assume the person filling in OPP values
knows nothing about the kernel and you could have values rounded both
ways.

Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Soren Brinkmann May 22, 2014, 3:36 p.m. UTC | #4
Hi Rob,

On Thu, 2014-05-22 at 08:27AM -0500, Rob Herring wrote:
> On Tue, May 20, 2014 at 5:30 PM, Sören Brinkmann
> <soren.brinkmann@xilinx.com> wrote:
> > Hi,
> >
> > I guess this is just to evaluate how big the lynch mob will be. Anyway:
> > Triggered by this discussion https://lkml.org/lkml/2014/5/15/46, I
> > looked a little into what it would take to migrate everybody to Hz
> > frequency resolutions to avoid all the conversions between cpufreq, CCF,
> > OPPs, etc.
> > Turns out, OPPs are already stored in Hz resolution in the kernel, but the DT
> > bindings use kHz resolution to specify them in DT. So, code-wise there
> > is just a removal of a multiplication in the OPP parser (see below), but
> > then there are the DT bindings...
> 
> Add this to the list of issues with the current OPP binding and define
> a new binding, not a band-aid.
> 
> > As plan B, I was thinking to add the property 'operating-points-hz'...
> >
> > Any better ideas?
> 
> Fix clk_round_rate to specify how you want to round. There are
> usecases for both rounding up and down. Don't you have the same
> rounding problem with hz? Assume the person filling in OPP values
> knows nothing about the kernel and you could have values rounded both
> ways.

Yes the issue would not be resolved by this alone. But currently the CCF
and OPPs in the kernel use Hz. And if you look at the interaction
between those frameworks with cpufreq, there are plenty of
multiplications/divisions by 1000 to convert between those, with even a
greater loss of accuracy. So, I think agreeing on using Hz as smallest
reasonable frequency resolution across all these frameworks would be a
first step into the right direction.

	Thanks,
	Sören
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
index 25538675d59e..61795111e8ca 100644
--- a/drivers/base/power/opp.c
+++ b/drivers/base/power/opp.c
@@ -731,7 +731,7 @@  int of_init_opp_table(struct device *dev)
 
 	val = prop->value;
 	while (nr) {
-		unsigned long freq = be32_to_cpup(val++) * 1000;
+		unsigned long freq = be32_to_cpup(val++);
 		unsigned long volt = be32_to_cpup(val++);
 
 		if (dev_pm_opp_add(dev, freq, volt)) {