From patchwork Thu Jul 21 22:18:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 997402 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6LMIxs0004349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 21 Jul 2011 22:19:20 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qk1Zv-0007rf-MF; Thu, 21 Jul 2011 22:18:47 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qk1Zv-0004lt-AU; Thu, 21 Jul 2011 22:18:47 +0000 Received: from na3sys009aog125.obsmtp.com ([74.125.149.153]) by canuck.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qk1Zr-0004lC-5d for linux-arm-kernel@lists.infradead.org; Thu, 21 Jul 2011 22:18:44 +0000 Received: from mail-fx0-f47.google.com ([209.85.161.47]) (using TLSv1) by na3sys009aob125.postini.com ([74.125.148.12]) with SMTP ID DSNKTiilv2puMX+/EKsEswUWhHekpnrhbzR7@postini.com; Thu, 21 Jul 2011 15:18:42 PDT Received: by mail-fx0-f47.google.com with SMTP id 11so4242250fxg.6 for ; Thu, 21 Jul 2011 15:18:39 -0700 (PDT) Received: by 10.204.7.134 with SMTP id d6mr208210bkd.206.1311286718467; Thu, 21 Jul 2011 15:18:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.66.195 with HTTP; Thu, 21 Jul 2011 15:18:18 -0700 (PDT) In-Reply-To: <20110721074511.GK26574@n2100.arm.linux.org.uk> References: <1311204745-6276-1-git-send-email-mturquette@ti.com> <20110721074511.GK26574@n2100.arm.linux.org.uk> From: "Turquette, Mike" Date: Thu, 21 Jul 2011 15:18:18 -0700 Message-ID: Subject: Re: [PATCH] ARM: do not mark CPU 0 as hotpluggable To: Russell King - ARM Linux X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110721_181843_472968_0DF42F91 X-CRM114-Status: GOOD ( 30.18 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.153 listed in list.dnswl.org] Cc: linaro-dev@lists.linaro.org, santosh.shilimkar@ti.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 21 Jul 2011 22:19:20 +0000 (UTC) X-MIME-Autoconverted: from quoted-printable to 8bit by demeter1.kernel.org id p6LMIxs0004349 On Thu, Jul 21, 2011 at 12:45 AM, Russell King - ARM Linux wrote: > On Wed, Jul 20, 2011 at 04:32:25PM -0700, Mike Turquette wrote: >> A quick poll of the ARM platforms that implement CPU Hotplug support >> shows that every platform treats CPU 0 as a special case that cannot be >> hotplugged.  In fact every platform has identical code for >> platform_cpu_die which returns -EPERM in the case of CPU 0. > > Are you sure that's just not because everyone copied what Realview has > been doing (highly likely)? Copy/paste is always likely. Would be nice for other platform folks to weigh in on this. > I suspect that there's no reason that CPU0 can't be taken down, especially > on those platforms which don't take the CPU fully offline but just put it > into a WFI loop. > > Those which restart the CPUs through the boot loader probably detect CPU0 > as the boot CPU, so they probably can't take CPU0 down. OMAP does seem to have this limitation and Santosh/Richard can provide much better details than me in the parallel thread. Again, would be nice to hear if other platforms have similar limitations from their stakeholders. The idea here is to not mark a CPU hotpluggable if it cannot be hotplugged. If the limitations turn out to be legitimate for some platforms but not others, what's the best way to handle it? Either move the topology initialization to platform code or allow platforms to set some config option. Patches for the latter are below, but I think the current discussion on whether or not other platforms can actually hotplug CPU0 should run its course before considering below patches too seriously. From b734cedf23a9f8366faa1a961d87cb4bc221291e Mon Sep 17 00:00:00 2001 From: Mike Turquette Date: Mon, 18 Jul 2011 17:33:22 -0700 Subject: [PATCH 1/2] ARM: conditionally allow master CPU hotplugging Currently all CPUs are marked as hotpluggable in topology_init(). This is not true for all ARM SMP platforms including OMAP4. In the OMAP4 case, CPU0 is considered as privileged due to TrustZone software and other considerations. This patch introduces a new config option, HOTPLUG_CPU_MASTER, which prevents the first CPU in possible_cpu_mask from being marked hotpluggable if set. Signed-off-by: Mike Turquette --- arch/arm/Kconfig | 8 ++++++++ arch/arm/kernel/setup.c | 5 +++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9adc278..a6e34f5 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1393,6 +1393,14 @@ config HOTPLUG_CPU Say Y here to experiment with turning CPUs off and on. CPUs can be controlled through /sys/devices/system/cpu. +config HOTPLUG_CPU_MASTER + bool "Prevent first CPU (master) from hotplugging" + depends on HOTPLUG_CPU + help + Say Y here if your platform treats the first CPU as a special + "master" CPU and cannot allow it to hotplug. This prevents the + "online" entry in sysfs for that CPU. + config LOCAL_TIMERS bool "Use local timer interrupts" depends on SMP diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index ed11fb0..3785420 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -940,7 +940,12 @@ static int __init topology_init(void) for_each_possible_cpu(cpu) { struct cpuinfo_arm *cpuinfo = &per_cpu(cpu_data, cpu); +#ifdef CONFIG_HOTPLUG_CPU_MASTER + if (cpu) + cpuinfo->cpu.hotpluggable = 1; +#else cpuinfo->cpu.hotpluggable = 1; +#endif register_cpu(&cpuinfo->cpu, cpu); } -- 1.7.4.1 and, From 5e22ea1fa6a10ea0440057832496087297079a5d Mon Sep 17 00:00:00 2001 From: Mike Turquette Date: Tue, 19 Jul 2011 16:47:11 -0700 Subject: [PATCH 2/2] OMAP4: Kconfig: remove hotplug control for CPU0 On OMAP4, CPU0 cannot be dynamically offlined through the usual CPU hotplug mechanism due to a variety of constraints. It is treated as a special "master" CPU for these reasons. Select HOTPLUG_CPU_MASTER to prevent creation of the hotplug control entry in sysfs. Signed-off-by: Mike Turquette --- arch/arm/mach-omap2/Kconfig | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig index 4ae6257..b6199e3 100644 --- a/arch/arm/mach-omap2/Kconfig +++ b/arch/arm/mach-omap2/Kconfig @@ -51,6 +51,7 @@ config ARCH_OMAP4 select ARCH_HAS_OPP select PM_OPP if PM select USB_ARCH_HAS_EHCI + select HOTPLUG_CPU_MASTER comment "OMAP Core Type" depends on ARCH_OMAP2