linux-clk.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Biju Das <biju.das@bp.renesas.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Simon Horman" <horms@verge.net.au>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>,
	"Dien Pham" <dien.pham.ry@rvc.renesas.com>,
	"TAKESHI KIHARA" <takeshi.kihara.df@renesas.com>,
	"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
	"Stephen Boyd" <sboyd@kernel.org>,
	"Michael Turquette" <mturquette@baylibre.com>,
	linux-clk <linux-clk@vger.kernel.org>
Subject: RE: Regarding CPU frequency reported by Salvator-X board
Date: Fri, 13 Dec 2019 11:57:02 +0000	[thread overview]
Message-ID: <OSBPR01MB2103D6BB45CF585DE643CC1CB8540@OSBPR01MB2103.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <CAMuHMdUUYFLtVXNY2p_OcbYAifxsk7+xJRzQgOh0WZVdaf2hQA@mail.gmail.com>

Hi All,

Any update on this issue.

Regards,
Biju

> -----Original Message-----
> From: Geert Uytterhoeven <geert@linux-m68k.org>
> Sent: Monday, October 14, 2019 8:54 AM
> To: Biju Das <biju.das@bp.renesas.com>
> Cc: Geert Uytterhoeven <geert+renesas@glider.be>; Simon Horman
> <horms@verge.net.au>; linux-renesas-soc@vger.kernel.org; Dien Pham
> <dien.pham.ry@rvc.renesas.com>; TAKESHI KIHARA
> <takeshi.kihara.df@renesas.com>; Niklas Söderlund
> <niklas.soderlund+renesas@ragnatech.se>; Stephen Boyd
> <sboyd@kernel.org>; Michael Turquette <mturquette@baylibre.com>;
> linux-clk <linux-clk@vger.kernel.org>
> Subject: Re: Regarding CPU frequency reported by Salvator-X board
> 
> Hi Biju,
> 
> CC clk
> 
> On Mon, Oct 14, 2019 at 9:46 AM Biju Das <biju.das@bp.renesas.com>
> wrote:
> > I have further investigated this issue, please find my findings below
> >
> > The  "cpg_z_clk_round_rate" function is called 2 times from
> "dev_pm_opp_set_rate" (1 is direct call and other through "clk_set_rate")
> function.
> >
> > For 500000000 frequency, after doing math operation(mult =
> > div_u64(rate * 32ULL, prate);), it gets a factor  10--> 10.66
> > truncated to 10 and the frequency returned by the system is  468748125
> >
> > On the second " cpg_z_clk_round_rate ", the below function make the
> value to worse, it gets a value of 9.9999, since it is integer division it is
> truncated to 9.
> > mult = div_u64(rate * 32ULL, prate);
> >
> > Now the frequency 468748125, after doing math operation becomes
> 421874 KHz. This is the problem.
> >
> > So I think the div_64 is wrong here, Instead we could go with
> DIV64_U64_ROUND_CLOSEST.
> >
> > With "DIV64_U64_ROUND_CLOSEST" the factor is 10.66 which is rounded
> to 11.
> >
> > So for 500000, after math operation, it becomes 515624
> >
> > Please share your opinion this issue.
> 
> I don't know what's the best way to solve this.
> 
> Rounding instead of truncating may lead to programming a too high clock
> frequency, which might damage the hardware.
> 
> Please note that the current code no longer uses div_u64(), but div64_ul()
> instead, which should have no impact on your findings.
> 
> > > -----Original Message-----
> > > From: Biju Das
> > > Sent: Thursday, September 19, 2019 11:49 AM
> > > To: Geert Uytterhoeven <geert+renesas@glider.be>; Simon Horman
> > > <horms@verge.net.au>; linux-renesas-soc@vger.kernel.org; Dien Pham
> > > <dien.pham.ry@rvc.renesas.com>; TAKESHI KIHARA
> > > <takeshi.kihara.df@renesas.com>; Niklas Söderlund
> > > <niklas.soderlund+renesas@ragnatech.se>
> > > Subject: Regarding CPU frequency reported by Salvator-X board
> > >
> > > Hi All,
> > >
> > > I started testing  frequency mentioned in OPP table  with M3-W1.1
> > > Salvator-X board (NOT salvator-XS) using user space governor
> > >
> > > The actual frequency reported for 0.5GHz(500000 KHz) is too much
> > > deviated from the target  frequency [INFO] Target frequency: 500000
> > > KHz [INFO] Actual frequency: 421874 KHz
> > >
> > > But if I change the extal value, as per the board schematic
> > > (16.6666MHz), the value is some what closer to target frequency.
> > >   &extal_clk {
> > > -       clock-frequency = <16666666>;
> > > +       clock-frequency = <16666600>;
> > >  };
> > > [INFO] Target frequency: 500000 KHz
> > > [INFO] Actual frequency: 468748 KHz
> > >
> > > Q1) Have any one  seen this issue? Please share your thoughts on this
> issue.
> > >
> > > Note:-
> > > I am not seeing this issue on Salvator-XS board, where the extal_clk
> > > value= 16640000(16.64MHz).
> > >
> > > Please see the logs
> > > with clock-frequency = <16666666>;
> > > -----------------------------------------------
> > > root@salvator-x:/cip-test-scripts# ./opp_t_001.sh  [INFO] Testing
> > > cpufreq for
> > > policy:
> > >  [INFO] /sys/devices/system/cpu/cpufreq/policy0
> > >  [INFO]
> > >  [INFO] CPUs affected:
> > >  [INFO] 0 1
> > >  [INFO]
> > >  [INFO] Available frequencies:
> > >  [INFO] 500000 1000000 1500000
> > >  [INFO]
> > >  [INFO] Target frequency: 500000 KHz  [INFO] Actual frequency:
> > > 421874 KHz  [INFO]  [INFO] Target frequency: 1000000 KHz  [INFO]
> > > Actual frequency: 937499 KHz  [INFO]  [INFO] Target frequency:
> > > 1500000 KHz  [INFO] Actual frequency: 1499999 KHz  [INFO]  [INFO]
> > > Testing cpufreq for policy:
> > >  [INFO] /sys/devices/system/cpu/cpufreq/policy2
> > >  [INFO]
> > >  [INFO] CPUs affected:
> > >  [INFO] 2 3 4 5
> > >  [INFO]
> > >  [INFO] Available frequencies:
> > >  [INFO] 800000 1000000 1200000
> > >  [INFO]
> > >  [INFO] Target frequency: 800000 KHz  [INFO] Actual frequency:
> > > 749999 KHz  [INFO]  [INFO] Target frequency: 1000000 KHz  [INFO]
> > > Actual frequency: 974999 KHz  [INFO]  [INFO] Target frequency:
> > > 1200000 KHz  [INFO] Actual frequency: 1199999 KHz
> > >
> > > With clock-frequency = <16666600>
> > > ----------------------------------------------
> > > root@salvator-x:/cip-test-scripts# ./opp_t_001.sh  [INFO] Testing
> > > cpufreq for
> > > policy:
> > >  [INFO] /sys/devices/system/cpu/cpufreq/policy0
> > >  [INFO]
> > >  [INFO] CPUs affected:
> > >  [INFO] 0 1
> > >  [INFO]
> > >  [INFO] Available frequencies:
> > >  [INFO] 500000 1000000 1500000
> > >  [INFO]
> > >  [INFO] Target frequency: 500000 KHz  [INFO] Actual frequency:
> > > 468748 KHz  [INFO]  [INFO] Target frequency: 1000000 KHz  [INFO]
> > > Actual frequency: 937496 KHz  [INFO]  [INFO] Target frequency:
> > > 1500000 KHz  [INFO] Actual frequency: 1499994 KHz  [INFO]  [INFO]
> > > Testing cpufreq for policy:
> > >  [INFO] /sys/devices/system/cpu/cpufreq/policy2
> > >  [INFO]
> > >  [INFO] CPUs affected:
> > >  [INFO] 2 3 4 5
> > >  [INFO]
> > >  [INFO] Available frequencies:
> > >  [INFO] 800000 1000000 1200000
> > >  [INFO]
> > >  [INFO] Target frequency: 800000 KHz  [INFO] Actual frequency:
> > > 787496 KHz  [INFO]  [INFO] Target frequency: 1000000 KHz  [INFO]
> > > Actual frequency: 974996 KHz  [INFO]  [INFO] Target frequency:
> > > 1200000 KHz  [INFO] Actual frequency: 1199995 KHz
> > >
> > > Regards,
> > > Biju
> > >
> >
> 
> 
> --
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

      reply	other threads:[~2019-12-13 20:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <OSBPR01MB21035AD5CA51E3CCFE6F61C6B8890@OSBPR01MB2103.jpnprd01.prod.outlook.com>
     [not found] ` <OSBPR01MB2103F7095937F52BD9D2FFDEB8900@OSBPR01MB2103.jpnprd01.prod.outlook.com>
2019-10-14  7:54   ` Regarding CPU frequency reported by Salvator-X board Geert Uytterhoeven
2019-12-13 11:57     ` Biju Das [this message]

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=OSBPR01MB2103D6BB45CF585DE643CC1CB8540@OSBPR01MB2103.jpnprd01.prod.outlook.com \
    --to=biju.das@bp.renesas.com \
    --cc=dien.pham.ry@rvc.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=horms@verge.net.au \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=sboyd@kernel.org \
    --cc=takeshi.kihara.df@renesas.com \
    /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 NNTP newsgroup(s).