All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome Brunet <jbrunet@baylibre.com>
To: Dong Aisheng <aisheng.dong@nxp.com>,
	linux-clk@vger.kernel.org, sboyd@codeaurora.org,
	mturquette@baylibre.com
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	shawnguo@kernel.org, Anson.Huang@nxp.com, ping.bai@nxp.com,
	linux-imx@nxp.com, fabio.estevam@nxp.com
Subject: Re: [PATCH V3 01/10] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support
Date: Tue, 23 Jan 2018 12:03:46 +0100	[thread overview]
Message-ID: <1516705426.7870.45.camel@baylibre.com> (raw)
In-Reply-To: <1516367470-24340-2-git-send-email-aisheng.dong@nxp.com>

On Fri, 2018-01-19 at 21:11 +0800, Dong Aisheng wrote:
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index f711be6..68ccd36 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -360,6 +360,7 @@ struct clk_div_table {
>   * @shift:     shift to the divider bit field
>   * @width:     width of the divider bit field
>   * @table:     array of value/divider pairs, last entry should have div = 0
> + * @cached_val: cached div hw value used for CLK_DIVIDER_ZERO_GATE
>   * @lock:      register lock
>   *
>   * Clock with an adjustable divider affecting its output frequency.  Implements
> @@ -388,6 +389,12 @@ struct clk_div_table {
>   * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED
>   *     except when the value read from the register is zero, the divisor is
>   *     2^width of the field.
> + * CLK_DIVIDER_ZERO_GATE - For dividers which are like CLK_DIVIDER_ONE_BASED

Unless I missed something in your patch, this comment says that, like
CLK_DIVIDER_MAX_AT_ZERO, CLK_DIVIDER_ZERO_GATE behave as a CLK_DIVIDER_ONE_BASED
clock

However, I don't see anything special done in _get_val() around
CLK_DIVIDER_ZERO_GATE which means that calling _get_val() with div=2 would give
val=1. This is more like a regular divider (when CLK_DIVIDER_ONE_BASED is not
set)

Also, when looking for the best divider, CCF could find that the best div is 1.
On a non-CLK_DIVIDER_ONE_BASED, this would translate to value 0 and
(accidentally) gate the clock .

all the occurrences of CLK_DIVIDER_ZERO_GATE I have seen in patch 9 are combined
with CLK_DIVIDER_ONE_BASED, which is probably why this potential issue has gone
unnoticed.

I think CLK_DIVIDER_ZERO_GATE should just means that value 0 gate the clock, and
just that. It should not imply what the rest of values mean.

In a more general way, I'd love to see a feature such as CLK_DIVIDER_ZERO_GATE
added to the divider but I'm bit concerned of all the quirks we are slowly
adding to the generic divider. It seems we are all trying re-use the algorithm
of clk_divider_bestdiv() with different 'val-to-div' transfer function. Not too
sure what the best solution could be though.

> + *     when the value read from the register is zero, it means the divisor
> + *     is gated. For this case, the cached_val will be used to store the
> + *     intermediate div for the normal rate operation, like set_rate/get_rate/
> + *     recalc_rate. When the divider is ungated, the driver will actually
> + *     program the hardware to have the requested divider value.
>   */

WARNING: multiple messages have this Message-ID (diff)
From: jbrunet@baylibre.com (Jerome Brunet)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 01/10] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE clk support
Date: Tue, 23 Jan 2018 12:03:46 +0100	[thread overview]
Message-ID: <1516705426.7870.45.camel@baylibre.com> (raw)
In-Reply-To: <1516367470-24340-2-git-send-email-aisheng.dong@nxp.com>

On Fri, 2018-01-19 at 21:11 +0800, Dong Aisheng wrote:
> diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> index f711be6..68ccd36 100644
> --- a/include/linux/clk-provider.h
> +++ b/include/linux/clk-provider.h
> @@ -360,6 +360,7 @@ struct clk_div_table {
>   * @shift:     shift to the divider bit field
>   * @width:     width of the divider bit field
>   * @table:     array of value/divider pairs, last entry should have div = 0
> + * @cached_val: cached div hw value used for CLK_DIVIDER_ZERO_GATE
>   * @lock:      register lock
>   *
>   * Clock with an adjustable divider affecting its output frequency.  Implements
> @@ -388,6 +389,12 @@ struct clk_div_table {
>   * CLK_DIVIDER_MAX_AT_ZERO - For dividers which are like CLK_DIVIDER_ONE_BASED
>   *     except when the value read from the register is zero, the divisor is
>   *     2^width of the field.
> + * CLK_DIVIDER_ZERO_GATE - For dividers which are like CLK_DIVIDER_ONE_BASED

Unless I missed something in your patch, this comment says that, like
CLK_DIVIDER_MAX_AT_ZERO, CLK_DIVIDER_ZERO_GATE behave as a CLK_DIVIDER_ONE_BASED
clock

However, I don't see anything special done in _get_val() around
CLK_DIVIDER_ZERO_GATE which means that calling _get_val() with div=2 would give
val=1. This is more like a regular divider (when CLK_DIVIDER_ONE_BASED is not
set)

Also, when looking for the best divider, CCF could find that the best div is 1.
On a non-CLK_DIVIDER_ONE_BASED, this would translate to value 0 and
(accidentally) gate the clock .

all the occurrences of CLK_DIVIDER_ZERO_GATE I have seen in patch 9 are combined
with CLK_DIVIDER_ONE_BASED, which is probably why this potential issue has gone
unnoticed.

I think CLK_DIVIDER_ZERO_GATE should just means that value 0 gate the clock, and
just that. It should not imply what the rest of values mean.

In a more general way, I'd love to see a feature such as CLK_DIVIDER_ZERO_GATE
added to the divider but I'm bit concerned of all the quirks we are slowly
adding to the generic divider. It seems we are all trying re-use the algorithm
of clk_divider_bestdiv() with different 'val-to-div' transfer function. Not too
sure what the best solution could be though.

> + *     when the value read from the register is zero, it means the divisor
> + *     is gated. For this case, the cached_val will be used to store the
> + *     intermediate div for the normal rate operation, like set_rate/get_rate/
> + *     recalc_rate. When the divider is ungated, the driver will actually
> + *     program the hardware to have the requested divider value.
>   */

  reply	other threads:[~2018-01-23 11:03 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 13:11 [PATCH V3 00/10] clk: add imx7ulp clk support Dong Aisheng
2018-01-19 13:11 ` Dong Aisheng
2018-01-19 13:11 ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 01/10] clk: clk-divider: add CLK_DIVIDER_ZERO_GATE " Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-23 11:03   ` Jerome Brunet [this message]
2018-01-23 11:03     ` Jerome Brunet
2018-01-23 12:21     ` Dong Aisheng
2018-01-23 12:21       ` Dong Aisheng
2018-01-23 13:10       ` Jerome Brunet
2018-01-23 13:10         ` Jerome Brunet
2018-01-23 13:10         ` Jerome Brunet
2018-01-19 13:11 ` [PATCH V3 02/10] clk: fractional-divider: add CLK_FRAC_DIVIDER_ZERO_BASED flag support Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 03/10] clk: imx: add pllv4 support Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 04/10] clk: imx: add pfdv2 support Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 05/10] clk: imx: add composite clk support Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 06/10] dt-bindings: clock: add imx7ulp clock binding doc Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 07/10] clk: imx: make mux parent strings const Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 08/10] clk: imx: implement new clk_hw based APIs Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 09/10] clk: imx: add imx7ulp clk driver Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11 ` [PATCH V3 10/10] add imx7ulp support Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:11   ` Dong Aisheng
2018-01-19 13:19   ` A.s. Dong
2018-01-19 13:19     ` A.s. Dong
2018-01-19 13:19     ` A.s. Dong
2018-01-25 13:22   ` Fabio Estevam
2018-01-25 13:22     ` Fabio Estevam
2018-01-25 13:46     ` A.s. Dong
2018-01-25 13:46       ` A.s. Dong
2018-01-25 13:46       ` A.s. Dong

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=1516705426.7870.45.camel@baylibre.com \
    --to=jbrunet@baylibre.com \
    --cc=Anson.Huang@nxp.com \
    --cc=aisheng.dong@nxp.com \
    --cc=fabio.estevam@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=ping.bai@nxp.com \
    --cc=sboyd@codeaurora.org \
    --cc=shawnguo@kernel.org \
    /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.