From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
To: Stephen Warren <swarren@wwwdotorg.org>,
Thierry Reding <thierry.reding@gmail.com>,
Mike Turquette <mturquette@linaro.org>,
Rabin Vincent <rabin.vincent@stericsson.com>,
linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC 5/5] clk: Add floor and ceiling constraints to clock rates
Date: Thu, 03 Jul 2014 16:02:14 +0200 [thread overview]
Message-ID: <53B56266.8090208@collabora.com> (raw)
In-Reply-To: <53ADF6E6.6090705@wwwdotorg.org>
On 06/28/2014 12:57 AM, Stephen Warren wrote:
> On 06/27/2014 01:57 AM, Tomeu Vizoso wrote:
>> Adds a way for clock consumers to set maximum and minimum rates. This can be
>> used for thermal drivers to set ceiling rates, or by misc. drivers to set
>> floor rates to assure a minimum performance level.
>
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>
>> +static struct rate_constraint *__ensure_constraint(struct clk *clk_user,
>> + enum constraint_type type)
>
>> + if (!found) {
>> + constraint = kzalloc(sizeof(*constraint), GFP_KERNEL);
>> + if (!constraint) {
>> + pr_err("%s: could not allocate constraint\n", __func__);
>
> Doesn't kzalloc print an error itself if the allocation fails? I've
> certainly seen quite a few patches ripping out custom "allocation
> failed" errors in code.
Thanks for pointing this out, have fixed it in a new version that will
be sent soon.
>> +void __clk_free_clk(struct clk *clk_user)
>> +{
>> + struct clk_core *clk = clk_to_clk_core(clk_user);
>> + struct rate_constraint *constraint;
>> + struct hlist_node *tmp;
>> +
>> + hlist_for_each_entry_safe(constraint, tmp, &clk->rate_constraints, node) {
>> + if (constraint->dev_id == clk_user->dev_id &&
>> + constraint->con_id == clk_user->con_id) {
>> + hlist_del(&constraint->node);
>> + kfree(constraint);
>
> Perhaps the list of constraints should be indexed by the client clk
> structure, so that test should be:
>
> if (constraint->clk_user == clk_user)
>
> It might be a bit more work, but perhaps the constraints should simply
> be stored directly in the struct clk rater than the struct clk_core.
> That would require a nested loop to apply constraints though; first over
> each struct clk associated with a struct clk_core, then over each
> constraints in that struct clk. It would slightly simplify
> adding/removing constraints though, and store the constraints at their
> "source".
Yeah, I like this alternative from a code organization point of view,
but I found the increased code complexity hard to justify. Wonder if
anybody else has an opinion on this.
>> diff --git a/include/linux/clk.h b/include/linux/clk.h
>
>> +int clk_set_floor_rate(struct clk *clk, unsigned long rate);
>
>> +int clk_set_ceiling_rate(struct clk *clk, unsigned long rate);
>
> Additions functions to explicitly remove any previously requested
> floor/ceiling rate might be useful. The same effect could be achieved by
> a floor of 0 or a very high ceiling, but it feels cleaner to remove them.
I'm also on the fence on whether the improved readability justifies the
additional API, because I find convenient that one just has to grep for
a single function call to find all usages (it was certainly useful when
I looked at how downstream does the equivalent). I'll be glad to add the
functions in a future version if there's consensus on this.
> Overall, this series seems to implement the right kind of concept to me.
> It'll certainly stop us (NVIDIA at least) wanting to create all kinds of
> "virtual" clock objects (and associated clock IDs and device tree clock
> IDs) to achieve a similar effect.
Thanks for the great feedback,
Tomeu
WARNING: multiple messages have this Message-ID (diff)
From: tomeu.vizoso@collabora.com (Tomeu Vizoso)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 5/5] clk: Add floor and ceiling constraints to clock rates
Date: Thu, 03 Jul 2014 16:02:14 +0200 [thread overview]
Message-ID: <53B56266.8090208@collabora.com> (raw)
In-Reply-To: <53ADF6E6.6090705@wwwdotorg.org>
On 06/28/2014 12:57 AM, Stephen Warren wrote:
> On 06/27/2014 01:57 AM, Tomeu Vizoso wrote:
>> Adds a way for clock consumers to set maximum and minimum rates. This can be
>> used for thermal drivers to set ceiling rates, or by misc. drivers to set
>> floor rates to assure a minimum performance level.
>
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>
>> +static struct rate_constraint *__ensure_constraint(struct clk *clk_user,
>> + enum constraint_type type)
>
>> + if (!found) {
>> + constraint = kzalloc(sizeof(*constraint), GFP_KERNEL);
>> + if (!constraint) {
>> + pr_err("%s: could not allocate constraint\n", __func__);
>
> Doesn't kzalloc print an error itself if the allocation fails? I've
> certainly seen quite a few patches ripping out custom "allocation
> failed" errors in code.
Thanks for pointing this out, have fixed it in a new version that will
be sent soon.
>> +void __clk_free_clk(struct clk *clk_user)
>> +{
>> + struct clk_core *clk = clk_to_clk_core(clk_user);
>> + struct rate_constraint *constraint;
>> + struct hlist_node *tmp;
>> +
>> + hlist_for_each_entry_safe(constraint, tmp, &clk->rate_constraints, node) {
>> + if (constraint->dev_id == clk_user->dev_id &&
>> + constraint->con_id == clk_user->con_id) {
>> + hlist_del(&constraint->node);
>> + kfree(constraint);
>
> Perhaps the list of constraints should be indexed by the client clk
> structure, so that test should be:
>
> if (constraint->clk_user == clk_user)
>
> It might be a bit more work, but perhaps the constraints should simply
> be stored directly in the struct clk rater than the struct clk_core.
> That would require a nested loop to apply constraints though; first over
> each struct clk associated with a struct clk_core, then over each
> constraints in that struct clk. It would slightly simplify
> adding/removing constraints though, and store the constraints at their
> "source".
Yeah, I like this alternative from a code organization point of view,
but I found the increased code complexity hard to justify. Wonder if
anybody else has an opinion on this.
>> diff --git a/include/linux/clk.h b/include/linux/clk.h
>
>> +int clk_set_floor_rate(struct clk *clk, unsigned long rate);
>
>> +int clk_set_ceiling_rate(struct clk *clk, unsigned long rate);
>
> Additions functions to explicitly remove any previously requested
> floor/ceiling rate might be useful. The same effect could be achieved by
> a floor of 0 or a very high ceiling, but it feels cleaner to remove them.
I'm also on the fence on whether the improved readability justifies the
additional API, because I find convenient that one just has to grep for
a single function call to find all usages (it was certainly useful when
I looked at how downstream does the equivalent). I'll be glad to add the
functions in a future version if there's consensus on this.
> Overall, this series seems to implement the right kind of concept to me.
> It'll certainly stop us (NVIDIA at least) wanting to create all kinds of
> "virtual" clock objects (and associated clock IDs and device tree clock
> IDs) to achieve a similar effect.
Thanks for the great feedback,
Tomeu
next prev parent reply other threads:[~2014-07-03 14:02 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-27 7:57 [RFC 0/5] Per-user clock constraints Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
2014-06-27 7:57 ` [RFC 1/5] clk: Add temporary mapping to the existing API Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
2014-06-27 7:57 ` [RFC 3/5] clk: use struct clk only for external API Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
[not found] ` <1403855872-14749-4-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-06-27 22:37 ` Stephen Warren
2014-06-27 22:37 ` Stephen Warren
2014-06-27 22:37 ` Stephen Warren
[not found] ` <53ADF239.9050008-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-06-30 19:43 ` Rabin Vincent
2014-06-30 19:43 ` Rabin Vincent
2014-06-30 19:43 ` Rabin Vincent
2014-06-27 7:57 ` [RFC 4/5] clk: per-user clock accounting for debug Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
2014-06-27 22:44 ` Stephen Warren
2014-06-27 22:44 ` Stephen Warren
[not found] ` <53ADF3C8.2060702-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2014-06-27 22:51 ` Stephen Warren
2014-06-27 22:51 ` Stephen Warren
2014-06-27 22:51 ` Stephen Warren
2014-06-30 19:49 ` Rabin Vincent
2014-06-30 19:49 ` Rabin Vincent
2014-06-30 19:49 ` Rabin Vincent
[not found] ` <1403855872-14749-1-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-06-27 7:57 ` [RFC 2/5] clk: Move all drivers to use internal API Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
2014-06-27 7:57 ` [RFC 5/5] clk: Add floor and ceiling constraints to clock rates Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
2014-06-27 7:57 ` Tomeu Vizoso
[not found] ` <1403855872-14749-6-git-send-email-tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>
2014-06-27 22:57 ` Stephen Warren
2014-06-27 22:57 ` Stephen Warren
2014-06-27 22:57 ` Stephen Warren
2014-06-27 23:10 ` Thierry Reding
2014-06-27 23:10 ` Thierry Reding
2014-07-03 14:02 ` Tomeu Vizoso [this message]
2014-07-03 14:02 ` Tomeu Vizoso
2014-06-27 22:30 ` [RFC 0/5] Per-user clock constraints Stephen Warren
2014-06-27 22:30 ` Stephen Warren
2014-06-27 22:30 ` Stephen Warren
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=53B56266.8090208@collabora.com \
--to=tomeu.vizoso@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=rabin.vincent@stericsson.com \
--cc=swarren@wwwdotorg.org \
--cc=thierry.reding@gmail.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 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.