Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755240AbbFERtS (ORCPT ); Fri, 5 Jun 2015 13:49:18 -0400 Received: from mail-ig0-f176.google.com ([209.85.213.176]:34866 "EHLO mail-ig0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751960AbbFERtP (ORCPT ); Fri, 5 Jun 2015 13:49:15 -0400 MIME-Version: 1.0 In-Reply-To: <1433517104-7595-3-git-send-email-wxt@rock-chips.com> References: <1433517104-7595-1-git-send-email-wxt@rock-chips.com> <1433517104-7595-3-git-send-email-wxt@rock-chips.com> Date: Fri, 5 Jun 2015 10:49:14 -0700 X-Google-Sender-Auth: sGQVGe_WslhJRfgzzl_ng8n7x50 Message-ID: Subject: Re: [PATCH v3 2/3] ARM: rockchip: ensure CPU to enter WFI/WFE state From: Doug Anderson To: Caesar Wang Cc: Heiko Stuebner , Dmitry Torokhov , "open list:ARM/Rockchip SoC..." , Russell King , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2227 Lines: 58 Caesar, On Fri, Jun 5, 2015 at 8:11 AM, Caesar Wang wrote: > In idle mode, core1/2/3 of Cortex-A17 should be either power off or in > WFI/WFE state. > we can delay 1ms to ensure the CPU enter WFI/WFE state. > > Signed-off-by: Caesar Wang > --- > > arch/arm/mach-rockchip/platsmp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm/mach-rockchip/platsmp.c b/arch/arm/mach-rockchip/platsmp.c > index 25da16f..6672fdd 100644 > --- a/arch/arm/mach-rockchip/platsmp.c > +++ b/arch/arm/mach-rockchip/platsmp.c > @@ -325,6 +325,9 @@ static void __init rockchip_smp_prepare_cpus(unsigned int max_cpus) > #ifdef CONFIG_HOTPLUG_CPU > static int rockchip_cpu_kill(unsigned int cpu) > { > + /* ensure CPU can enter the WFI/WFE state */ > + mdelay(1); This is a pretty weak assurance. Is there any stronger assurance you can give that we're in WFI/WFE state and won't come out of it? Do you actually see problems if you power off a CPU when it's not in WFI/WFE state? ...so I _think_ I see the path that is happening here and what you're trying to handle. Specifically, I see: On dying CPU: 1. cpu_die() calls 'complete(&cpu_died)' 2. cpu_die() calls 'smp_ops.cpu_die(cpu)' AKA rockchip_cpu_die() 3. rockchip_cpu_die() does a bit more cache flushing before looping in cpu_do_idle() The problem is that the moment the completion happens in step #1 above the dying CPU can be killed. ...so you're trying to make sure the dying CPU makes it to cpu_do_idle(). In that case a fixed mdelay(1) might be OK since the time that the CPU takes to run through a few instructions (with no interrupts) is pretty predictable. It would be really nice if the commit message went through all this, though. ...but is there any chance that cpu_do_idle() could somehow return? We shouldn't send any events since we've marked the core offline, but perhaps some per-core interrupt (arch timer?) that didn't get migrated? -Doug -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/