From patchwork Fri Jan 17 12:25:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hanjun Guo X-Patchwork-Id: 3504101 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 24DDB9F2E9 for ; Fri, 17 Jan 2014 12:46:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B1C420114 for ; Fri, 17 Jan 2014 12:46:18 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A68FD2010F for ; Fri, 17 Jan 2014 12:46:16 +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 1W48oL-0007RQ-S6; Fri, 17 Jan 2014 12:46:10 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W48oJ-0007kx-DH; Fri, 17 Jan 2014 12:46:07 +0000 Received: from mail-pd0-f172.google.com ([209.85.192.172]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W48oG-0007jw-Bj for linux-arm-kernel@lists.infradead.org; Fri, 17 Jan 2014 12:46:05 +0000 Received: by mail-pd0-f172.google.com with SMTP id z10so3958755pdj.31 for ; Fri, 17 Jan 2014 04:45:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FR/CRIxay7QCdrnWt3zKXjEGaeIe0TT5NwV2nuZqcVo=; b=J/wNR2xk3lBARMLLM+x+QOVBw7xBgIEDw2hnDbw9xy7yKsgCZwVhRmnK6UShdMbAQ1 dNNL8szc8PXFgDTzr9bw/tELPpdsOC0xnqgniDfRwTBqgcQuCeLBlQPJrdv5ks5Uqqej Gz/qmYY6Ge0ktPSOQtScRMxgDyAuUKPXJhUIrfXOb+MNo0/Q+MBWcbYdfGY90qaV2Wi6 x3aGvFUSPMIrLyhQ9zHWpcw9DmCgcQ13rFdT4DA1qeQmT0RWqVIAbCSWarNWW/i6sLje 3yf8ma1XfOZwb85LOBJ96s3CcngI0CqYQlMBRTWgQISaXQGgZH5eDQa0f6/nM5B0PGa1 lbcQ== X-Gm-Message-State: ALoCoQmnoKeGb6sX0DkCOKFO7SmiG0WbDClsKcXjrw4xLJY3qR+I14UYpH/UCGtZCYbfOIors2KU X-Received: by 10.66.255.39 with SMTP id an7mr1834123pad.7.1389962742668; Fri, 17 Jan 2014 04:45:42 -0800 (PST) Received: from localhost ([218.17.215.175]) by mx.google.com with ESMTPSA id xv2sm22497742pbb.39.2014.01.17.04.44.50 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 17 Jan 2014 04:45:41 -0800 (PST) From: Hanjun Guo To: "Rafael J. Wysocki" , Catalin Marinas , Will Deacon , Russell King - ARM Linux Subject: [PATCH 11/20] ARM64 / ACPI: Get the enable method for SMP initialization Date: Fri, 17 Jan 2014 20:25:05 +0800 Message-Id: <1389961514-13562-12-git-send-email-hanjun.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1389961514-13562-1-git-send-email-hanjun.guo@linaro.org> References: <1389961514-13562-1-git-send-email-hanjun.guo@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140117_074604_556092_6D3CBD04 X-CRM114-Status: GOOD ( 22.83 ) X-Spam-Score: -1.1 (-) Cc: Mark Rutland , Matthew Garrett , linaro-kernel@lists.linaro.org, Arnd Bergmann , Rob Herring , Linus Walleij , Olof Johansson , linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org, linux-acpi@vger.kernel.org, Hanjun Guo , patches@linaro.org, Grant Likely , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Charles.Garcia-Tobin@arm.com 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=-3.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, 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 ACPI has no flag to indicate different enable methods for SMP initialization, but it indicates that spin-table is supported at now because of the Parked Protocol shows that there is parked address in GIC structure. In order to boot the system with ACPI if DT is not available, we set the default enable method as spin-table since PSCI is not available in ACPI spec at now. Signed-off-by: Hanjun Guo --- arch/arm64/include/asm/acpi.h | 8 ++++++++ arch/arm64/include/asm/cpu_ops.h | 1 + arch/arm64/include/asm/smp.h | 2 +- arch/arm64/kernel/cpu_ops.c | 2 +- arch/arm64/kernel/smp.c | 42 ++++++++++++++++++++++++++++++++++++-- drivers/acpi/plat/arm-core.c | 26 +++++++++++++++++++++++ 6 files changed, 77 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 7edd39e..097394c 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -87,11 +87,19 @@ extern int (*acpi_suspend_lowlevel)(void); extern int arm_cpu_to_apicid[NR_CPUS]; #define cpu_physical_id(cpu) arm_cpu_to_apicid[cpu] +extern const char *acpi_get_enable_method(int cpu); + #else /* !CONFIG_ACPI */ #define acpi_disabled 1 /* ACPI sometimes enabled on ARM */ #define acpi_noirq 1 /* ACPI sometimes enabled on ARM */ #define acpi_pci_disabled 1 /* ACPI PCI sometimes enabled on ARM */ #define acpi_strict 1 /* no ACPI spec workarounds on ARM */ + +static inline const char *acpi_get_enable_method(int cpu) +{ + return NULL; +} + #endif #endif /*_ASM_ARM64_ACPI_H*/ diff --git a/arch/arm64/include/asm/cpu_ops.h b/arch/arm64/include/asm/cpu_ops.h index c4cdb5e..08c8f07 100644 --- a/arch/arm64/include/asm/cpu_ops.h +++ b/arch/arm64/include/asm/cpu_ops.h @@ -53,6 +53,7 @@ struct cpu_operations { }; extern const struct cpu_operations *cpu_ops[NR_CPUS]; +extern const struct cpu_operations * __init cpu_get_ops(const char *name); extern int __init cpu_read_ops(struct device_node *dn, int cpu); extern void __init cpu_read_bootcpu_ops(void); diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h index a498f2c..a5cea56 100644 --- a/arch/arm64/include/asm/smp.h +++ b/arch/arm64/include/asm/smp.h @@ -39,7 +39,7 @@ extern void show_ipi_list(struct seq_file *p, int prec); extern void handle_IPI(int ipinr, struct pt_regs *regs); /* - * Setup the set of possible CPUs (via set_cpu_possible) + * Platform specific SMP operations */ extern void smp_init_cpus(void); diff --git a/arch/arm64/kernel/cpu_ops.c b/arch/arm64/kernel/cpu_ops.c index d62d12f..531f2cc 100644 --- a/arch/arm64/kernel/cpu_ops.c +++ b/arch/arm64/kernel/cpu_ops.c @@ -35,7 +35,7 @@ static const struct cpu_operations *supported_cpu_ops[] __initconst = { NULL, }; -static const struct cpu_operations * __init cpu_get_ops(const char *name) +const struct cpu_operations * __init cpu_get_ops(const char *name) { const struct cpu_operations **ops = supported_cpu_ops; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index a0c2ca6..7719d46 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -48,6 +48,7 @@ #include #include #include +#include /* * as from 2.5, kernels no longer have an init_tasks structure @@ -280,7 +281,7 @@ static void (*smp_cross_call)(const struct cpumask *, unsigned int); * cpu logical map array containing MPIDR values related to logical * cpus. Assumes that cpu_logical_map(0) has already been initialized. */ -void __init smp_init_cpus(void) +static int __init of_smp_init_cpus(void) { struct device_node *dn = NULL; unsigned int i, cpu = 1; @@ -364,6 +365,10 @@ next: cpu++; } + /* No device tree or no CPU node in DT */ + if (cpu == 1 && !bootcpu_valid) + return -ENODEV; + /* sanity check */ if (cpu > NR_CPUS) pr_warning("no. of cores (%d) greater than configured maximum of %d - clipping\n", @@ -371,7 +376,7 @@ next: if (!bootcpu_valid) { pr_err("DT missing boot CPU MPIDR, not enabling secondaries\n"); - return; + return -EINVAL; } /* @@ -381,6 +386,39 @@ next: for (i = 0; i < NR_CPUS; i++) if (cpu_logical_map(i) != INVALID_HWID) set_cpu_possible(i, true); + + return 0; +} + +/* + * In ACPI mode, the cpu possible map was enumerated before SMP + * initialization when MADT table was parsed, so we can get the + * possible map here to initialize CPUs. + */ +static void __init acpi_smp_init_cpus(void) +{ + int cpu; + const char *enable_method; + + for_each_possible_cpu(cpu) { + enable_method = acpi_get_enable_method(cpu); + if (!enable_method) + continue; + + cpu_ops[cpu] = cpu_get_ops(enable_method); + if (!cpu_ops[cpu]) + continue; + + cpu_ops[cpu]->cpu_init(NULL, cpu); + } +} + +void __init smp_init_cpus(void) +{ + if (!of_smp_init_cpus()) + return; + + acpi_smp_init_cpus(); } void __init smp_prepare_cpus(unsigned int max_cpus) diff --git a/drivers/acpi/plat/arm-core.c b/drivers/acpi/plat/arm-core.c index 1d9b789..2704633 100644 --- a/drivers/acpi/plat/arm-core.c +++ b/drivers/acpi/plat/arm-core.c @@ -367,6 +367,32 @@ static void __init acpi_process_madt(void) } /* + * To see PCSI is enabled or not. + * + * PSCI is not available for ACPI 5.0, return FALSE for now. + * + * FIXME: should we introduce early_param("psci", func) for test purpose? + */ +static bool acpi_psci_smp_available(int cpu) +{ + return FALSE; +} + +static const char *enable_method[] = { + "psci", + "spin-table", + NULL +}; + +const char *acpi_get_enable_method(int cpu) +{ + if (acpi_psci_smp_available(cpu)) + return enable_method[0]; + else + return enable_method[1]; +} + +/* * acpi_boot_table_init() and acpi_boot_init() * called from setup_arch(), always. * 1. checksums all tables