All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeffrey Hugo <jhugo@codeaurora.org>
To: jbrunet@baylibre.com, mturquette@baylibre.com, sboyd@kernel.org
Cc: linux-clk@vger.kernel.org
Subject: Does clk_core_round_rate_nolock() really do the right thing?
Date: Tue, 13 Nov 2018 15:37:54 -0700	[thread overview]
Message-ID: <c9984aa1-4c87-d97d-eec8-4adbe9bb243e@codeaurora.org> (raw)

"clk: rework calls to round and determine rate callbacks" [1] added 
clk_core_round_rate_nolock().

I question that it does the right thing in a specific scenario.

Lets assume we have a clock that is currently running at 5Mhz, but we 
want to have it run at 400Khz, and the clock supports both rates. 
Perhaps the clock is for a hardware block, where in to switch 
operational modes, the clock frequency is expected to run at the lower 
frequency.

The driver may call clk_set_rate() to do so, resulting in the following 
call flow (based on 4.20-rc2)-

clk_set_rate()
clk_core_set_rate_nolock()
clk_core_req_round_rate_nolock()
clk_core_round_rate_nolock()

In clk_core_round_rate_nolock(), lets assume the conditionals do not 
apply (clk core cannot round, and set rate parent flag isn't set).  In 
that case, the requested rate is modified by this line -

req->rate = core->rate;

This transforms the request from 400Khz to 5Mhz (the current clock rate).

What will then end up happening is we return from 
clk_core_round_rate_nolock(), through clk_core_req_round_rate_nolock() 
back to clk_core_set_rate_nolock() where we check to see if the rate 
returned from the "rounding" is the same as the current clock rate (5Mhz 
== 5Mhz).  Thus we conclude there is nothing to be done, and we return 
success back up to the caller having not actually touched the clock or 
set the requested rate.

On the face of it, this seems incorrect to me, although I am a neophyte 
to the clock framework.  Is this really the expected behavior, to leave 
the clock at the current rate even though the requested rate is 
different?  If so, why?


[1] - 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0f6cc2b8e94da5400528c0ba7fd910392ec598a2

-- 
Jeffrey Hugo
Qualcomm Datacenter Technologies as an affiliate of Qualcomm 
Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

             reply	other threads:[~2018-11-13 22:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-13 22:37 Jeffrey Hugo [this message]
2018-11-13 22:47 ` Does clk_core_round_rate_nolock() really do the right thing? Stephen Boyd

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=c9984aa1-4c87-d97d-eec8-4adbe9bb243e@codeaurora.org \
    --to=jhugo@codeaurora.org \
    --cc=jbrunet@baylibre.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.