From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: imx: disable cpu in .cpu_kill hook
Date: Mon, 14 Jan 2013 07:55:36 -0600 [thread overview]
Message-ID: <50F40E58.4030808@gmail.com> (raw)
In-Reply-To: <1358168977-9631-1-git-send-email-shawn.guo@linaro.org>
On 01/14/2013 07:09 AM, Shawn Guo wrote:
> It's buggy to disable the cpu that is being hot-unplugged in .cpu_die
> hook which runs on the cpu itself. Instead, it should be done in
> .cpu_kill which runs on the thread (another cpu) that asks for shutting
> down the cpu. Move imx_enable_cpu(cpu, false) call into .cpu_kill
> hook, and leave the cpu to be hot-unplugged in WFI with a recovery call
> cpu_leave_lowpower(), so that we can get a more stable cpu hot-plug
> operation.
>
> Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
> ---
> arch/arm/mach-imx/common.h | 1 +
> arch/arm/mach-imx/hotplug.c | 31 +++++++++++++++++++++++++++----
> arch/arm/mach-imx/platsmp.c | 1 +
> 3 files changed, 29 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
> index 7191ab4..fa36fb8 100644
> --- a/arch/arm/mach-imx/common.h
> +++ b/arch/arm/mach-imx/common.h
> @@ -142,6 +142,7 @@ extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
> extern void imx6q_clock_map_io(void);
>
> extern void imx_cpu_die(unsigned int cpu);
> +extern int imx_cpu_kill(unsigned int cpu);
>
> #ifdef CONFIG_PM
> extern void imx6q_pm_init(void);
> diff --git a/arch/arm/mach-imx/hotplug.c b/arch/arm/mach-imx/hotplug.c
> index 3dec962..a9b4096 100644
> --- a/arch/arm/mach-imx/hotplug.c
> +++ b/arch/arm/mach-imx/hotplug.c
> @@ -38,6 +38,22 @@ static inline void cpu_enter_lowpower(void)
> : "cc");
> }
>
> +static inline void cpu_leave_lowpower(void)
> +{
> + unsigned int v;
> +
> + asm volatile(
> + "mrc p15, 0, %0, c1, c0, 0\n"
> + " orr %0, %0, %1\n"
> + " mcr p15, 0, %0, c1, c0, 0\n"
Can't you do:
set_cr(get_cr() | CR_C);
> + " mrc p15, 0, %0, c1, c0, 1\n"
> + " orr %0, %0, %2\n"
> + " mcr p15, 0, %0, c1, c0, 1\n"
Setting or clearing the SMP bit is showing up in multiple places
(big.LITTLE series, Tegra cpuidle). I did inline versions of
set_auxcr/get_auxcr for highbank cpuidle. We should be make those common.
Rob
> + : "=&r" (v)
> + : "Ir" (CR_C), "Ir" (0x40)
> + : "cc");
> +}
> +
> /*
> * platform-specific code to shutdown a CPU
> *
> @@ -45,10 +61,17 @@ static inline void cpu_enter_lowpower(void)
> */
> void imx_cpu_die(unsigned int cpu)
> {
> + static int spurious;
> +
> cpu_enter_lowpower();
> - imx_enable_cpu(cpu, false);
> + cpu_do_idle();
> + cpu_leave_lowpower();
>
> - /* spin here until hardware takes it down */
> - while (1)
> - ;
> + pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, ++spurious);
> +}
> +
> +int imx_cpu_kill(unsigned int cpu)
> +{
> + imx_enable_cpu(cpu, false);
> + return 1;
> }
> diff --git a/arch/arm/mach-imx/platsmp.c b/arch/arm/mach-imx/platsmp.c
> index 3777b80..66fae88 100644
> --- a/arch/arm/mach-imx/platsmp.c
> +++ b/arch/arm/mach-imx/platsmp.c
> @@ -92,5 +92,6 @@ struct smp_operations imx_smp_ops __initdata = {
> .smp_boot_secondary = imx_boot_secondary,
> #ifdef CONFIG_HOTPLUG_CPU
> .cpu_die = imx_cpu_die,
> + .cpu_kill = imx_cpu_kill,
> #endif
> };
>
next prev parent reply other threads:[~2013-01-14 13:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-14 13:09 [PATCH] ARM: imx: disable cpu in .cpu_kill hook Shawn Guo
2013-01-14 13:32 ` Russell King - ARM Linux
2013-01-14 13:48 ` Shawn Guo
2013-01-14 13:55 ` Rob Herring [this message]
2013-01-14 14:00 ` Shawn Guo
2013-01-14 16:29 ` Nicolas Pitre
2013-01-14 16:46 ` Russell King - ARM Linux
2013-01-14 16:57 ` Nicolas Pitre
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=50F40E58.4030808@gmail.com \
--to=robherring2@gmail.com \
--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