mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chenhui Zhao <chenhui.zhao@freescale.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: <linux-kernel@vger.kernel.org>, <kernel@pengutronix.de>,
	<linux-arm-kernel@lists.infradead.org>, <leoli@freescale.com>,
	<Jason.Jin@freescale.com>, <Zhuoyu.Zhang@freescale.com>
Subject: Re: [PATCH 3/3] arm: pm: add deep sleep support for LS1
Date: Mon, 29 Sep 2014 17:42:55 +0800	[thread overview]
Message-ID: <20140929094255.GA14086@udp189498uds.ap.freescale.net> (raw)
In-Reply-To: <20140928142632.GG5182@n2100.arm.linux.org.uk>

On Sun, Sep 28, 2014 at 03:26:33PM +0100, Russell King - ARM Linux wrote:
> On Sun, Sep 28, 2014 at 07:06:40PM +0800, Chenhui Zhao wrote:
> > On Fri, Sep 26, 2014 at 01:14:27PM +0100, Russell King - ARM Linux wrote:
> > > On Fri, Sep 26, 2014 at 07:25:03PM +0800, Chenhui Zhao wrote:
> > > > +/*
> > > > + * r0: the physical entry address of SRAM code
> > > > + *
> > > > + */
> > > > +ENTRY(ls1_do_deepsleep)
> > > > +	mov	r13, r0
> > > > +
> > > > +	/* flush cache */
> > > > +	bl	v7_flush_dcache_all
> > > 
> > > Please explain the purpose of this call via a comment in the code.
> > > 
> > > The generic code will have saved the CPU state, and will have called
> > > flush_cache_louis() to flush the caches to the point of unification.
> > > 
> > > The only data which will have been loaded into the cache between that
> > > point is the stack for the return from __cpu_suspend_save, and
> > > speculative prefetches.
> > > 
> > > So, the only reason I can gather is that you need to flush data from
> > > lower levels of the cache below the point of unification.
> > > 
> > 
> > In deep sleep process, all caches will lost, so flush all caches to prevent
> > data loss.
> 
> You haven't answered my question.
> 

I want to flush L1 and L2 caches of Cortex-A7 in LS1021. However,
flush_cache_louis() only flushed L1 cache. Therefore, call
v7_flush_dcache_all() to flush L1 and L2 cache. 

> > > > +
> > > > +	/* disable cache, C bit in SCTLR */
> > > > +	mrc	p15, 0, r0, c1, c0, 0
> > > > +	bic	r0, r0, #(1 << 2)
> > > > +	mcr	p15, 0, r0, c1, c0, 0
> > > > +	isb
> > > > +
> > > > +	/* disable coherency, SMP bit in ACTLR */
> > > > +	mrc	p15, 0, r0, c1, c0, 1
> > > > +	bic	r0, r0, #(1 << 6)
> > > > +	mcr	p15, 0, r0, c1, c0, 1
> > > > +	isb
> > > > +	dsb
> > > > +
> > > > +	/* disable MMU, M bit in SCTLR */
> > > > +	mrc	p15, 0, r0, c1, c0, 0
> > > > +	bic	r0, r0, #1
> > > > +	mcr	p15, 0, r0, c1, c0, 0
> > > > +	isb
> > > > +
> > > > +	/* jump to sram code using physical address */
> > > > +	bx	r13
> > > 
> > > This looks extremely fragile.  You are running in virtual space, and you
> > > turn the MMU off.  You are reliant on the MMU still being on for the
> > > following instructions to already be in the pipeline.  That's not a
> > > very good assumption to make (we've made it in the past and it breaks
> > > every so often when things change, eg when the code is no longer laid
> > > out how we expect.)
> > > 
> > > You need to disable the MMU safely, which means using the identity map
> > > page tables and executing code in the identity map region.
> > 
> > Yes, the code will switch off MMU, and switch to physical address space.
> > On LS1021, the DDR memory located at the physical address space started from
> > 0x80000000, the kernel space also started at 0x80000000 (CONFIG_PAGE_OFFSET = 0x80000000).
> > So the virtual address of kernel code is equal to the physical address.
> 
> You can't rely on that.
> 
> Sorry, NAK.

I'll try to use a safer method to implement it.

Chenhui

      reply	other threads:[~2014-09-29  9:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 11:25 [PATCH 0/3] arm: ls1: add deep sleep support Chenhui Zhao
2014-09-26 11:25 ` [PATCH 1/3] arm: ls1: add CPU hotplug platform support Chenhui Zhao
2014-09-26 12:20   ` Russell King - ARM Linux
2014-09-26 12:46     ` Mark Rutland
2014-09-26 13:03       ` Russell King - ARM Linux
2014-09-26 13:20         ` Mark Rutland
2014-09-28 10:57           ` Li Yang
2014-09-28 14:27             ` Russell King - ARM Linux
2014-09-26 11:25 ` [PATCH 2/3] pm: add FSM configuration for deep sleep Chenhui Zhao
2014-09-26 12:02   ` Russell King - ARM Linux
2014-09-26 20:51     ` Russell King - ARM Linux
2014-09-28  9:53       ` Chenhui Zhao
2014-09-26 11:25 ` [PATCH 3/3] arm: pm: add deep sleep support for LS1 Chenhui Zhao
2014-09-26 12:14   ` Russell King - ARM Linux
2014-09-28 11:06     ` Chenhui Zhao
2014-09-28 14:26       ` Russell King - ARM Linux
2014-09-29  9:42         ` Chenhui Zhao [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=20140929094255.GA14086@udp189498uds.ap.freescale.net \
    --to=chenhui.zhao@freescale.com \
    --cc=Jason.Jin@freescale.com \
    --cc=Zhuoyu.Zhang@freescale.com \
    --cc=kernel@pengutronix.de \
    --cc=leoli@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    /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

all inboxes | Powered by JetHome®