From patchwork Mon May 16 07:57:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 67829 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1408552qge; Mon, 16 May 2016 01:03:28 -0700 (PDT) X-Received: by 10.55.178.198 with SMTP id b189mr26982179qkf.98.1463385808596; Mon, 16 May 2016 01:03:28 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 65si17229005qkx.158.2016.05.16.01.03.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 16 May 2016 01:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:43006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2DUu-0004n8-7O for patch@linaro.org; Mon, 16 May 2016 04:03:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52733) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2DPh-0005VW-At for qemu-devel@nongnu.org; Mon, 16 May 2016 03:58:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2DPY-0000LZ-WE for qemu-devel@nongnu.org; Mon, 16 May 2016 03:58:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55438) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2DPW-0000Kw-8M; Mon, 16 May 2016 03:57:54 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72FA58553D; Mon, 16 May 2016 07:57:53 +0000 (UTC) Received: from hawk.localdomain.com (ovpn-204-50.brq.redhat.com [10.40.204.50]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4G7vPBO018488; Mon, 16 May 2016 03:57:51 -0400 From: Andrew Jones To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org, qemu-arm@nongnu.org, andre.przywara@arm.com, peter.maydell@linaro.org, alex.bennee@linaro.org Date: Mon, 16 May 2016 09:57:24 +0200 Message-Id: <1463385444-12916-11-git-send-email-drjones@redhat.com> In-Reply-To: <1463385444-12916-1-git-send-email-drjones@redhat.com> References: <1463385444-12916-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 16 May 2016 07:57:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [kvm-unit-tests PATCH 10/10] arm/arm64: gic: don't just use zero X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marc.zyngier@arm.com, christoffer.dall@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Allow user to select who sends ipis and with which irq, rather than just always sending irq=0 from cpu0. Signed-off-by: Andrew Jones --- arm/gic.c | 53 ++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) -- 2.4.11 diff --git a/arm/gic.c b/arm/gic.c index ec8e0a26ff724..b76b946f2c106 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -11,6 +11,7 @@ * This work is licensed under the terms of the GNU LGPL, version 2. */ #include +#include #include #include #include @@ -31,6 +32,7 @@ struct gic { static struct gic *gic; static int gic_version; +static int sender, irq; static int acked[NR_CPUS]; static cpumask_t ready; @@ -92,19 +94,19 @@ static void ipi_handler(struct pt_regs *regs __unused) static void gicv2_ipi_send_self(void) { - writel(2 << 24, gicv2_dist_base() + GIC_DIST_SOFTINT); + writel(2 << 24 | irq, gicv2_dist_base() + GIC_DIST_SOFTINT); } static void gicv2_ipi_send_tlist(cpumask_t *mask) { u8 tlist = (u8)cpumask_bits(mask)[0]; - writel(tlist << 16, gicv2_dist_base() + GIC_DIST_SOFTINT); + writel(tlist << 16 | irq, gicv2_dist_base() + GIC_DIST_SOFTINT); } static void gicv2_ipi_send_broadcast(void) { - writel(1 << 24, gicv2_dist_base() + GIC_DIST_SOFTINT); + writel(1 << 24 | irq, gicv2_dist_base() + GIC_DIST_SOFTINT); } #define ICC_SGI1R_AFFINITY_1_SHIFT 16 @@ -147,7 +149,7 @@ static void gicv3_ipi_send_tlist(cpumask_t *mask) sgi1r = (MPIDR_TO_SGI_AFFINITY(cluster_id, 3) | MPIDR_TO_SGI_AFFINITY(cluster_id, 2) | - /* irq << 24 | */ + irq << 24 | MPIDR_TO_SGI_AFFINITY(cluster_id, 1) | tlist); @@ -184,7 +186,7 @@ static void ipi_test_self(void) memset(acked, 0, sizeof(acked)); smp_wmb(); cpumask_clear(&mask); - cpumask_set_cpu(0, &mask); + cpumask_set_cpu(smp_processor_id(), &mask); gic->ipi.send_self(); check_acked(&mask); report_prefix_pop(); @@ -199,7 +201,7 @@ static void ipi_test_smp(void) memset(acked, 0, sizeof(acked)); smp_wmb(); cpumask_copy(&mask, &cpu_present_mask); - for (i = 0; i < nr_cpus; i += 2) + for (i = smp_processor_id() & 1; i < nr_cpus; i += 2) cpumask_clear_cpu(i, &mask); gic->ipi.send_tlist(&mask); check_acked(&mask); @@ -209,7 +211,7 @@ static void ipi_test_smp(void) memset(acked, 0, sizeof(acked)); smp_wmb(); cpumask_copy(&mask, &cpu_present_mask); - cpumask_clear_cpu(0, &mask); + cpumask_clear_cpu(smp_processor_id(), &mask); gic->ipi.send_broadcast(); check_acked(&mask); report_prefix_pop(); @@ -226,6 +228,15 @@ static void ipi_enable(void) local_irq_enable(); } +static void ipi_send(void) +{ + ipi_enable(); + wait_on_ready(); + ipi_test_self(); + ipi_test_smp(); + exit(report_summary()); +} + static void ipi_recv(void) { ipi_enable(); @@ -284,6 +295,19 @@ int main(int argc, char **argv) ipi_test_self(); } else if (!strcmp(argv[0], "ipi")) { + int off, i = 0; + long val; + + while (--argc) { + off = parse_keyval(argv[++i], &val); + if (off == -1) + continue; + argv[i][off] = '\0'; + if (strcmp(argv[i], "sender") == 0) + sender = val; + else if (strcmp(argv[i], "irq") == 0) + irq = val; + } report_prefix_push(argv[0]); nr_cpu_check(2); @@ -292,11 +316,18 @@ int main(int argc, char **argv) for_each_present_cpu(cpu) { if (cpu == 0) continue; - smp_boot_secondary(cpu, ipi_recv); + if (cpu == sender) + smp_boot_secondary(cpu, ipi_send); + else + smp_boot_secondary(cpu, ipi_recv); + } + if (sender == 0) { + wait_on_ready(); + ipi_test_self(); + ipi_test_smp(); + } else { + ipi_recv(); } - wait_on_ready(); - ipi_test_self(); - ipi_test_smp(); report_prefix_pop(); } else {