linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Vipul Kumar Samar <vipulkumar.samar-qxv4g6HH51o@public.gmane.org>,
	Russell King - ARM Linux
	<linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org>,
	Magnus Damm <damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org>,
	"Rafael J. Wysocki" <rjw-KKrjLPT3xs0@public.gmane.org>
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 2/2] ARM: ABMA: Disable/Enable interface clock from suspend/resume
Date: Wed, 26 Sep 2012 14:38:15 +0200	[thread overview]
Message-ID: <CACRpkdY_reBeOpyzxdjh9hsc1n_Ff7p5KFBA0Ysys_zDv3WtrA@mail.gmail.com> (raw)
In-Reply-To: <1348658647-25975-3-git-send-email-vipulkumar.samar-qxv4g6HH51o@public.gmane.org>

On Wed, Sep 26, 2012 at 1:24 PM, Vipul Kumar Samar
<vipulkumar.samar-qxv4g6HH51o@public.gmane.org> wrote:

> AMBA devices interface clock is disabled in RTPM suspend/resume hooks
> but not in conventional hooks.
>
> This patch adds support to disable/enable clock for conventional
> suspend/resume calls.
(...)
> +       struct amba_device *pcdev = to_amba_device(dev);
>         int ret = 0;
>
>         if (!drv)
> @@ -132,16 +133,27 @@ static int amba_pm_suspend(struct device *dev)
>                 ret = amba_legacy_suspend(dev, PMSG_SUSPEND);
>         }
>
> +       if (!ret)
> +               clk_disable(pcdev->pclk);
> +
>         return ret;
>  }

You're not accounting for the case where pcdev->pclk
is an error pointer (as happens if pclk lookup fails at
probe).

I think you can simplify some of the code using
the external accessors from <linux/amba/bus.h>:

amba_pclk_enable();
amba_pclk_disable();

But:

Again this is a case where you have a race between runtime
suspend/resume and ordinary suspend/resume.

These ordinary suspend/resume operations should probably
wait for runtime suspend to happen *first* if and only if
runtime PM is enabled, and then the block will be gated
off. So we really need to figure out how we can make sure
that this happens.

If just ordinary PM is enabled, the above makes sense but in
that case I think we should have that #ifdef:ed as an alternative
or something.

So something like:

suspend():
#ifdef CONFIG_PM_RUNTIME
   /* Wait for runtime PM to hammer down the pclk */
#elif CONFIG_PM
   amba_pclk_disable();
#endif

resume():
#if defined(CONFIG_PM) && !defined(CONFIG_PM_RUNTIME)
  amba_pclk_enable();
#endif
  /* Let runtime PM lazily enable the clock when needed */

To complicate things further the bus operations can be
overridden by e.g. voltage domains. In this case we (ux500)
have choosen to call out to the AMBA level to make sure
semantics are preserved.

Yours,
Linus Walleij

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

      parent reply	other threads:[~2012-09-26 12:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26 11:24 [PATCH 0/2] ARM: AMBA: Fix clock disable/enable issue in conventional suspend/resume Vipul Kumar Samar
     [not found] ` <1348658647-25975-1-git-send-email-vipulkumar.samar-qxv4g6HH51o@public.gmane.org>
2012-09-26 11:24   ` [PATCH 1/2] spi:pl022: Disable/Enable functional clock from suspend/resume Vipul Kumar Samar
     [not found]     ` <1348658647-25975-2-git-send-email-vipulkumar.samar-qxv4g6HH51o@public.gmane.org>
2012-09-26 12:17       ` Linus Walleij
     [not found]         ` <CACRpkdampxUw0=NO6cs679C-r0_AnPEaTYVc+GppRkKGn32p-w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-26 12:19           ` Mark Brown
     [not found]             ` <20120926121946.GO4428-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2012-09-26 12:41               ` Linus Walleij
     [not found]                 ` <CACRpkdZLUUXw5TDwTqtP10YaRHEuHNHq9gMY-YSNeZ+21=cZRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-27 17:03                   ` Mark Brown
2012-09-26 14:08               ` viresh kumar
     [not found]                 ` <CAOh2x==aZbqYpPHvWyY7ReVi90TJAHbMLbk17o8wAOh+swbxzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-26 14:13                   ` Linus Walleij
2012-09-26 11:24   ` [PATCH 2/2] ARM: ABMA: Disable/Enable interface " Vipul Kumar Samar
     [not found]     ` <1348658647-25975-3-git-send-email-vipulkumar.samar-qxv4g6HH51o@public.gmane.org>
2012-09-26 12:38       ` Linus Walleij [this message]

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=CACRpkdY_reBeOpyzxdjh9hsc1n_Ff7p5KFBA0Ysys_zDv3WtrA@mail.gmail.com \
    --to=linus.walleij-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
    --cc=damm-yzvPICuk2ACczHhG9Qg4qA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-lFZ/pmaqli7XmaaqVzeoHQ@public.gmane.org \
    --cc=rjw-KKrjLPT3xs0@public.gmane.org \
    --cc=spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=vipulkumar.samar-qxv4g6HH51o@public.gmane.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 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).