Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1332366 > unrolled thread
| Started by | Michael Turquette <mturquette@baylibre.com> |
|---|---|
| First post | 2016-02-11 22:20 +0100 |
| Last post | 2016-02-14 16:00 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v42 5/6] clk: clk_put WARNs if user has not disabled clk Michael Turquette <mturquette@baylibre.com> - 2016-02-11 22:20 +0100
Re: [PATCH v42 5/6] clk: clk_put WARNs if user has not disabled clk Stephen Boyd <sboyd@codeaurora.org> - 2016-02-13 02:20 +0100
Re: [PATCH v42 5/6] clk: clk_put WARNs if user has not disabled clk Geert Uytterhoeven <geert@linux-m68k.org> - 2016-02-14 16:00 +0100
| From | Michael Turquette <mturquette@baylibre.com> |
|---|---|
| Date | 2016-02-11 22:20 +0100 |
| Subject | [PATCH v42 5/6] clk: clk_put WARNs if user has not disabled clk |
| Message-ID | <r16OB-5Vk-1@gated-at.bofh.it> |
>From the clk_put kerneldoc in include/linux/clk.h: """ Note: drivers must ensure that all clk_enable calls made on this clock source are balanced by clk_disable calls prior to calling this function. """ The common clock framework implementation of the clk.h api has per-user reference counts for calls to clk_prepare and clk_disable. As such it can enforce the requirement to properly call clk_disable and clk_unprepare before calling clk_put. Because this requirement is probably violated in many places, this patch starts with a simple warning. Once offending code has been fixed this check could additionally release the reference counts automatically. Signed-off-by: Michael Turquette <mturquette@baylibre.com> --- Changed in v2ish: * s/WARN_ON/WARN_ON_ONCE/ to reduce noise for pm-clocks drivers/clk/clk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 01183e3..d81f970 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2824,6 +2824,14 @@ void __clk_put(struct clk *clk) clk->max_rate < clk->core->req_rate) clk_core_set_rate_nolock(clk->core, clk->core->req_rate); + /* + * before calling clk_put, all calls to clk_prepare and clk_enable from + * a given user must be balanced with calls to clk_disable and + * clk_unprepare by that same user + */ + WARN_ON_ONCE(clk->prepare_count); + WARN_ON_ONCE(clk->enable_count); + owner = clk->core->owner; kref_put(&clk->core->ref, __clk_release); -- 2.1.4
[toc] | [next] | [standalone]
| From | Stephen Boyd <sboyd@codeaurora.org> |
|---|---|
| Date | 2016-02-13 02:20 +0100 |
| Message-ID | <r1x2q-6qn-7@gated-at.bofh.it> |
| In reply to | #1332366 |
On 02/11, Michael Turquette wrote: > >From the clk_put kerneldoc in include/linux/clk.h: > > """ > Note: drivers must ensure that all clk_enable calls made on this clock > source are balanced by clk_disable calls prior to calling this function. > """ > > The common clock framework implementation of the clk.h api has per-user > reference counts for calls to clk_prepare and clk_disable. As such it > can enforce the requirement to properly call clk_disable and > clk_unprepare before calling clk_put. > > Because this requirement is probably violated in many places, this patch > starts with a simple warning. Once offending code has been fixed this > check could additionally release the reference counts automatically. Do we have any fixes for pm code in the works? I'm worried we're going to be giving a warning and nobody will fix them or has a plan to fix them. > > Signed-off-by: Michael Turquette <mturquette@baylibre.com> > --- Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
[toc] | [prev] | [next] | [standalone]
| From | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| Date | 2016-02-14 16:00 +0100 |
| Message-ID | <r26jw-3Vq-7@gated-at.bofh.it> |
| In reply to | #1333242 |
Hi Stephen, Mike,
On Sat, Feb 13, 2016 at 2:18 AM, Stephen Boyd <sboyd@codeaurora.org> wrote:
> On 02/11, Michael Turquette wrote:
>> >From the clk_put kerneldoc in include/linux/clk.h:
>>
>> """
>> Note: drivers must ensure that all clk_enable calls made on this clock
>> source are balanced by clk_disable calls prior to calling this function.
>> """
>>
>> The common clock framework implementation of the clk.h api has per-user
>> reference counts for calls to clk_prepare and clk_disable. As such it
>> can enforce the requirement to properly call clk_disable and
>> clk_unprepare before calling clk_put.
>>
>> Because this requirement is probably violated in many places, this patch
>> starts with a simple warning. Once offending code has been fixed this
>> check could additionally release the reference counts automatically.
>
> Do we have any fixes for pm code in the works? I'm worried we're
> going to be giving a warning and nobody will fix them or has a
> plan to fix them.
drivers/base/power/clock_ops.c
AFAIK not.
I've been running with the above patch for several months, and I had
to remove the two clk_put() calls in {en,dis}able_clock() in
drivers/base/power/clock_ops.c to get rid of the warnings when using the
legacy clock domain.
Fixing drivers/base/power/clock_ops.c is non-trivial though, as you need a
place to store the clk's reference obtained in enable_clock(), for later use in
disable_clock().
However, the plan is to make CONFIG_PM=y mandatory for Renesas ARM
SoCs with clock domains, which makes us no longer users of the legacy clock
domain.
Legacy SH and Davinci/Keystone/OMAP1 users may care, though...
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web