All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Stephen Boyd <sboyd@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	kernel@pengutronix.de, linux-clk@vger.kernel.org
Subject: Re: [PATCH] clk: Disambiguate comment about clk_get_rate() for disabled clocks
Date: Thu, 9 Feb 2023 15:57:15 +0000	[thread overview]
Message-ID: <Y+UX2ysd1B5/cHpk@shell.armlinux.org.uk> (raw)
In-Reply-To: <20230201082309.233348-1-u.kleine-koenig@pengutronix.de>

On Wed, Feb 01, 2023 at 09:23:09AM +0100, Uwe Kleine-König wrote:
> The sentence "[clk_get_rate()] is only valid once the clock source has
> been enabled." can be understood in two ways:
> 
> a) When called for a disabled clock the return value might be wrong; or
> b) The disabled clock must be enabled before it runs at the returned
> rate.
> 
> It's hard to find evidence what is actually meant, but given that the
> clock tree can change between the call to clk_get_rate() and the return
> of a later clk_enable() call, it's prudent to assume a).
> 
> Adapt the comment accordingly to be unambiguous.

Sorry for the late reply, I've been suffering with Covid for the last
nine days.

From the API perspective, it's both. Essentially, if the clock isn't
enabled, then the return value is completely undefined by the API and
no one should trust it.

It's one of the reasons why:

	clk_set_rate(clk, r);
	v = clk_get_rate(clk);

should not be used when what is actually required is:

	v = clk_round_rate(clk, r);

	...

	clk_set_rate(clk, r);

Note: r to clk_set_rate() not v.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2023-02-09 15:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01  8:23 [PATCH] clk: Disambiguate comment about clk_get_rate() for disabled clocks Uwe Kleine-König
2023-02-09 15:57 ` Russell King (Oracle) [this message]
2023-02-14  9:06   ` Uwe Kleine-König
2023-04-06  9:26     ` Uwe Kleine-König

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=Y+UX2ysd1B5/cHpk@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=linux-clk@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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.