Linux Power Management development
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Chander Kashyap <chander.kashyap@linaro.org>
Cc: "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"daniel.lezcano@linaro.org" <daniel.lezcano@linaro.org>,
	"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
	"kgene.kim@samsung.com" <kgene.kim@samsung.com>,
	Chander Kashyap <k.chander@samsung.com>
Subject: Re: [Patch v4 5/5] mcpm: exynos: populate suspend and powered_up callbacks
Date: Tue, 13 May 2014 18:14:52 +0100	[thread overview]
Message-ID: <20140513171452.GB10210@red-moon> (raw)
In-Reply-To: <CANuQgHG9tGzi2rSOwREAxVu4BQoprDg9om62AybgW5v31fpbTQ@mail.gmail.com>

On Tue, May 13, 2014 at 12:43:31PM +0100, Chander Kashyap wrote:

[...]

> >> +static void exynos_suspend(u64 residency)
> >> +{
> >> +     unsigned int mpidr, cpunr;
> >> +
> >> +     mpidr = read_cpuid_mpidr();
> >> +     cpunr = exynos_pmu_cpunr(mpidr);
> >
> > If I were to be picky, I would compute these values only if they
> > are needed, ie move the computation after exynos_power_down().
> 
> Yes thats make sense. I will realign it.
> 
> >
> > There is another quite horrible issue here. We know this code works
> > because the processors A15/A7 hit the caches with C bit in SCTLR cleared.
> >
> > On processors where this is not true, this sequence would explode
> > if power down fails (in case core is gated but L2 is still powered on,
> > the stack is stuck in L2) since it is going to read stack data that is
> > in L2 but can't be read.
> >
> > It is not related to this sequence only, but it is an issue in general
> > and wanted to mention that on the lists for public awareness.
> >
> 
> Can you please elaborate. I didn't understand.

It is not related to this patch only. This function carries out writes to the
stack (which might end up in eg L2) and then disables the C bit in SCTLR
through MCPM.

A15 and A7 processors hit the cache with the C bit clear in the SCTLR
so the processor still "hits" the stack values if the power down fails.
On processors where caches are not hit with the C bit clear (eg A9) this code
would fail since the stack values that sit in the caches cannot be read with
the C bit clear in SCTLR until the SCTLR is restored, so it will have to
be implemented in assembly with no stack usage (or better, no cacheable data
usage).

So, all I am saying is, to avoid copy'n'paste havoc and to avoid running
this code on Exynos platforms where it must not be run as-is, please add
a comment along the line:

"This function requires the stack data to be visible through power down
and can only be executed on processors like A15 and A7 that hit the cache
with the C bit clear in the SCTLR register."

Please let me know if that's clear.

Lorenzo

> 
> > The gist of what I am saying is, please add a comment to that extent,
> > here and it should be added in exynos_power_down() too.
> >
> >> +     __raw_writel(virt_to_phys(mcpm_entry_point), ns_sram_base_addr + 0x1c);
> >
> > No magic numbers please (0x1c). You can add a macro/wrapper, as TC2 does.
> 
> Yes i will remove it.
> 
> >
> >> +     exynos_power_down();
> >> +
> >> +     /*
> >> +      * Execution reaches here only if cpu did not power down.
> >> +      * Hence roll back the changes done in exynos_power_down function.
> >> +     */
> >> +     exynos_cpu_powerup(cpunr);
> >
> > Please be aware that if this function returns MCPM will soft reboot, and
> > the CPUidle driver will have no way to detect a state entry failure.
> >
> > I am just flagging this up, since fixing this behaviour is not easy, and
> > honestly, since power down failure should be the exception not the rule,
> > the idle stats should not be affected much.
> >
> > I think this is the proper way of implementing the sequence but please
> > all keep in mind what I wrote above.
> >
> > Lorenzo
> >
> >> +}
> >> +
> >>  static const struct mcpm_platform_ops exynos_power_ops = {
> >>       .power_up               = exynos_power_up,
> >>       .power_down             = exynos_power_down,
> >>       .power_down_finish      = exynos_power_down_finish,
> >> +     .suspend                = exynos_suspend,
> >> +     .powered_up             = exynos_powered_up,
> >>  };
> >>
> >>  static void __init exynos_mcpm_usage_count_init(void)
> >> --
> >> 1.7.9.5
> >>
> >>
> >
> 
> 
> 
> -- 
> with warm regards,
> Chander Kashyap
> 


  reply	other threads:[~2014-05-13 17:12 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 11:49 [PATCH 0/4] add cpuidle support for Exynos5420 Chander Kashyap
2014-04-21 11:49 ` [PATCH 1/4] cpuidle: config: Add SOC_EXYNOS5420 entry to select cpuidle-big-little driver Chander Kashyap
2014-04-22 10:42   ` Daniel Lezcano
2014-04-23  6:20     ` Chander Kashyap
2014-04-21 11:49 ` [PATCH 2/4] driver: cpuidle: cpuidle-big-little: init driver for Exynos5420 Chander Kashyap
2014-04-22 10:39   ` Daniel Lezcano
2014-04-22 11:12   ` Daniel Lezcano
2014-04-21 11:49 ` [PATCH 3/4] exynos: cpuidle: do not allow cpuidle registration " Chander Kashyap
2014-04-22 10:38   ` Daniel Lezcano
2014-04-21 11:49 ` [PATCH 4/4] mcpm: exynos: populate suspend and powered_up callbacks Chander Kashyap
2014-04-22 10:51   ` Daniel Lezcano
2014-04-23  8:22     ` Chander Kashyap
2014-04-23  9:25   ` [Patch v2 0/4] add cpuidle support for Exynos5420 Chander Kashyap
2014-04-23  9:25     ` [Patch v2 1/4] cpuidle: config: Add SOC_EXYNOS5420 entry to select cpuidle-big-little driver Chander Kashyap
2014-04-23  9:25     ` [Patch v2 2/4] driver: cpuidle: cpuidle-big-little: init driver for Exynos5420 Chander Kashyap
2014-04-23 16:32       ` Lorenzo Pieralisi
2014-04-24  7:47         ` Chander Kashyap
2014-04-23  9:25     ` [Patch v2 3/4] exynos: cpuidle: do not allow cpuidle registration " Chander Kashyap
2014-04-23  9:25     ` [Patch v2 4/4] mcpm: exynos: populate suspend and powered_up callbacks Chander Kashyap
2014-04-23 16:02       ` Lorenzo Pieralisi
2014-04-24  7:44         ` Chander Kashyap
2014-04-23 10:18     ` [Patch v2 0/4] add cpuidle support for Exynos5420 Rafael J. Wysocki
2014-04-23 15:42       ` Kukjin Kim
2014-05-05  8:27     ` [PATCH v3 0/5] " Chander Kashyap
2014-05-05  8:27       ` [Patch v3 1/5] driver: cpuidle-big-little: add of_device_id structure Chander Kashyap
2014-05-05  8:27       ` [Patch v3 2/5] cpuidle: config: Add ARCH_EXYNOS entry to select cpuidle-big-little driver Chander Kashyap
2014-05-05  8:59         ` Andreas Färber
2014-05-05  9:09           ` Chander Kashyap
2014-05-05  9:27         ` [PATCH v4 0/5] add cpuidle support for Exynos5420 Chander Kashyap
2014-05-05  9:27           ` [Patch v4 1/5] driver: cpuidle-big-little: add of_device_id structure Chander Kashyap
2014-05-05  9:27           ` [Patch v4 2/5] cpuidle: config: Add ARCH_EXYNOS entry to select cpuidle-big-little driver Chander Kashyap
2014-05-05  9:27           ` [Patch v4 3/5] driver: cpuidle: cpuidle-big-little: init driver for Exynos5420 Chander Kashyap
2014-05-05  9:27           ` [Patch v4 4/5] exynos: cpuidle: do not allow cpuidle registration " Chander Kashyap
2014-05-05  9:27           ` [Patch v4 5/5] mcpm: exynos: populate suspend and powered_up callbacks Chander Kashyap
2014-05-09 15:32             ` Lorenzo Pieralisi
2014-05-13 11:43               ` Chander Kashyap
2014-05-13 17:14                 ` Lorenzo Pieralisi [this message]
2014-05-14  2:52                   ` Chander Kashyap
2014-05-05  8:27       ` [Patch v3 3/5] driver: cpuidle: cpuidle-big-little: init driver for Exynos5420 Chander Kashyap
2014-05-05  8:27       ` [Patch v3 4/5] exynos: cpuidle: do not allow cpuidle registration " Chander Kashyap
2014-05-05  8:27       ` [Patch v3 5/5] mcpm: exynos: populate suspend and powered_up callbacks Chander Kashyap

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=20140513171452.GB10210@red-moon \
    --to=lorenzo.pieralisi@arm.com \
    --cc=chander.kashyap@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=k.chander@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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