cpufreq.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Soren Brinkmann <soren.brinkmann@xilinx.com>
To: Mike Turquette <mturquette@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Russell King <linux@arm.linux.org.uk>
Cc: "Michal Simek" <michal.simek@xilinx.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	cpufreq@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	"Soren Brinkmann" <soren.brinkmann@xilinx.com>
Subject: [RFC PATCH 0/5] Frequency resolution in CCF vs. cpufreq
Date: Wed, 14 May 2014 15:30:50 -0700	[thread overview]
Message-ID: <1400106655-22465-1-git-send-email-soren.brinkmann@xilinx.com> (raw)

Hi,

I have one or two problems with cpufreq and the CCF, which are caused by
rounding/different frequency resolutions.

cpufreq works with kHz, while the CCF uses Hz. On Zynq our default frequency is
666666666 Hz which the CCF, due to rounding, reports as 666666660. And for
cpufreq, which simply divides values it obtains through clk_round_rate() by
1000, 666666.
Since passing 666666 to clk_round_rate() does not result in 666666660
(clk_round_rate() always rounds down!), we chose to put 666667 in the OPP. This
causes issue 1: cpufreq stats are broken.
The OPP is 666667 but clk_get_rate(CPU)/1000 is 666666. Hence the stats module
cannot match the frequency to an OPP.
This is what I address in patch 1, by allowing small deviations when matching a
frequency to an OPP.

Then when looking at our second OPP: 333334. Similar, due to rounding problems
the frequency ends on 4 instead of 3. I think it would be nice if I could
specify the 333333 directly (the 4 there does not really make sense).
That is addressed in patches 2 and 3. Those introduce a new API call for the
CCF (I revived some really old code) which rounds to the closest possible
frequency, as opposed to the closest possible one that does not exceed the
requested. And then we use this function in the cpufreq-cpu0 driver instead.

And finally patch 5, another case where the new API call makes sense.

	Thanks,
	Sören


Soren Brinkmann (5):
  cpufreq: stats: Allow small rounding errors
  clk: Introduce 'clk_round_rate_nearest()'
  cpufreq: cpu0: Use clk_round_rate_nearest()
  ARM: zynq: dt: Use properly rounded frequencies in OPPs
  net: macb: Use clk_round_rate_nearest() API

 arch/arm/boot/dts/zynq-7000.dtsi    |  4 ++--
 drivers/clk/clk.c                   | 26 ++++++++++++++++++++++++--
 drivers/cpufreq/cpufreq-cpu0.c      |  3 ++-
 drivers/cpufreq/cpufreq_stats.c     |  2 +-
 drivers/net/ethernet/cadence/macb.c |  2 +-
 include/linux/clk.h                 | 14 ++++++++++++--
 6 files changed, 42 insertions(+), 9 deletions(-)

-- 
1.9.3.1.ga73a6ad


             reply	other threads:[~2014-05-14 22:30 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 22:30 Soren Brinkmann [this message]
2014-05-14 22:30 ` [RFC PATCH 1/5] cpufreq: stats: Allow small rounding errors Soren Brinkmann
2014-05-14 22:30 ` [RFC PATCH 2/5] clk: Introduce 'clk_round_rate_nearest()' Soren Brinkmann
2014-05-15  7:38   ` Uwe Kleine-König
2014-05-15 14:10     ` Sören Brinkmann
2014-05-19  0:51     ` Sören Brinkmann
2014-05-19 16:19       ` Uwe Kleine-König
2014-05-19 16:41         ` Sören Brinkmann
2014-05-19 17:29           ` Sören Brinkmann
2014-05-20  7:51             ` Uwe Kleine-König
2014-05-20  7:33           ` Uwe Kleine-König
2014-05-20 16:01             ` Sören Brinkmann
2014-05-20 17:48               ` Stephen Boyd
2014-05-20 21:48                 ` Sören Brinkmann
2014-05-21  7:34                   ` Uwe Kleine-König
2014-05-21 15:58                     ` Sören Brinkmann
2014-05-21 18:23                       ` Uwe Kleine-König
2014-05-21 20:19                         ` Sören Brinkmann
2014-05-21 20:33                         ` Mike Turquette
2014-05-22 18:03                           ` Sören Brinkmann
2014-05-22 18:20                             ` Uwe Kleine-König
2014-05-22 20:32                               ` Sören Brinkmann
2014-05-22 21:03                                 ` Mike Turquette
2014-05-22 23:44                                   ` Sören Brinkmann
2014-05-23  1:37                                     ` Mike Turquette
2014-05-23 16:14                                       ` Sören Brinkmann
2014-05-26  6:29                                         ` Viresh Kumar
2014-05-26 11:22                                           ` Rafael J. Wysocki
2014-05-26 11:07                                             ` Viresh Kumar
2014-05-26 11:47                                               ` Rafael J. Wysocki
2014-05-26 21:52                                                 ` Sören Brinkmann
2014-05-28  2:05                                             ` Mike Turquette
2014-05-28 16:17                                               ` Rafael J. Wysocki
2014-06-07  0:44                               ` Sören Brinkmann
2014-05-14 22:30 ` [RFC PATCH 3/5] cpufreq: cpu0: Use clk_round_rate_nearest() Soren Brinkmann
2014-05-14 22:30 ` [RFC PATCH 4/5] ARM: zynq: dt: Use properly rounded frequencies in OPPs Soren Brinkmann
2014-05-14 22:30 ` [RFC PATCH 5/5] net: macb: Use clk_round_rate_nearest() API Soren Brinkmann
2014-05-15  6:12 ` [RFC PATCH 0/5] Frequency resolution in CCF vs. cpufreq Viresh Kumar
2014-05-15 14:05   ` Sören Brinkmann
2014-05-15  7:47 ` Uwe Kleine-König
2014-05-15 12:14   ` Nishanth Menon
2014-05-15 14:00   ` Sören Brinkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1400106655-22465-1-git-send-email-soren.brinkmann@xilinx.com \
    --to=soren.brinkmann@xilinx.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=michal.simek@xilinx.com \
    --cc=mturquette@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).