linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Turquette <mturquette@ti.com>
To: Paul Walmsley <paul@pwsan.com>
Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ARM: OMAP2+: clockdomain: disabling unused clks
Date: Fri, 9 Nov 2012 11:40:23 -0800	[thread overview]
Message-ID: <20121109194023.17381.62227@nucleus> (raw)
In-Reply-To: <alpine.DEB.2.00.1211091906340.20703@utopia.booyaka.com>

Quoting Paul Walmsley (2012-11-09 11:08:00)
> On Fri, 9 Nov 2012, Paul Walmsley wrote:
> 
> > On Thu, 8 Nov 2012, Mike Turquette wrote:
> > 
> > > You're right.  In my rush I glossed over the clkdm decrement part.  In
> > > light of the suspend/resume issues I'm not sure this approach is really
> > > valid.  I think getting to the bottom of those issues will give the
> > > final word.
> > 
> > What do you think about something like this?  It's still under test and 
> > review here, but seems to avoid the warnings on 3530ES3 Beagle at least.
> > 
> > The usage of __clk_get_enable_count() in this code still seems like a hack 
> > to me.  It would be better for the CCF to call a different clk_hw_ops 
> > function pointer for the disable-unused-clocks case.  But if you agree, 
> > and plan to fix this, or have some other cleaner fix in mind for the near 
> > future, then something like this seems reasonable for the short term to 
> > me.  What do you think?
> 

For avoiding the WARNs, this seems fine to me.  And I agree that a new
clk_ops function pointer is needed.  Maybe something like,

void (*unused_disable)(struct clk_hw *hw);

But I'm OK with the below patch in the short term.  I just have one
question: did you observe any PM regressions by skipping the clkdm
programming?

Thanks,
Mike

> Here's the patch.  The changes to clkdm_clk_disable() are the important 
> ones, the rest can be ignored for the purposes of this review.
> 
> 
> - Paul
> 
> From: Mike Turquette <mturquette@ti.com>
> Date: Fri, 9 Nov 2012 11:28:42 -0700
> Subject: [PATCH] ARM: OMAP2+: clockdomain: bypass clockdomain handling when
>  disabling unused clks
> 
> The OMAP port to the common clk framework[1] resulted in spurious WARNs
> while disable unused clocks.  This is due to _clkdm_clk_hwmod_disable
> catching clkdm->usecount's with a value of zero.  Even less desirable it
> would not allow the clkdm_clk_disable function pointer to get called due
> to an early return of -ERANGE.
> 
> This patch adds a check for such a corner case by skipping the WARN and
> early return in the event that clkdm->usecount and clk->enable_usecount
> are both zero.  Presumably this could only happen during the check for
> unused clocks at boot-time.
> 
> [1] http://article.gmane.org/gmane.linux.ports.arm.omap/88824
> 
> Signed-off-by: Mike Turquette <mturquette@ti.com>
> [paul@pwsan.com: split the hwmod and clock disable cases; modified the
>  code to skip the clockdomain handling during the disable-unused-clocks phase]
> ---
>  arch/arm/mach-omap2/clockdomain.c |   91 ++++++++++++++++++++++---------------
>  1 file changed, 54 insertions(+), 37 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
> index 64e5046..1bd0ff0 100644
> --- a/arch/arm/mach-omap2/clockdomain.c
> +++ b/arch/arm/mach-omap2/clockdomain.c
> @@ -22,6 +22,7 @@
>  #include <linux/clk.h>
>  #include <linux/limits.h>
>  #include <linux/err.h>
> +#include <linux/clk-private.h>
>  
>  #include <linux/io.h>
>  
> @@ -947,35 +948,6 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)
>         return 0;
>  }
>  
> -static int _clkdm_clk_hwmod_disable(struct clockdomain *clkdm)
> -{
> -       unsigned long flags;
> -
> -       if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)
> -               return -EINVAL;
> -
> -       spin_lock_irqsave(&clkdm->lock, flags);
> -
> -       if (atomic_read(&clkdm->usecount) == 0) {
> -               spin_unlock_irqrestore(&clkdm->lock, flags);
> -               WARN_ON(1); /* underflow */
> -               return -ERANGE;
> -       }
> -
> -       if (atomic_dec_return(&clkdm->usecount) > 0) {
> -               spin_unlock_irqrestore(&clkdm->lock, flags);
> -               return 0;
> -       }
> -
> -       arch_clkdm->clkdm_clk_disable(clkdm);
> -       pwrdm_state_switch(clkdm->pwrdm.ptr);
> -       spin_unlock_irqrestore(&clkdm->lock, flags);
> -
> -       pr_debug("clockdomain: %s: disabled\n", clkdm->name);
> -
> -       return 0;
> -}
> -
>  /**
>   * clkdm_clk_enable - add an enabled downstream clock to this clkdm
>   * @clkdm: struct clockdomain *
> @@ -1018,15 +990,39 @@ int clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
>   */
>  int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
>  {
> -       /*
> -        * XXX Rewrite this code to maintain a list of enabled
> -        * downstream clocks for debugging purposes?
> -        */
> +       unsigned long flags;
> +       int force_disable = 0;
>  
> -       if (!clk)
> +       if (!clkdm || !clk || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)
>                 return -EINVAL;
>  
> -       return _clkdm_clk_hwmod_disable(clkdm);
> +       spin_lock_irqsave(&clkdm->lock, flags);
> +
> +       /* corner case: disabling unused clocks */
> +       force_disable = (__clk_get_enable_count(clk) == 0) ? 1 : 0;
> +       if (force_disable)
> +               goto ccd_exit;
> +
> +       if (atomic_read(&clkdm->usecount) == 0) {
> +               spin_unlock_irqrestore(&clkdm->lock, flags);
> +               WARN_ON(1); /* underflow */
> +               return -ERANGE;
> +       }
> +
> +       if (atomic_dec_return(&clkdm->usecount) > 0) {
> +               spin_unlock_irqrestore(&clkdm->lock, flags);
> +               return 0;
> +       }
> +
> +       arch_clkdm->clkdm_clk_disable(clkdm);
> +       pwrdm_state_switch(clkdm->pwrdm.ptr);
> +
> +       pr_debug("clockdomain: %s: disabled\n", clkdm->name);
> +
> +ccd_exit:
> +       spin_unlock_irqrestore(&clkdm->lock, flags);
> +
> +       return 0;
>  }
>  
>  /**
> @@ -1077,6 +1073,8 @@ int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh)
>   */
>  int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh)
>  {
> +       unsigned long flags;
> +
>         /* The clkdm attribute does not exist yet prior OMAP4 */
>         if (cpu_is_omap24xx() || cpu_is_omap34xx())
>                 return 0;
> @@ -1086,9 +1084,28 @@ int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh)
>          * downstream hwmods for debugging purposes?
>          */
>  
> -       if (!oh)
> +       if (!clkdm || !oh || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)
>                 return -EINVAL;
>  
> -       return _clkdm_clk_hwmod_disable(clkdm);
> +       spin_lock_irqsave(&clkdm->lock, flags);
> +
> +       if (atomic_read(&clkdm->usecount) == 0) {
> +               spin_unlock_irqrestore(&clkdm->lock, flags);
> +               WARN_ON(1); /* underflow */
> +               return -ERANGE;
> +       }
> +
> +       if (atomic_dec_return(&clkdm->usecount) > 0) {
> +               spin_unlock_irqrestore(&clkdm->lock, flags);
> +               return 0;
> +       }
> +
> +       arch_clkdm->clkdm_clk_disable(clkdm);
> +       pwrdm_state_switch(clkdm->pwrdm.ptr);
> +       spin_unlock_irqrestore(&clkdm->lock, flags);
> +
> +       pr_debug("clockdomain: %s: disabled\n", clkdm->name);
> +
> +       return 0;
>  }
>  
> -- 
> 1.7.10.4

  reply	other threads:[~2012-11-09 19:40 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-08  1:12 [PATCH v2 00/26] Move OMAP2+ over to common clk framework Mike Turquette
2012-11-08  1:12 ` [PATCH 01/26] ARM: OMAP: clock: Nuke plat/clock.c & reuse struct clk as clk_hw_omap Mike Turquette
2012-11-08  1:12 ` [PATCH 02/26] ARM: OMAP: hwmod: Fix up hwmod based clkdm accesses Mike Turquette
2012-11-12 22:15   ` Paul Walmsley
2012-11-08  1:12 ` [PATCH 03/26] ARM: OMAP4: clock: Convert to common clk Mike Turquette
2012-11-12 22:52   ` Paul Walmsley
2012-11-13  2:17   ` Paul Walmsley
2012-11-08  1:12 ` [PATCH 04/26] ARM: OMAP3: " Mike Turquette
2012-11-08  1:12 ` [PATCH 05/26] ARM: OMAP2: " Mike Turquette
2012-11-12 22:16   ` Paul Walmsley
2012-11-08  1:12 ` [PATCH 06/26] ARM: OMAP2xxx: clock: add APLL rate recalculation functions Mike Turquette
2012-11-08  1:12 ` [PATCH 07/26] ARM: OMAP: clock: list all clk_hw_omap clks to enable/disable autoidle Mike Turquette
2012-11-12 23:00   ` Paul Walmsley
2012-11-08  1:12 ` [PATCH 08/26] ARM: OMAP: clock: Define a function to enable clocks at init Mike Turquette
2012-11-12 23:01   ` Paul Walmsley
2012-11-08  1:12 ` [PATCH 09/26] ARM: OMAP2+: hwmod: Invoke init_clkdm before other init functions Mike Turquette
2012-11-08  1:12 ` [PATCH 10/26] ARM: OMAP: clock: Get rid of some clkdm assocations within clks Mike Turquette
2012-11-08  1:12 ` [PATCH 11/26] ARM: OMAP2+: clock: add OMAP CCF convenience macros to mach-omap2/clock.h Mike Turquette
2012-11-08  1:12 ` [PATCH 12/26] ARM: OMAP4: clock: Add 44xx data using common struct clk Mike Turquette
2012-11-13  1:37   ` Paul Walmsley
2012-11-13  2:16     ` Paul Walmsley
2012-11-08  1:12 ` [PATCH 13/26] ARM: AM33XX: clock: add clock data in common clock format Mike Turquette
2012-11-08  1:12 ` [PATCH 16/26] ARM: OMAP: clock: Switch to COMMON clk Mike Turquette
2012-11-08  1:12 ` [PATCH 17/26] ARM: OMAP: hwmod: Cleanup !CONFIG_COMMON_CLK parts Mike Turquette
2012-11-08  1:12 ` [PATCH 18/26] ARM: OMAP4: clock: " Mike Turquette
2012-11-08  1:12 ` [PATCH 20/26] ARM: omap3: " Mike Turquette
2012-11-08  1:12 ` [PATCH 22/26] ARM: AM33xx: clock: drop obsolete clock data Mike Turquette
2012-11-08  1:12 ` [PATCH 23/26] ARM: omap2: clock: Cleanup !CONFIG_COMMON_CLK parts Mike Turquette
2012-11-08  1:13 ` [PATCH 25/26] ARM: OMAP2+: clock: remove unnecessary declarations Mike Turquette
2012-11-08  1:13 ` [PATCH 26/26] ARM: OMAP2+: clock: Cleanup !CONFIG_COMMON_CLK parts Mike Turquette
2012-11-08  1:31 ` [PATCH v2 00/26] Move OMAP2+ over to common clk framework Mike Turquette
2012-11-08  1:42   ` Tony Lindgren
2012-11-08  1:54     ` Mike Turquette
2012-11-08  2:50       ` Paul Walmsley
2012-11-08  5:02 ` Rajendra Nayak
2012-11-08  5:19   ` Mike Turquette
2012-11-08 19:20     ` Kevin Hilman
     [not found] ` <1352337181-29427-15-git-send-email-mturquette@ti.com>
2012-11-08 18:08   ` [PATCH 14/26] ARM: OMAP3: clock: Add 3xxx data using common struct clk Paul Walmsley
2012-11-08 21:52     ` Mike Turquette
2012-11-08 22:01     ` Paul Walmsley
2012-11-09  0:11       ` Paul Walmsley
2012-11-09  0:33         ` Paul Walmsley
2012-11-09  0:49           ` Paul Walmsley
2012-11-09  0:57         ` Mike Turquette
2012-11-08 23:31     ` [PATCH] ARM: OMAP2+: clockdomain: disabling unused clks Mike Turquette
2012-11-09  0:58       ` Paul Walmsley
2012-11-09  1:17         ` Mike Turquette
2012-11-09 19:06           ` Paul Walmsley
2012-11-09 19:08             ` Paul Walmsley
2012-11-09 19:40               ` Mike Turquette [this message]
2012-11-09 19:52                 ` Paul Walmsley
2012-11-09 20:53                   ` Paul Walmsley
2012-11-08 19:04 ` [PATCH v2 00/26] Move OMAP2+ over to common clk framework Vaibhav Hiremath
2012-11-09 21:12 ` Paul Walmsley
2012-11-09 22:09   ` Tony Lindgren
2012-11-09 22:18   ` Mike Turquette
2012-11-09 23:47     ` Paul Walmsley
2012-11-12 21:50 ` [PATCH] ARM: OMAP3+: DPLL: drop !CONFIG_COMMON_CLK sections Paul Walmsley
2012-11-12 22:30   ` Mike Turquette
     [not found] ` <1352337181-29427-16-git-send-email-mturquette@ti.com>
     [not found]   ` <alpine.DEB.2.00.1211081532210.20703@utopia.booyaka.com>
2012-11-09 20:32     ` [PATCH 15/26] ARM: omap2: clock: Add 24xx data using common struct clk Paul Walmsley
2012-11-09 21:05       ` Mike Turquette
2012-11-09 21:22         ` Paul Walmsley
2012-11-09 22:21           ` Mike Turquette
2012-11-12 22:13   ` Paul Walmsley
2012-11-13 13:42 ` [PATCH v2 00/26] Move OMAP2+ over to common clk framework Laurent Pinchart
2012-11-13 16:43   ` Mike Turquette
2012-11-15  0:57     ` Laurent Pinchart

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=20121109194023.17381.62227@nucleus \
    --to=mturquette@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).