From patchwork Tue Jan 10 17:17:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 90740 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp722511qgi; Tue, 10 Jan 2017 09:18:09 -0800 (PST) X-Received: by 10.84.232.197 with SMTP id x5mr4821169plm.111.1484068689837; Tue, 10 Jan 2017 09:18:09 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si2769815plk.74.2017.01.10.09.18.09; Tue, 10 Jan 2017 09:18:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940648AbdAJRR4 (ORCPT + 7 others); Tue, 10 Jan 2017 12:17:56 -0500 Received: from foss.arm.com ([217.140.101.70]:59230 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760037AbdAJRRz (ORCPT ); Tue, 10 Jan 2017 12:17:55 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 079D61575; Tue, 10 Jan 2017 09:17:55 -0800 (PST) Received: from beelzebub.ast.arm.com (unknown [10.118.96.220]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8EF6C3F3D6; Tue, 10 Jan 2017 09:17:54 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: linux-acpi@vger.kernel.org, will.deacon@arm.com, mark.rutland@arm.com, punit.agrawal@arm.com, steve.capper@arm.com, msalter@redhat.com, mlangsdorf@redhat.com, linux@armlinux.org.uk Subject: [PATCH v12 3/7] arm64: pmu: Cache PMU interrupt numbers from MADT parse Date: Tue, 10 Jan 2017 11:17:48 -0600 Message-Id: <1484068672-15852-4-git-send-email-jeremy.linton@arm.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1484068672-15852-1-git-send-email-jeremy.linton@arm.com> References: <1484068672-15852-1-git-send-email-jeremy.linton@arm.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Mark Salter In the case of ACPI, the PMU IRQ information is contained in the MADT table. Also, since the PMU does not exist as a device in the ACPI DSDT table, it is necessary to create a platform device so that the appropriate driver probing is triggered. Since the platform device creation needs to happen after the CPU's have been started, and the MADT parsing needs to happen before, we save off the interrupt numbers discovered during the parsing. Signed-off-by: Mark Salter Signed-off-by: Jeremy Linton --- arch/arm64/kernel/smp.c | 5 +++++ drivers/perf/Kconfig | 4 ++++ drivers/perf/Makefile | 1 + drivers/perf/arm_pmu_acpi.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/perf/arm_pmu.h | 7 +++++++ 5 files changed, 57 insertions(+) create mode 100644 drivers/perf/arm_pmu_acpi.c -- 2.5.5 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 8ea244c..cbaab44 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -552,6 +553,7 @@ acpi_verify_and_map_madt(struct acpi_madt_generic_interrupt *processor) } bootcpu_valid = true; early_map_cpu_to_node(0, acpi_numa_get_nid(0, hwid)); + arm_pmu_parse_acpi(0, processor); return; } @@ -572,6 +574,9 @@ acpi_verify_and_map_madt(struct acpi_madt_generic_interrupt *processor) */ acpi_set_mailbox_entry(cpu_count, processor); + /* get PMU irq info */ + arm_pmu_parse_acpi(cpu_count, processor); + early_map_cpu_to_node(cpu_count, acpi_numa_get_nid(cpu_count, hwid)); cpu_count++; diff --git a/drivers/perf/Kconfig b/drivers/perf/Kconfig index 4d5c5f9..697df05 100644 --- a/drivers/perf/Kconfig +++ b/drivers/perf/Kconfig @@ -19,4 +19,8 @@ config XGENE_PMU help Say y if you want to use APM X-Gene SoC performance monitors. +config ARM_PMU_ACPI + def_bool y + depends on ARM_PMU && ACPI + endmenu diff --git a/drivers/perf/Makefile b/drivers/perf/Makefile index b116e98..d1d7762 100644 --- a/drivers/perf/Makefile +++ b/drivers/perf/Makefile @@ -1,2 +1,3 @@ obj-$(CONFIG_ARM_PMU) += arm_pmu.o obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o +obj-$(CONFIG_ARM_PMU_ACPI) += arm_pmu_acpi.o diff --git a/drivers/perf/arm_pmu_acpi.c b/drivers/perf/arm_pmu_acpi.c new file mode 100644 index 0000000..2008001 --- /dev/null +++ b/drivers/perf/arm_pmu_acpi.c @@ -0,0 +1,40 @@ +/* + * ARM ACPI PMU support + * + * Copyright (C) 2015 Red Hat Inc. + * Author: Mark Salter + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +struct pmu_irq { + int gsi; + int trigger; + bool used; +}; + +static struct pmu_irq pmu_irqs[NR_CPUS]; + +/* + * Called from acpi_verify_and_map_madt()'s MADT parsing during boot. + * This routine saves off the GSI's and their trigger state for use when we are + * ready to build the PMU platform device. + */ +void __init arm_pmu_parse_acpi(int cpu, struct acpi_madt_generic_interrupt *gic) +{ + pmu_irqs[cpu].gsi = gic->performance_interrupt; + if (gic->flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) + pmu_irqs[cpu].trigger = ACPI_EDGE_SENSITIVE; + else + pmu_irqs[cpu].trigger = ACPI_LEVEL_SENSITIVE; +} diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index 8462da2..df1ba55 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -164,4 +164,11 @@ int arm_pmu_device_probe(struct platform_device *pdev, #endif /* CONFIG_ARM_PMU */ +#ifdef CONFIG_ARM_PMU_ACPI +struct acpi_madt_generic_interrupt; +void arm_pmu_parse_acpi(int cpu, struct acpi_madt_generic_interrupt *gic); +#else +#define arm_pmu_parse_acpi(a, b) do { } while (0) +#endif /* CONFIG_ARM_PMU_ACPI */ + #endif /* __ARM_PMU_H__ */