From: Jerome Brunet <jbrunet@baylibre.com>
To: Shawn Lin <shawn.lin@rock-chips.com>,
Heiko Stuebner <heiko@sntech.de>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: linux-clk@vger.kernel.org
Subject: Re: [PATCH] clk: Don't show the incorrect clock phase
Date: Thu, 08 Mar 2018 11:04:57 +0100 [thread overview]
Message-ID: <1520503497.4264.12.camel@baylibre.com> (raw)
In-Reply-To: <1520495643-164458-1-git-send-email-shawn.lin@rock-chips.com>
On Thu, 2018-03-08 at 15:54 +0800, Shawn Lin wrote:
> It's found that the clock phase output from clk_summary is
> wrong compared to the actual phase reading from the register.
>
> cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample
> sdio_sample 0 1 0 50000000 0 -22
>
> It expose an issue that clk core, clk_core_get_phase, always
> return the cached core->phase which should be either updated
> by calling clk_set_phase or directly from the first place the
> clk was registered. When registering the clk, the core->phase
> geting from ->get_phase() may return negative value indicating
> error. This is quite common since the clk's phase may be highly
> related to its praent chain, but it was temporary orphan when
> registered, since its parent chain hadn't be ready at that time,
> so the clk drivers decide to return error in this case. However,
> if no clk_set_phase is called, core->phase would never be updated.
> This is wrong, and we should try to update it when all its parent
> chain is settled down, like the way of updating clock rate for that.
> It's not derserved to complicate the code but just update it if
> seeing it's a nagative number when calling clk_core_get_phase, which
> would be much simple and enough.
>
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
>
> drivers/clk/clk.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 0f686a9..b49e4c8 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2370,6 +2370,15 @@ static int clk_core_get_phase(struct clk_core *core)
> int ret;
>
> clk_prepare_lock();
> + /*
> + * clk_set_phase always set the phase in [0, 360],
> + * so the only reason for core->phase to be nagative
> + * number is it's a error number propagated back from
> + * the clk drivers. So we should try to update it if
> + * possible.
> + */
> + if (core->phase < 0 && core->ops->get_phase)
Why bother with core->phase < 0 ?
if core->ops->get_phase is available, why not call it anyway ?
The phase may have changed since it was cached.
A typical example would be phases based on adding fixed delays:
* Take a 200MHz clock and set phase to 180 => a 2.5ns delay is set
* Clock rate change to 100MHz but delay is still 2.5ns
-> cached phase = 180
-> actual phase = 90
> + core->phase = core->ops->get_phase(core->hw);
> ret = core->phase;
> clk_prepare_unlock();
>
next prev parent reply other threads:[~2018-03-08 10:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-08 7:54 [PATCH] clk: Don't show the incorrect clock phase Shawn Lin
2018-03-08 9:40 ` Geert Uytterhoeven
2018-03-08 11:15 ` Shawn Lin
2018-03-08 10:04 ` Jerome Brunet [this message]
2018-03-08 11:28 ` Shawn Lin
2018-03-08 11:37 ` Jerome Brunet
2018-03-08 11:39 ` Jerome Brunet
2018-03-08 11:46 ` Shawn Lin
2018-03-08 12:03 ` Jerome Brunet
2018-03-08 12:11 ` Shawn Lin
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=1520503497.4264.12.camel@baylibre.com \
--to=jbrunet@baylibre.com \
--cc=heiko@sntech.de \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=shawn.lin@rock-chips.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