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


Groups > linux.kernel > #1204286

Re: [PATCH RFC RFT 1/3] clk: per-user clk prepare & enable ref counts

From Maxime Coquelin <maxime.coquelin@st.com>
Newsgroups linux.kernel
Subject Re: [PATCH RFC RFT 1/3] clk: per-user clk prepare & enable ref counts
Date 2015-08-10 15:50 +0200
Message-ID <pVVCG-7X5-17@gated-at.bofh.it> (permalink)
References <pUVln-hs-3@gated-at.bofh.it> <pUVlo-hs-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi Mike,

On 08/07/2015 09:09 PM, Michael Turquette wrote:
> This patch adds prepare and enable reference counts for the per-user
> handles that clock consumers have for a clock node. This patch warns if
> an imbalance occurs while trying to disable or unprepare a clock and
> aborts, leaving the hardware unaffected.
>
> Signed-off-by: Michael Turquette <mturquette@baylibre.com>
> ---
>   drivers/clk/clk.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index 898052e..72feee9 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -84,6 +84,8 @@ struct clk {
>   	unsigned long min_rate;
>   	unsigned long max_rate;
>   	struct hlist_node clks_node;
> +	unsigned int enable_count;
> +	unsigned int prepare_count;
>   };
>   
>   /***           locking             ***/
> @@ -600,6 +602,9 @@ void clk_unprepare(struct clk *clk)
>   		return;
>   
>   	clk_prepare_lock();
> +	if (WARN_ON(clk->prepare_count == 0))
Isn't clk_prepare_unlock()call missing here before return?
> +		return;
> +	clk->prepare_count--;
>   	clk_core_unprepare(clk->core);
>   	clk_prepare_unlock();
>   }
> @@ -657,6 +662,7 @@ int clk_prepare(struct clk *clk)
>   		return 0;
>   
>   	clk_prepare_lock();
> +	clk->prepare_count++;
>   	ret = clk_core_prepare(clk->core);
>   	clk_prepare_unlock();
>   
> @@ -707,6 +713,9 @@ void clk_disable(struct clk *clk)
>   		return;
>   
>   	flags = clk_enable_lock();
> +	if (WARN_ON(clk->enable_count == 0))
Ditto.
> +		return;
> +	clk->enable_count--;
>   	clk_core_disable(clk->core);
>   	clk_enable_unlock(flags);
>   }

Regards,
Maxime
--
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