From patchwork Fri Oct 1 11:56:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh KUMAR X-Patchwork-Id: 66364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-wy0-f184.google.com (mail-wy0-f184.google.com [74.125.82.184]) by ozlabs.org (Postfix) with ESMTP id D6295B70E9 for ; Fri, 1 Oct 2010 21:58:23 +1000 (EST) Received: by mail-wy0-f184.google.com with SMTP id 11sf1396664wyi.11 for ; Fri, 01 Oct 2010 04:58:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:mime-version:x-beenthere:received :received:received:received:received-spf:received:received:received :received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=qgpvuwGeqCAC0molNl6Z0vxLM5g/yKLkFCFN6Dbx+8E=; b=tkCRsNU98xYNYIf5ufH2YSnOnJMj2IcxS+jXe5DT75ivij7tZ5G6VEQ9N+ic/PedKq Br34KPNTm+3+YpMyOjwIH7oZTlXKa+tZwgTFOOMoSEcIilVsnooQlXFH0ytx4u9Ib5ze LMw9p6U5YIZ0DeyjXuZfO48famGGTjMM/xgBI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=mime-version:x-beenthere:received-spf:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; b=4tUgo8s5QDQtsEMO0OjigdmbV3+ZfcB8lmZh8pMg1SzeEmwDx18A+Jwuu/oRoSD5Te t5MLognAS7On3o5UT8zhLNQVsih5e1EvwQDERZXi2Y52NAhTv9QLBBPL+iXsSSgIN0RS b+e2C18Y90Jz7AHDAdkRhGOfBW5e+d0Ri1kZI= Received: by 10.216.145.167 with SMTP id p39mr1102467wej.10.1285934302241; Fri, 01 Oct 2010 04:58:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.14.46.205 with SMTP id r53ls233455eeb.7.p; Fri, 01 Oct 2010 04:58:21 -0700 (PDT) Received: by 10.14.45.75 with SMTP id o51mr621569eeb.22.1285934301871; Fri, 01 Oct 2010 04:58:21 -0700 (PDT) Received: by 10.14.45.75 with SMTP id o51mr621568eeb.22.1285934301855; Fri, 01 Oct 2010 04:58:21 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com [207.126.144.133]) by gmr-mx.google.com with ESMTP id w43si1114429eeh.7.2010.10.01.04.58.06; Fri, 01 Oct 2010 04:58:21 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of viresh.kumar@st.com) client-ip=207.126.144.133; Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKTKXMzsc12Hnwx6d6ASwjM1AoOTbF6lX/@postini.com; Fri, 01 Oct 2010 11:58:21 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id AEB76CF; Fri, 1 Oct 2010 11:57:50 +0000 (GMT) Received: from mail2.dlh.st.com (mail2.dlh.st.com [10.199.8.22]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 585782659; Fri, 1 Oct 2010 11:57:47 +0000 (GMT) Received: from localhost (dlhl0509.dlh.st.com [10.199.7.86]) by mail2.dlh.st.com (MOS 3.8.7a) with ESMTP id CUF00993 (AUTH viresh.kumar@st.com); Fri, 1 Oct 2010 17:27:46 +0530 (IST) From: Viresh KUMAR To: linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com, a.zummo@towertech.it, dbrownell@users.sourceforge.net, linux-usb@vger.kernel.org, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, linux-mtd@lists.infradead.org, dwmw2@infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Deepak Sikri , shiraz.hashim@st.com, vipin.kumar@st.com, armando.visconti@st.com, vipulkumar.samar@st.com, rajeev-dlh.kumar@st.com, pratyush.anand@st.com, bhupesh.sharma@st.com, Viresh Kumar Subject: [rtc-linux] [PATCH V2 47/69] ST SPEAr13xx: Adding CPU hotplug support added for SMP platforms Date: Fri, 1 Oct 2010 17:26:07 +0530 Message-Id: X-Mailer: git-send-email 1.7.2.2 In-Reply-To: References: In-Reply-To: References: X-Original-Sender: viresh.kumar@st.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of viresh.kumar@st.com) smtp.mail=viresh.kumar@st.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Deepak Sikri Signed-off-by: Deepak Sikri Signed-off-by: shiraz hashim Signed-off-by: Viresh Kumar --- arch/arm/mach-spear13xx/Makefile | 1 + arch/arm/mach-spear13xx/hotplug.c | 135 +++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-spear13xx/hotplug.c diff --git a/arch/arm/mach-spear13xx/Makefile b/arch/arm/mach-spear13xx/Makefile index 799eefa..869afb4 100644 --- a/arch/arm/mach-spear13xx/Makefile +++ b/arch/arm/mach-spear13xx/Makefile @@ -5,6 +5,7 @@ # common files obj-y += spear13xx.o clock.o fsmc-nor.o obj-$(CONFIG_SMP) += platsmp.o headsmp.o +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o obj-$(CONFIG_PCIEPORTBUS) += pcie.o obj-$(CONFIG_PM) += pm.o sleep.o diff --git a/arch/arm/mach-spear13xx/hotplug.c b/arch/arm/mach-spear13xx/hotplug.c new file mode 100644 index 0000000..a3259bf --- /dev/null +++ b/arch/arm/mach-spear13xx/hotplug.c @@ -0,0 +1,135 @@ +/* + * linux/arch/arm/mach-spear13xx/hotplug.c + * + * Copyright (C) 2010 ST Microelectronics Ltd. + * Deepak Sikri + * + * based upon linux/arch/arm/mach-realview/hotplug.c + * + * Copyright (C) 2002 ARM Ltd. + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include + +extern volatile int pen_release; + +static DECLARE_COMPLETION(cpu_killed); + +static inline void cpu_enter_lowpower(void) +{ + unsigned int v; + + flush_cache_all(); + asm volatile( + " mcr p15, 0, %1, c7, c5, 0\n" + " dsb\n" + /* + * Turn off coherency + */ + " mrc p15, 0, %0, c1, c0, 1\n" + " bic %0, %0, #0x20\n" + " mcr p15, 0, %0, c1, c0, 1\n" + " mrc p15, 0, %0, c1, c0, 0\n" + " bic %0, %0, #0x04\n" + " mcr p15, 0, %0, c1, c0, 0\n" + : "=&r" (v) + : "r" (0) + : "cc", "memory"); +} + +static inline void cpu_leave_lowpower(void) +{ + unsigned int v; + + asm volatile("mrc p15, 0, %0, c1, c0, 0\n" + " orr %0, %0, #0x04\n" + " mcr p15, 0, %0, c1, c0, 0\n" + " mrc p15, 0, %0, c1, c0, 1\n" + " orr %0, %0, #0x20\n" + " mcr p15, 0, %0, c1, c0, 1\n" + : "=&r" (v) + : + : "cc"); +} + +static inline void platform_do_lowpower(unsigned int cpu) +{ + for (;;) { + wfi(); + + if (pen_release == cpu) { + /* + * OK, proper wakeup, we're done + */ + break; + } + + /* + * getting here, means that we have come out of WFI without + * having been woken up - this shouldn't happen + * + * The trouble is, letting people know about this is not really + * possible, since we are currently running incoherently, and + * therefore cannot safely call printk() or anything else + */ +#ifdef DEBUG + pr_crit("CPU%u: spurious wakeup call\n", cpu); +#endif + } +} + +int platform_cpu_kill(unsigned int cpu) +{ + return wait_for_completion_timeout(&cpu_killed, 5000); +} + +/* + * platform-specific code to shutdown a CPU + * + * Called with IRQs disabled + */ +void __cpuinit platform_cpu_die(unsigned int cpu) +{ +#ifdef DEBUG + unsigned int this_cpu = hard_smp_processor_id(); + + if (cpu != this_cpu) { + pr_crit("Eek! platform_cpu_die running on %u, should\ + be %u\n", this_cpu, cpu); + BUG(); + } +#endif + + printk(KERN_NOTICE "CPU%u: shutdown\n", cpu); + complete(&cpu_killed); + + /* + * we're ready for shutdown now, so do it + */ + cpu_enter_lowpower(); + platform_do_lowpower(cpu); + + /* + * bring this CPU back into the world of cache + * coherency, and then restore interrupts + */ + cpu_leave_lowpower(); +} + +int platform_cpu_disable(unsigned int cpu) +{ + /* + * we don't allow CPU 0 to be shutdown (it is still too special + * e.g. clock tick interrupts) + */ + return cpu == 0 ? -EPERM : 0; +}