Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1203005

[PATCH RFC RFT 2/3] clk: clk_put WARNs if user has not disabled clk

From Michael Turquette <mturquette@baylibre.com>
Newsgroups linux.kernel
Subject [PATCH RFC RFT 2/3] clk: clk_put WARNs if user has not disabled clk
Date 2015-08-07 21:20 +0200
Message-ID <pUVln-hs-9@gated-at.bofh.it> (permalink)
References <pUVln-hs-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/clk/clk.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 72feee9..6ec0f77 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2764,6 +2764,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(clk->prepare_count);
+	WARN_ON(clk->enable_count);
+
 	owner = clk->core->owner;
 	kref_put(&clk->core->ref, __clk_release);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RFC RFT 0/3] clk: detect per-user enable imbalances and implement hand-off Michael Turquette <mturquette@baylibre.com> - 2015-08-07 21:20 +0200
  [PATCH RFC RFT 2/3] clk: clk_put WARNs if user has not disabled clk Michael Turquette <mturquette@baylibre.com> - 2015-08-07 21:20 +0200
  [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Michael Turquette <mturquette@baylibre.com> - 2015-08-07 21:20 +0200
    Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-10 16:50 +0200
      Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-11 10:50 +0200
        Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Maxime Coquelin <maxime.coquelin@st.com> - 2015-08-11 12:10 +0200
          Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Geert Uytterhoeven <geert@linux-m68k.org> - 2015-08-11 12:20 +0200
            Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Maxime Coquelin <maxime.coquelin@st.com> - 2015-08-11 13:40 +0200
              Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Geert Uytterhoeven <geert@linux-m68k.org> - 2015-08-11 13:50 +0200
                Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-11 14:10 +0200
                Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Maxime Coquelin <maxime.coquelin@st.com> - 2015-08-11 14:10 +0200
                Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Geert Uytterhoeven <geert@linux-m68k.org> - 2015-08-11 14:40 +0200
              Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Maxime Coquelin <maxime.coquelin@st.com> - 2015-08-11 13:50 +0200
            Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Michael Turquette <mturquette@baylibre.com> - 2015-08-11 19:10 +0200
              Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-11 20:20 +0200
                Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Geert Uytterhoeven <geert@linux-m68k.org> - 2015-08-12 09:30 +0200
                Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-12 10:00 +0200
          Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Michael Turquette <mturquette@baylibre.com> - 2015-08-11 19:10 +0200
            Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-11 20:30 +0200
        Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Lee Jones <lee.jones@linaro.org> - 2015-08-11 20:40 +0200
          Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Maxime Ripard <maxime.ripard@free-electrons.com> - 2015-08-18 18:00 +0200
    Re: [PATCH RFC RFT 3/3] clk: introduce CLK_ENABLE_HAND_OFF flag Maxime Ripard <maxime.ripard@free-electrons.com> - 2015-08-18 18:00 +0200
  [PATCH RFC RFT 1/3] clk: per-user clk prepare & enable ref counts Michael Turquette <mturquette@baylibre.com> - 2015-08-07 21:20 +0200
    Re: [PATCH RFC RFT 1/3] clk: per-user clk prepare & enable ref counts Maxime Coquelin <maxime.coquelin@st.com> - 2015-08-10 15:50 +0200
      Re: [PATCH RFC RFT 1/3] clk: per-user clk prepare & enable ref counts Michael Turquette <mturquette@baylibre.com> - 2015-08-10 21:40 +0200
  Re: [PATCH RFC RFT 0/3] clk: detect per-user enable imbalances and  implement hand-off Lee Jones <lee.jones@linaro.org> - 2015-08-10 17:40 +0200
    Re: [PATCH RFC RFT 0/3] clk: detect per-user enable imbalances and  implement hand-off Lee Jones <lee.jones@linaro.org> - 2015-08-11 11:20 +0200
  Re: [PATCH RFC RFT 0/3] clk: detect per-user enable imbalances and  implement hand-off Geert Uytterhoeven <geert@linux-m68k.org> - 2015-08-11 11:30 +0200
    Re: [PATCH RFC RFT 0/3] clk: detect per-user enable imbalances and  implement hand-off Geert Uytterhoeven <geert@linux-m68k.org> - 2015-08-11 19:50 +0200
  Re: [PATCH RFC RFT 0/3] clk: detect per-user enable imbalances and  implement hand-off Maxime Ripard <maxime.ripard@free-electrons.com> - 2015-08-18 17:50 +0200

csiph-web