linux-pm.vger.kernel.org archive mirror
 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>,
	nicolas.pitre@linaro.org
Subject: Re: [Patch v2 4/4] mcpm: exynos: populate suspend and powered_up callbacks
Date: Wed, 23 Apr 2014 17:02:56 +0100	[thread overview]
Message-ID: <20140423160256.GA1243@e102568-lin.cambridge.arm.com> (raw)
In-Reply-To: <1398245154-18771-5-git-send-email-chander.kashyap@linaro.org>

[added Nico in CC]

On Wed, Apr 23, 2014 at 10:25:54AM +0100, Chander Kashyap wrote:
> In order to support cpuidle through mcpm, suspend and powered-up
> callbacks are required in mcpm platform code.
> Hence populate the same callbacks.
> 
> Signed-off-by: Chander Kashyap <chander.kashyap@linaro.org>
> Signed-off-by: Chander Kashyap <k.chander@samsung.com>
> ---
> changes in v2:
> 	1. Fixed typo: enynos_pmu_cpunr to exynos_pmu_cpunr
> 
>  arch/arm/mach-exynos/mcpm-exynos.c |   53 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
> 
> diff --git a/arch/arm/mach-exynos/mcpm-exynos.c b/arch/arm/mach-exynos/mcpm-exynos.c
> index 6c74c82..d53f597 100644
> --- a/arch/arm/mach-exynos/mcpm-exynos.c
> +++ b/arch/arm/mach-exynos/mcpm-exynos.c
> @@ -272,10 +272,63 @@ static int exynos_power_down_finish(unsigned int cpu, unsigned int cluster)
>  	return 0; /* success: the CPU is halted */
>  }
>  
> +static void enable_coherency(void)
> +{
> +	unsigned long v, u;
> +
> +	asm volatile(
> +		"mrc	p15, 0, %0, c1, c0, 1\n"
> +		"orr	%0, %0, %2\n"
> +		"ldr	%1, [%3]\n"
> +		"and	%1, %1, #0\n"
> +		"orr	%0, %0, %1\n"
> +		"mcr	p15, 0, %0, c1, c0, 1\n"
> +		: "=&r" (v), "=&r" (u)
> +		: "Ir" (0x40), "Ir" (S5P_INFORM0)
> +		: "cc");
> +}
> +
> +void exynos_powered_up(void)
> +{
> +	unsigned int mpidr, cpu, cluster;
> +
> +	mpidr = read_cpuid_mpidr();
> +	cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
> +	cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
> +
> +	arch_spin_lock(&exynos_mcpm_lock);
> +	if (cpu_use_count[cpu][cluster] == 0)
> +		cpu_use_count[cpu][cluster] = 1;
> +	arch_spin_unlock(&exynos_mcpm_lock);
> +}
> +
> +static void exynos_suspend(u64 residency)
> +{
> +	unsigned int mpidr, cpunr;
> +
> +	mpidr = read_cpuid_mpidr();
> +	cpunr = exynos_pmu_cpunr(mpidr);
> +
> +	__raw_writel(virt_to_phys(mcpm_entry_point), REG_ENTRY_ADDR);
> +
> +	exynos_power_down();
> +
> +	/*
> +	 * Execution reaches here only if cpu did not power down.
> +	 * Hence roll back the changes done in exynos_power_down function.
> +	*/
> +	__raw_writel(EXYNOS_CORE_LOCAL_PWR_EN,
> +			EXYNOS_ARM_CORE_CONFIGURATION(cpunr));
> +	set_cr(get_cr() | CR_C);
> +	enable_coherency();

This is wrong:

1) MCPM would eventually reboot the CPU in question if the suspend call
   returns (and restore SCTLR and ACTLR in cpu_resume), so there is 0 point
   in doing that here.
2) The core would have executed out of coherency for a "while" so the
   tlbs could be stale and you do not invalidate them. But given (1), (2)
   becomes just informational. The register write must be executed
   though (I guess...). Now, on restoring the SMP bit in cpu_resume
   (errata 799270) I need to verify this is safe and get back to you.

Cheers,
Lorenzo

  reply	other threads:[~2014-04-23 16:02 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 [this message]
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
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=20140423160256.GA1243@e102568-lin.cambridge.arm.com \
    --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=nicolas.pitre@linaro.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;
as well as URLs for NNTP newsgroup(s).