linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 6/6] arm/imx6q: add suspend/resume support
Date: Thu, 8 Sep 2011 17:24:52 +0100	[thread overview]
Message-ID: <20110908162452.GA20292@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20110908152222.GA31581@S2100-06.ap.freescale.net>

On Thu, Sep 08, 2011 at 11:22:23PM +0800, Shawn Guo wrote:
> On Thu, Sep 08, 2011 at 08:47:18AM +0100, Russell King - ARM Linux wrote:
> > On Thu, Sep 08, 2011 at 02:23:02PM +0800, Shawn Guo wrote:
> > > Yes, if you lose L2 power in suspend, it's the easiest way for you to
> > > resume L2.
> > > 
> > > For my case which retains L2, I actually do not want to call this
> > > function which will invalidate L2.  But since we still have problem
> > > to use rmk's generic suspend/resume updates (ARM: pm: add L2 cache
> > > cleaning for suspend), we have to flush the entire L2 on imx6q for now.
> > 
> > OMAP44xx has the same problem but they re-initialize L2 on resume in
> > their pre-cpu_resume() assembly code.
> > 
> Are you suggesting that this might be the reason why imx6q has problem
> with your patch?

Consider the mechanics of what is happening.

On suspend, when we enter cpu_suspend(), we assume the L2 cache is
still enabled.

We _always_ assume that L1 cache state is lost, so we always flush the
entire L1 cache.

As SoCs can (and do) preserve the L2 contents over suspend/resume cycles,
we leave it to the platform's finisher to decide whether it needs to
flush the entire L2 cache to RAM or not.

If L2 is preserved, then we want to ensure that as much data as possible
is retained in the L2 cache (if the hardware preserves its contents, we
don't want waste time flushing data out of the cache needlessly -
especially if we're using these paths for cpuidle.)  However, we need
access to a certain amount of data to bring the system back up, and as
the L2 cache typically will not be searched before the MMU is enabled,
we have to flush out a certain minimal amount of data (the location
of the stacked restore information and the stacked restore information
itself.)

However, we don't flush out anything else from the L2 cache.

Now, upon resume, the resume code will be able to read the data it needs
to restore the system as we ensured that was flushed out to memory - as
I mentioned above, the L2 cache won't be searched for this irrespective
of whether the control registers have enabled it or not.

We will continue to the point where we hit the first bit of information
stored in L2, which will probably be the stacked SVC register set.  If
at this point we're not able to search the L2 cache, then we'll read
stale data from the backing memory instead, and the system will crash.

Consider what generic code could do about this - if we flushed out that
register set to memory, then we could get past that point - but we then
would need to call a function to enable the L2 cache.  What if that
function needs data which is sitting in the L2 cache to function (eg,
it may need values from the device tree).  We would need to ensure
that that data were also flushed out of the L2 cache.  What about
spinlocks?  Maybe some other CPU has dragged the spinlock data into
the L2 cache.  That gets _much_ harder to solve.

Now to the physical act of enabling the L2 cache.  The L2 cache control
registers are subject to security restrictions when running in non-secure
mode, needing platform specific SMC calls to reprogram the cache.  Generic
code is unable to do this.

Hence why it's left up to the platform to figure out how to enable the
L2 cache before calling cpu_resume().  The platform is best placed to
work out what it needs to do to setup the L2 cache so that the L2 cache
is available by the time the system control register is written, enabling
the MMU and caches.

> Are we supposed to re-initialize L2 before calling
> into generic cpu_resume()?

So, the above is the long way of saying "yes" to this question.  I hope
it gives the full picture about why this is so.

  reply	other threads:[~2011-09-08 16:24 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06  9:58 [PATCH 0/6] add initial imx6q support Shawn Guo
2011-09-06  9:58 ` [PATCH 1/6] arm/imx6q: add device tree source Shawn Guo
2011-09-06 18:31   ` Arnd Bergmann
2011-09-07 11:16     ` Shawn Guo
2011-09-06  9:58 ` [PATCH 2/6] arm/imx6q: add core definitions and low-level debug uart Shawn Guo
2011-09-06 18:39   ` Arnd Bergmann
2011-09-07  8:50     ` Shawn Guo
2011-09-06 20:25   ` Uwe Kleine-König
2011-09-07 11:00     ` Shawn Guo
2011-09-07 12:36       ` Uwe Kleine-König
2011-09-07 14:23         ` Russell King - ARM Linux
2011-09-07 15:36           ` Nicolas Pitre
2011-09-08 14:56             ` Arnd Bergmann
2011-09-09 17:28               ` Tony Lindgren
2011-09-12  2:30         ` Shawn Guo
2011-09-12  7:41           ` Uwe Kleine-König
2011-09-12  8:43             ` Shawn Guo
2011-09-12  8:44       ` Sascha Hauer
2011-09-12 11:36         ` Shawn Guo
2011-09-12 14:14         ` Russell King - ARM Linux
2011-09-17 11:59           ` Russell King - ARM Linux
2011-09-15  1:24     ` Shawn Guo
2011-09-06  9:58 ` [PATCH 3/6] arm/imx6q: add core drivers clock, gpc, mmdc and src Shawn Guo
2011-09-06 19:14   ` Arnd Bergmann
2011-09-07  6:05     ` Shawn Guo
2011-09-07  7:56       ` Arnd Bergmann
2011-09-12 16:12         ` Shawn Guo
2011-09-12 19:40           ` Grant Likely
2011-09-12 20:28             ` Arnd Bergmann
2011-09-12 21:04               ` Grant Likely
2011-09-13  0:07             ` Shawn Guo
2011-09-07 12:43       ` Barry Song
2011-09-08  6:48         ` Shawn Guo
2011-09-11  2:28           ` Barry Song
2011-09-12 19:16           ` Grant Likely
2011-09-12  9:46   ` Sascha Hauer
2011-09-12 11:49     ` Shawn Guo
2011-09-12 12:36       ` Uwe Kleine-König
2011-09-12 12:40         ` Arnd Bergmann
2011-09-12 14:27           ` Shawn Guo
2011-09-15  1:26             ` Shawn Guo
2011-09-06  9:58 ` [PATCH 4/6] arm/imx6q: add smp and cpu hotplug support Shawn Guo
2011-09-06 18:53   ` Arnd Bergmann
2011-09-07  4:41     ` Shawn Guo
2011-09-07  5:08       ` Shilimkar, Santosh
2011-09-07  7:46         ` Shawn Guo
2011-09-06  9:58 ` [PATCH 5/6] arm/imx6q: add device tree machine support Shawn Guo
2011-09-06 18:55   ` Arnd Bergmann
2011-09-07  3:07     ` Shawn Guo
2011-09-07  7:26       ` Arnd Bergmann
2011-09-06  9:58 ` [PATCH 6/6] arm/imx6q: add suspend/resume support Shawn Guo
2011-09-06 18:56   ` Arnd Bergmann
2011-09-07 13:50   ` Barry Song
2011-09-08  6:23     ` Shawn Guo
2011-09-08  7:47       ` Russell King - ARM Linux
2011-09-08 15:22         ` Shawn Guo
2011-09-08 16:24           ` Russell King - ARM Linux [this message]
2011-09-08 17:09             ` Lorenzo Pieralisi
2011-09-09  7:40               ` Shawn Guo
2011-09-09  6:31             ` Barry Song
2011-09-09  7:32             ` Shawn Guo
2011-09-09  8:15               ` Russell King - ARM Linux
2011-09-09 10:15                 ` Shawn Guo
2011-09-09 18:47                   ` Russell King - ARM Linux
2011-09-06 18:28 ` [PATCH 0/6] add initial imx6q support Arnd Bergmann
2011-09-06 19:42   ` Uwe Kleine-König
2011-09-07  2:55     ` Shawn Guo
2011-09-07  9:39       ` Arnd Bergmann
2011-09-07  2:51   ` Shawn Guo

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=20110908162452.GA20292@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).