From patchwork Sat Mar 14 11:49:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Nie X-Patchwork-Id: 45814 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ACB97214BF for ; Sat, 14 Mar 2015 11:53:55 +0000 (UTC) Received: by wibbs8 with SMTP id bs8sf1170617wib.3 for ; Sat, 14 Mar 2015 04:53:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=tax1ztx89u3ajY6t5e303fbhYmNONbdRxuZKrXj8B5g=; b=O3pP9GR1iPCa7I179qnstjp+DtTdj8HBS2QW9Q4Yfkyp+KgQqawGFOw2+1YkwiUUNA 920niUpnh7Nk5XeQFs4x9lB/SvS87sDHCFkw9V2Mw3MZcsCbGEZAH90TbrZ8dmfvxZXQ sOHGYBfNxa1iq0pNtPof7fYa3sfZ+9OuNsvBkDBs/hd7SzeWBY3Dv57ceLMX/q7wzxf7 ld3ePQP5wo1CyJn4R717/yvGHZW8/RJ5c6CpnKq14/ab7fTyN2VGwwGRfsLcdy5b/DXZ 3KeC4PCQOzKDAEmcjFGMJFD9+Zi4tEFn6QeVwCnyuBNsdyaY3a5C004wAxdA10LkjGR0 Qq3Q== X-Gm-Message-State: ALoCoQnjhPXF4P1taNajUu6BMBCwEeciBzd5tne1F8ZqRLNMPaT0JN2+lIhgS1kxdxbIIDV+HrkI X-Received: by 10.180.90.175 with SMTP id bx15mr4645253wib.3.1426334034942; Sat, 14 Mar 2015 04:53:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.101 with SMTP id lv5ls513931lac.22.gmail; Sat, 14 Mar 2015 04:53:54 -0700 (PDT) X-Received: by 10.112.185.101 with SMTP id fb5mr47995252lbc.12.1426334034265; Sat, 14 Mar 2015 04:53:54 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id gz6si3363460lac.135.2015.03.14.04.53.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Mar 2015 04:53:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labjg1 with SMTP id jg1so8020623lab.2 for ; Sat, 14 Mar 2015 04:53:54 -0700 (PDT) X-Received: by 10.112.201.231 with SMTP id kd7mr26601620lbc.35.1426334034110; Sat, 14 Mar 2015 04:53:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp1478016lbj; Sat, 14 Mar 2015 04:53:53 -0700 (PDT) X-Received: by 10.70.15.67 with SMTP id v3mr43668351pdc.166.1426334032347; Sat, 14 Mar 2015 04:53:52 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f10si9461302pas.26.2015.03.14.04.53.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Mar 2015 04:53:52 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YWkc7-000487-5J; Sat, 14 Mar 2015 11:52:19 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YWkai-0003Ar-BH for linux-arm-kernel@lists.infradead.org; Sat, 14 Mar 2015 11:50:53 +0000 Received: by pabyw6 with SMTP id yw6so14751166pab.2 for ; Sat, 14 Mar 2015 04:50:31 -0700 (PDT) X-Received: by 10.66.235.169 with SMTP id un9mr110662342pac.45.1426333831037; Sat, 14 Mar 2015 04:50:31 -0700 (PDT) Received: from localhost.localdomain ([107.6.112.156]) by mx.google.com with ESMTPSA id ov5sm7365488pdb.91.2015.03.14.04.50.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Mar 2015 04:50:29 -0700 (PDT) From: Jun Nie To: linux-arm-kernel@lists.infradead.org, mturquette@linaro.org, linux@arm.linux.org.uk, shawn.guo@linaro.org, jun.nie@linaro.org, zte-lt@lists.linaro.org Subject: [PATCH 06/10] ARM: zx: add cpu hotplug support Date: Sat, 14 Mar 2015 19:49:41 +0800 Message-Id: <1426333785-3952-7-git-send-email-jun.nie@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1426333785-3952-1-git-send-email-jun.nie@linaro.org> References: <1426333785-3952-1-git-send-email-jun.nie@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150314_045052_497063_F6F83490 X-CRM114-Status: GOOD ( 15.68 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.44 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.44 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: jun.nie@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 It's a clone of vexpress cpu hotplug implementation. Signed-off-by: Shawn Guo Signed-off-by: Jun Nie --- arch/arm/mach-zx/Makefile | 1 + arch/arm/mach-zx/core.h | 1 + arch/arm/mach-zx/hotplug.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-zx/platsmp.c | 3 ++ 4 files changed, 113 insertions(+) create mode 100644 arch/arm/mach-zx/hotplug.c diff --git a/arch/arm/mach-zx/Makefile b/arch/arm/mach-zx/Makefile index 7c2edf6..a3b386e7 100644 --- a/arch/arm/mach-zx/Makefile +++ b/arch/arm/mach-zx/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_SOC_ZX296702) += zx296702.o obj-$(CONFIG_SMP) += headsmp.o platsmp.o +obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o diff --git a/arch/arm/mach-zx/core.h b/arch/arm/mach-zx/core.h index 400c7b4..9f6b719 100644 --- a/arch/arm/mach-zx/core.h +++ b/arch/arm/mach-zx/core.h @@ -13,5 +13,6 @@ extern struct smp_operations zx_smp_ops; void zx_secondary_startup(void); +void zx_cpu_die(unsigned int cpu); #endif /* __MACH_ZX_CORE_H */ diff --git a/arch/arm/mach-zx/hotplug.c b/arch/arm/mach-zx/hotplug.c new file mode 100644 index 0000000..1b660e1 --- /dev/null +++ b/arch/arm/mach-zx/hotplug.c @@ -0,0 +1,108 @@ +/* + * Copyright 2014 Linaro Ltd. + * Copyright (C) 2014 ZTE Corporation. + * + * 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 + +static inline void cpu_enter_lowpower(void) +{ + unsigned int v; + + asm volatile( + "mcr p15, 0, %1, c7, c5, 0\n" + " mcr p15, 0, %1, c7, c10, 4\n" + /* + * Turn off coherency + */ + " mrc p15, 0, %0, c1, c0, 1\n" + " bic %0, %0, %3\n" + " mcr p15, 0, %0, c1, c0, 1\n" + " mrc p15, 0, %0, c1, c0, 0\n" + " bic %0, %0, %2\n" + " mcr p15, 0, %0, c1, c0, 0\n" + : "=&r" (v) + : "r" (0), "Ir" (CR_C), "Ir" (0x40) + : "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" + " mrc p15, 0, %0, c1, c0, 1\n" + " orr %0, %0, %2\n" + " mcr p15, 0, %0, c1, c0, 1\n" + : "=&r" (v) + : "Ir" (CR_C), "Ir" (0x40) + : "cc"); +} + +static inline void platform_do_lowpower(unsigned int cpu, int *spurious) +{ + /* + * there is no power-control hardware on this platform, so all + * we can do is put the core into WFI; this is safe as the calling + * code will have already disabled interrupts + */ + for (;;) { + wfi(); + + if (pen_release == cpu_logical_map(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 + * + * Just note it happening - when we're woken, we can report + * its occurrence. + */ + (*spurious)++; + } +} + +/* + * platform-specific code to shutdown a CPU + * + * Called with IRQs disabled + */ +void __ref zx_cpu_die(unsigned int cpu) +{ + int spurious = 0; + + /* + * we're ready for shutdown now, so do it + */ + cpu_enter_lowpower(); + platform_do_lowpower(cpu, &spurious); + + /* + * bring this CPU back into the world of cache + * coherency, and then restore interrupts + */ + cpu_leave_lowpower(); + + if (spurious) + pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious); +} diff --git a/arch/arm/mach-zx/platsmp.c b/arch/arm/mach-zx/platsmp.c index e508a9c..ca157c3 100644 --- a/arch/arm/mach-zx/platsmp.c +++ b/arch/arm/mach-zx/platsmp.c @@ -144,4 +144,7 @@ struct smp_operations zx_smp_ops __initdata = { .smp_prepare_cpus = zx_smp_prepare_cpus, .smp_secondary_init = zx_secondary_init, .smp_boot_secondary = zx_boot_secondary, +#ifdef CONFIG_HOTPLUG_CPU + .cpu_die = zx_cpu_die, +#endif };