From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH 18/18] arm/arm64: Add smp selftest Date: Sun, 1 Feb 2015 19:34:46 +0100 Message-ID: <1422815686-24591-19-git-send-email-drjones@redhat.com> References: <1422815686-24591-1-git-send-email-drjones@redhat.com> Cc: christoffer.dall@linaro.org, pbonzini@redhat.com To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46424 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753769AbbBASfT (ORCPT ); Sun, 1 Feb 2015 13:35:19 -0500 In-Reply-To: <1422815686-24591-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Andrew Jones --- arm/selftest.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ arm/unittests.cfg | 11 ++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/arm/selftest.c b/arm/selftest.c index d77495747b08a..fc9ec609d875e 100644 --- a/arm/selftest.c +++ b/arm/selftest.c @@ -7,11 +7,16 @@ */ #include #include +#include #include #include #include #include #include +#include +#include +#include +#include static void assert_args(int num_args, int needed_args) { @@ -297,6 +302,45 @@ static void check_vectors(void *arg __unused) exit(report_summary()); } +static bool psci_check(void) +{ + const struct fdt_property *method; + int node, len, ver; + + node = fdt_node_offset_by_compatible(dt_fdt(), -1, "arm,psci-0.2"); + if (node < 0) { + printf("PSCI v0.2 compatibility required\n"); + return false; + } + + method = fdt_get_property(dt_fdt(), node, "method", &len); + if (method == NULL) { + printf("bad psci device tree node\n"); + return false; + } + + if (len < 4 || strcmp(method->data, "hvc") != 0) { + printf("psci method must be hvc\n"); + return false; + } + + ver = psci_invoke(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); + printf("PSCI version %d.%d\n", PSCI_VERSION_MAJOR(ver), + PSCI_VERSION_MINOR(ver)); + + return true; +} + +static cpumask_t smp_reported; +static void cpu_report(void) +{ + int cpu = smp_processor_id(); + + report("CPU%d online", true, cpu); + cpumask_set_cpu(cpu, &smp_reported); + halt(); +} + int main(int argc, char **argv) { report_prefix_push("selftest"); @@ -316,6 +360,22 @@ int main(int argc, char **argv) void *sp = memalign(THREAD_SIZE, THREAD_SIZE); start_usr(check_vectors, NULL, (unsigned long)sp + THREAD_START_SP); + + } else if (strcmp(argv[0], "smp") == 0) { + + int cpu; + + report("PSCI version", psci_check()); + + for_each_present_cpu(cpu) { + if (cpu == 0) + continue; + smp_boot_secondary(cpu, cpu_report); + } + + cpumask_set_cpu(0, &smp_reported); + while (!cpumask_full(&smp_reported)) + cpu_relax(); } return report_summary(); diff --git a/arm/unittests.cfg b/arm/unittests.cfg index efcca6bf24af6..ee655b2678a4e 100644 --- a/arm/unittests.cfg +++ b/arm/unittests.cfg @@ -13,8 +13,8 @@ # [selftest::setup] file = selftest.flat -smp = 1 -extra_params = -m 256 -append 'setup smp=1 mem=256' +smp = 2 +extra_params = -m 256 -append 'setup smp=2 mem=256' groups = selftest # Test vector setup and exception handling (kernel mode). @@ -28,3 +28,10 @@ groups = selftest file = selftest.flat extra_params = -append 'vectors-user' groups = selftest + +# Test SMP support +[selftest::smp] +file = selftest.flat +smp = $(getconf _NPROCESSORS_CONF) +extra_params = -append 'smp' +groups = selftest -- 1.9.3