From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v8 6/7] clk: Add floor and ceiling constraints to clock rates
Date: Tue, 02 Sep 2014 17:13:46 -0700 [thread overview]
Message-ID: <20140903001346.5251.47709@quantum> (raw)
In-Reply-To: <1409585675-26894-3-git-send-email-tomeu.vizoso@collabora.com>
Quoting Tomeu Vizoso (2014-09-01 08:34:34)
> @@ -1633,6 +1636,13 @@ int clk_provider_set_rate(struct clk_core *clk, unsigned long rate)
> /* prevent racing with updates to the clock topology */
> clk_prepare_lock();
>
> + hlist_for_each_entry(clk_user, &clk->per_user_clks, child_node) {
> + rate = max(rate, clk_user->floor_constraint);
> +
> + if (clk_user->ceiling_constraint > 0)
> + rate = min(rate, clk_user->ceiling_constraint);
A ceiling_constraint from consumer_A could be less than a
floor_constraint from consumer_B. What should we do in this case?
In the code above the ceiling_constraint will always win. Is that by
design? We should document that behavior in Documentation/clk.txt.
This is the right place to check for the aforementioned corner case,
since we not only care about a single consumer having sane constraints
(e.g. min < max) but also mixing constraints across consumers.
However ...
> + }
> +
> /* bail early if nothing to do */
> if (rate == clk_provider_get_rate(clk))
> goto out;
> @@ -1699,6 +1709,24 @@ int clk_set_rate(struct clk *clk_user, unsigned long rate)
> }
> EXPORT_SYMBOL_GPL(clk_set_rate);
>
> +int clk_set_floor_rate(struct clk *clk_user, unsigned long rate)
> +{
> + struct clk_core *clk = clk_to_clk_core(clk_user);
> +
> + clk_user->floor_constraint = rate;
> + return clk_provider_set_rate(clk, clk_provider_get_rate(clk));
> +}
> +EXPORT_SYMBOL_GPL(clk_set_floor_rate);
> +
> +int clk_set_ceiling_rate(struct clk *clk_user, unsigned long rate)
> +{
> + struct clk_core *clk = clk_to_clk_core(clk_user);
> +
> + clk_user->ceiling_constraint = rate;
> + return clk_provider_set_rate(clk, clk_provider_get_rate(clk));
> +}
> +EXPORT_SYMBOL_GPL(clk_set_ceiling_rate);
... we should probably sanity-check constraints here to make sure that
ceiling_rates for a given consumer are higher than floor_constraints for
that same consumer. It's a bit extra overhead but a WARN would probably
be helpful in this case.
Rest of the patch looks good.
Regards,
Mike
next prev parent reply other threads:[~2014-09-03 0:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-01 15:29 [PATCH v8 0/7] Per-user clock constraints Tomeu Vizoso
2014-09-01 15:29 ` [PATCH v8 1/7] clk: Add temporary mapping to the existing API Tomeu Vizoso
2014-09-01 15:29 ` [PATCH v8 2/7] ASoC: mxs-saif: fix mixed use of public and provider clk API Tomeu Vizoso
2014-09-01 15:34 ` [PATCH v8 4/7] clk: use struct clk only for external API Tomeu Vizoso
2014-09-01 15:34 ` [PATCH v8 5/7] clk: per-user clock accounting for debug Tomeu Vizoso
2014-09-01 15:34 ` [PATCH v8 6/7] clk: Add floor and ceiling constraints to clock rates Tomeu Vizoso
2014-09-03 0:13 ` Mike Turquette [this message]
2014-09-03 14:14 ` Tomeu Vizoso
2014-09-01 15:34 ` [PATCH v8 7/7] clk: Warn of unbalanced clk_prepare() calls Tomeu Vizoso
2014-09-03 23:45 ` [PATCH v8 4/7] clk: use struct clk only for external API Stephen Boyd
2014-09-04 13:34 ` Tomeu Vizoso
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=20140903001346.5251.47709@quantum \
--to=mturquette@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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 NNTP newsgroup(s).