All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dong Aisheng <dongas86@gmail.com>
To: Michael Turquette <mturquette@baylibre.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
	sboyd@codeaurora.org, shawnguo@kernel.org,
	linux-arm-kernel@lists.infradead.org, anson.huang@nxp.com
Subject: Re: [RESEND PATCH 3/8] clk: core: support clocks which requires parents on (part 1)
Date: Wed, 29 Jun 2016 21:57:09 +0800	[thread overview]
Message-ID: <20160629135709.GA29919@shlinux2> (raw)
In-Reply-To: <146681236249.35033.18209610320711572265@resonance>

On Fri, Jun 24, 2016 at 04:52:42PM -0700, Michael Turquette wrote:
> Quoting Dong Aisheng (2016-04-20 02:34:35)
> > On Freescale i.MX7D platform, all clocks operations, including
> > enable/disable, rate change and re-parent, requires its parent
> > clock on. Current clock core can not support it well.
> > This patch introduce a new flag CLK_OPS_PARENT_ON to handle this
> > special case in clock core that enable its parent clock firstly for
> > each operation and disable it later after operation complete.
> > 
> > The patch part 1 fixes the possible disabling clocks while its parent
> > is off during kernel booting phase in clk_disable_unused_subtree().
> > 
> > Before the completion of kernel booting, clock tree is still not built
> > completely, there may be a case that the child clock is on but its
> > parent is off which could be caused by either HW initial reset state
> > or bootloader initialization.
> > 
> > Taking bootloader as an example, we may enable all clocks in HW by default.
> > And during kernel booting time, the parent clock could be disabled in its
> > driver probe due to calling clk_prepare_enable and clk_disable_unprepare.
> > Because it's child clock is only enabled in HW while its SW usecount
> > in clock tree is still 0, so clk_disable of parent clock will gate
> > the parent clock in both HW and SW usecount ultimately. Then there will
> > be a child clock is still on in HW but its parent is already off.
> > 
> > Later in clk_disable_unused(), this clock disable accessing while its
> > parent off will cause system hang due to the limitation of HW which
> > must require its parent on.
> > 
> > This patch simply enables the parent clock first before disabling
> > if flag CLK_OPS_PARENT_ON is set in clk_disable_unused_subtree().
> > This is a simple solution and only affects booting time.
> > 
> > After kernel booting up the clock tree is already created, there will
> > be no case that child is off but its parent is off.
> > So no need do this checking for normal clk_disable() later.
> > 
> > Cc: Michael Turquette <mturquette@baylibre.com>
> > Cc: Stephen Boyd <sboyd@codeaurora.org>
> > Cc: Shawn Guo <shawnguo@kernel.org>
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/clk/clk.c            | 5 +++++
> >  include/linux/clk-provider.h | 2 ++
> >  2 files changed, 7 insertions(+)
> > 
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index 9f944d4..1f054d1a 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -765,6 +765,9 @@ static void clk_disable_unused_subtree(struct clk_core *core)
> >         hlist_for_each_entry(child, &core->children, child_node)
> >                 clk_disable_unused_subtree(child);
> >  
> > +       if (core->flags & CLK_OPS_PARENT_ON)
> > +               clk_core_prepare_enable(core->parent);
> > +
> >         flags = clk_enable_lock();
> >  
> >         if (core->enable_count)
> > @@ -789,6 +792,8 @@ static void clk_disable_unused_subtree(struct clk_core *core)
> >  
> >  unlock_out:
> >         clk_enable_unlock(flags);
> > +       if (core->flags & CLK_OPS_PARENT_ON)
> > +               clk_core_disable_unprepare(core->parent);
> >  }
> >  
> >  static bool clk_ignore_unused;
> > diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> > index 15628644..c878f9c 100644
> > --- a/include/linux/clk-provider.h
> > +++ b/include/linux/clk-provider.h
> > @@ -33,6 +33,8 @@
> >  #define CLK_RECALC_NEW_RATES   BIT(9) /* recalc rates after notifications */
> >  #define CLK_SET_RATE_UNGATE    BIT(10) /* clock needs to run to set rate */
> >  #define CLK_IS_CRITICAL                BIT(11) /* do not gate, ever */
> > +/* parents need on during gate/ungate, set rate and re-parent */
> > +#define CLK_OPS_PARENT_ON      BIT(12)
> 
> Hi Dong,
> 
> In the clk framework we use "enabled" instead of "on". How about
> changing the flag to CLK_OPS_PARENT_ENABLE?
> 

Yes, of course i'm fine with it.
I could update the patch title too.
Thanks for the review.

Regards
Dong Aisheng

> Regards,
> Mike
> 
> >  
> >  struct clk;
> >  struct clk_hw;
> > -- 
> > 1.9.1
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-clk" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: dongas86@gmail.com (Dong Aisheng)
To: linux-arm-kernel@lists.infradead.org
Subject: [RESEND PATCH 3/8] clk: core: support clocks which requires parents on (part 1)
Date: Wed, 29 Jun 2016 21:57:09 +0800	[thread overview]
Message-ID: <20160629135709.GA29919@shlinux2> (raw)
In-Reply-To: <146681236249.35033.18209610320711572265@resonance>

On Fri, Jun 24, 2016 at 04:52:42PM -0700, Michael Turquette wrote:
> Quoting Dong Aisheng (2016-04-20 02:34:35)
> > On Freescale i.MX7D platform, all clocks operations, including
> > enable/disable, rate change and re-parent, requires its parent
> > clock on. Current clock core can not support it well.
> > This patch introduce a new flag CLK_OPS_PARENT_ON to handle this
> > special case in clock core that enable its parent clock firstly for
> > each operation and disable it later after operation complete.
> > 
> > The patch part 1 fixes the possible disabling clocks while its parent
> > is off during kernel booting phase in clk_disable_unused_subtree().
> > 
> > Before the completion of kernel booting, clock tree is still not built
> > completely, there may be a case that the child clock is on but its
> > parent is off which could be caused by either HW initial reset state
> > or bootloader initialization.
> > 
> > Taking bootloader as an example, we may enable all clocks in HW by default.
> > And during kernel booting time, the parent clock could be disabled in its
> > driver probe due to calling clk_prepare_enable and clk_disable_unprepare.
> > Because it's child clock is only enabled in HW while its SW usecount
> > in clock tree is still 0, so clk_disable of parent clock will gate
> > the parent clock in both HW and SW usecount ultimately. Then there will
> > be a child clock is still on in HW but its parent is already off.
> > 
> > Later in clk_disable_unused(), this clock disable accessing while its
> > parent off will cause system hang due to the limitation of HW which
> > must require its parent on.
> > 
> > This patch simply enables the parent clock first before disabling
> > if flag CLK_OPS_PARENT_ON is set in clk_disable_unused_subtree().
> > This is a simple solution and only affects booting time.
> > 
> > After kernel booting up the clock tree is already created, there will
> > be no case that child is off but its parent is off.
> > So no need do this checking for normal clk_disable() later.
> > 
> > Cc: Michael Turquette <mturquette@baylibre.com>
> > Cc: Stephen Boyd <sboyd@codeaurora.org>
> > Cc: Shawn Guo <shawnguo@kernel.org>
> > Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com>
> > ---
> >  drivers/clk/clk.c            | 5 +++++
> >  include/linux/clk-provider.h | 2 ++
> >  2 files changed, 7 insertions(+)
> > 
> > diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> > index 9f944d4..1f054d1a 100644
> > --- a/drivers/clk/clk.c
> > +++ b/drivers/clk/clk.c
> > @@ -765,6 +765,9 @@ static void clk_disable_unused_subtree(struct clk_core *core)
> >         hlist_for_each_entry(child, &core->children, child_node)
> >                 clk_disable_unused_subtree(child);
> >  
> > +       if (core->flags & CLK_OPS_PARENT_ON)
> > +               clk_core_prepare_enable(core->parent);
> > +
> >         flags = clk_enable_lock();
> >  
> >         if (core->enable_count)
> > @@ -789,6 +792,8 @@ static void clk_disable_unused_subtree(struct clk_core *core)
> >  
> >  unlock_out:
> >         clk_enable_unlock(flags);
> > +       if (core->flags & CLK_OPS_PARENT_ON)
> > +               clk_core_disable_unprepare(core->parent);
> >  }
> >  
> >  static bool clk_ignore_unused;
> > diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
> > index 15628644..c878f9c 100644
> > --- a/include/linux/clk-provider.h
> > +++ b/include/linux/clk-provider.h
> > @@ -33,6 +33,8 @@
> >  #define CLK_RECALC_NEW_RATES   BIT(9) /* recalc rates after notifications */
> >  #define CLK_SET_RATE_UNGATE    BIT(10) /* clock needs to run to set rate */
> >  #define CLK_IS_CRITICAL                BIT(11) /* do not gate, ever */
> > +/* parents need on during gate/ungate, set rate and re-parent */
> > +#define CLK_OPS_PARENT_ON      BIT(12)
> 
> Hi Dong,
> 
> In the clk framework we use "enabled" instead of "on". How about
> changing the flag to CLK_OPS_PARENT_ENABLE?
> 

Yes, of course i'm fine with it.
I could update the patch title too.
Thanks for the review.

Regards
Dong Aisheng

> Regards,
> Mike
> 
> >  
> >  struct clk;
> >  struct clk_hw;
> > -- 
> > 1.9.1
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-clk" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-06-29 13:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20  9:34 [RESEND PATCH 0/8] clk: core: support clocks which requires parents on Dong Aisheng
2016-04-20  9:34 ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 1/8] clk: introduce clk_core_enable_lock and clk_core_disable_lock functions Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 2/8] clk: move clk_disable_unused after clk_core_disable_unprepare function Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 3/8] clk: core: support clocks which requires parents on (part 1) Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-06-24 23:52   ` Michael Turquette
2016-06-24 23:52     ` Michael Turquette
2016-06-24 23:52     ` Michael Turquette
2016-06-29 13:57     ` Dong Aisheng [this message]
2016-06-29 13:57       ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 4/8] clk: core: support clocks which requires parents on (part 2) Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-06-24 23:52   ` Michael Turquette
2016-06-24 23:52     ` Michael Turquette
2016-06-24 23:52     ` Michael Turquette
2016-06-29 13:59     ` Dong Aisheng
2016-06-29 13:59       ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 5/8] clk: imx: re-order and concentrate the same type of clk api Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 6/8] clk: imx: add clk api for supporting clk_OPS_PARENT_ON clocks Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 7/8] clk: imx7d: using api with flag CLK_OPS_PARENT_ON Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-04-20  9:34 ` [RESEND PATCH 8/8] clk: imx7d: only enable minimum required clocks Dong Aisheng
2016-04-20  9:34   ` Dong Aisheng
2016-06-02 15:20 ` [RESEND PATCH 0/8] clk: core: support clocks which requires parents on Dong Aisheng
2016-06-02 15:20   ` Dong Aisheng
2016-06-12 14:58   ` Dong Aisheng
2016-06-12 14:58     ` Dong Aisheng

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=20160629135709.GA29919@shlinux2 \
    --to=dongas86@gmail.com \
    --cc=aisheng.dong@nxp.com \
    --cc=anson.huang@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.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.