From patchwork Wed Jul 31 18:38:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2836526 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 58C579F9C8 for ; Wed, 31 Jul 2013 18:38:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17DC820333 for ; Wed, 31 Jul 2013 18:38:57 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BDE420356 for ; Wed, 31 Jul 2013 18:38:55 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V4bIN-0004Q3-Ad; Wed, 31 Jul 2013 18:38:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V4bID-0007Am-S3; Wed, 31 Jul 2013 18:38:37 +0000 Received: from mail-pb0-x22b.google.com ([2607:f8b0:400e:c01::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V4bI6-00079N-7h for linux-arm-kernel@lists.infradead.org; Wed, 31 Jul 2013 18:38:32 +0000 Received: by mail-pb0-f43.google.com with SMTP id md4so1094672pbc.30 for ; Wed, 31 Jul 2013 11:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=JAwedgPchYAlAJStwwe2ZU/7LrFGwcelHTgGE8nNVr8=; b=0Ae5ZMCHLuSdSk+OwX9gZrkxXibkoVNLoHnhX9SgwNRxzimZSYCbaO6RJGN3gw3+MX yL8Y7eBIu7zNCqSv8EjNKLLjQK0mieCGWCKwzs+ofr9AVhGYFjDySL3FBLF+bcB0Bt+h cKkTVnrfKxPvUpS6Wdm7AVxKcnF+m7ALJUbk8+9+ia3IRSZrCHOqNUZm6yWMgYV6ROQK 1SdHO8cpbfdxB46VO8EA6KFwlrtw70i/9bAFZTXmaB2mIPh302+2PYpk08arjvfWW1MP hqk0VyBrrrpBi4eASF37Psi+gG0t2upY0J0y8ZVOpdQ8I9cCT3uAGApnF7UxN7R5r5Uq PyFw== X-Received: by 10.66.161.197 with SMTP id xu5mr10257342pab.58.1375295887568; Wed, 31 Jul 2013 11:38:07 -0700 (PDT) Received: from [127.0.0.1] (ac230065.ppp.asahi-net.or.jp. [183.77.230.65]) by mx.google.com with ESMTPSA id w8sm6009933paj.4.2013.07.31.11.38.05 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 31 Jul 2013 11:38:06 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Thu, 01 Aug 2013 03:38:18 +0900 Message-Id: <20130731183818.31551.51694.sendpatchset@w520> In-Reply-To: <20130731183808.31551.47235.sendpatchset@w520> References: <20130731183808.31551.47235.sendpatchset@w520> Subject: [PATCH 01/02] ARM: shmobile: Introduce per-CPU SMP boot / sleep code X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130731_143830_436273_2C3BB152 X-CRM114-Status: GOOD ( 12.54 ) X-Spam-Score: -2.0 (--) Cc: olof@lixom.net, horms@verge.net.au, Magnus Damm , arnd@arndb.de, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm Add per-CPU SMP boot / sleep code that can be used by all SoCs included in mach-shmobile. The boot code reads out the per-CPU MPIDR id value and matches it with the value stored for any CPU number, and if there is a match and the boot function is set as well then the boot function will be executed. The sleep code simply uses WFI and then jumps back to the boot code to see if anyone has asked to wake up that CPU, if not it will sleep again. Signed-off-by: Magnus Damm --- arch/arm/mach-shmobile/headsmp.S | 50 ++++++++++++++++++++++++++ arch/arm/mach-shmobile/include/mach/common.h | 4 ++ arch/arm/mach-shmobile/platsmp.c | 18 +++++++++ 3 files changed, 72 insertions(+) --- 0001/arch/arm/mach-shmobile/headsmp.S +++ work/arch/arm/mach-shmobile/headsmp.S 2013-07-31 12:23:20.000000000 +0900 @@ -40,3 +40,53 @@ shmobile_boot_fn: .globl shmobile_boot_arg shmobile_boot_arg: 2: .space 4 + +/* + * Per-CPU SMP boot function/argument selection code based on MPIDR + */ + +ENTRY(shmobile_smp_boot) + @ r0 = MPIDR_HWID_BITMASK + mrc p15, 0, r1, c0, c0, 5 @ r1 = MPIDR + and r0, r1, r0 @ r0 = cpu_logical_map() value + mov r1, #0 @ r1 = CPU index + adr r5, 1f @ array of per-cpu mpidr values + adr r6, 2f @ array of per-cpu functions + adr r7, 3f @ array of per-cpu arguments + +shmobile_smp_boot_find_mpidr: + ldr r8, [r5, r1, lsl #2] + cmp r8, r0 + bne shmobile_smp_boot_next + + ldr r9, [r6, r1, lsl #2] + cmp r9, #0 + bne shmobile_smp_boot_found + +shmobile_smp_boot_next: + add r1, r1, #1 + cmp r1, #CONFIG_NR_CPUS + blo shmobile_smp_boot_find_mpidr + + b shmobile_smp_sleep + +shmobile_smp_boot_found: + ldr r0, [r7, r1, lsl #2] + mov pc, r9 +ENDPROC(shmobile_smp_boot) + +ENTRY(shmobile_smp_sleep) + wfi + b shmobile_smp_boot +ENDPROC(shmobile_smp_sleep) + + .globl shmobile_smp_mpidr +shmobile_smp_mpidr: +1: .space CONFIG_NR_CPUS * 4 + .globl shmobile_smp_fn +shmobile_smp_fn: +2: .space CONFIG_NR_CPUS * 4 + .globl shmobile_smp_arg +shmobile_smp_arg: +3: .space CONFIG_NR_CPUS * 4 + --- 0006/arch/arm/mach-shmobile/include/mach/common.h +++ work/arch/arm/mach-shmobile/include/mach/common.h 2013-07-31 12:18:01.000000000 +0900 @@ -10,6 +10,10 @@ extern void shmobile_setup_console(void) extern void shmobile_boot_vector(void); extern unsigned long shmobile_boot_fn; extern unsigned long shmobile_boot_arg; +extern void shmobile_smp_boot(void); +extern void shmobile_smp_sleep(void); +extern void shmobile_smp_hook(unsigned int cpu, unsigned long fn, + unsigned long arg); extern void shmobile_boot_scu(void); extern void shmobile_smp_scu_prepare_cpus(unsigned int max_cpus); extern int shmobile_smp_scu_boot_secondary(unsigned int cpu, --- 0001/arch/arm/mach-shmobile/platsmp.c +++ work/arch/arm/mach-shmobile/platsmp.c 2013-07-31 12:18:01.000000000 +0900 @@ -12,6 +12,9 @@ */ #include #include +#include +#include +#include void __init shmobile_smp_init_cpus(unsigned int ncores) { @@ -26,3 +29,18 @@ void __init shmobile_smp_init_cpus(unsig for (i = 0; i < ncores; i++) set_cpu_possible(i, true); } + +extern unsigned long shmobile_smp_fn[]; +extern unsigned long shmobile_smp_arg[]; +extern unsigned long shmobile_smp_mpidr[]; + +void shmobile_smp_hook(unsigned int cpu, unsigned long fn, unsigned long arg) +{ + shmobile_smp_fn[cpu] = 0; + flush_cache_all(); + + shmobile_smp_mpidr[cpu] = cpu_logical_map(cpu); + shmobile_smp_fn[cpu] = fn; + shmobile_smp_arg[cpu] = arg; + flush_cache_all(); +}