Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1332366
| From | Michael Turquette <mturquette@baylibre.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v42 5/6] clk: clk_put WARNs if user has not disabled clk |
| Date | 2016-02-11 22:20 +0100 |
| Message-ID | <r16OB-5Vk-1@gated-at.bofh.it> (permalink) |
| References | <r16OB-5Vk-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
>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
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[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
csiph-web