From patchwork Tue May 26 16:23:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 6483891 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DE9C59F1C1 for ; Tue, 26 May 2015 16:27:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EB52C20625 for ; Tue, 26 May 2015 16:27:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 1A1BE2057F for ; Tue, 26 May 2015 16:27:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YxHf4-0001q2-2L; Tue, 26 May 2015 16:25:02 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YxHec-0001bf-5e for linux-arm-kernel@lists.infradead.org; Tue, 26 May 2015 16:24:37 +0000 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 360A028; Tue, 26 May 2015 09:24:07 -0700 (PDT) Received: from leverpostej.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CF3153F21B; Tue, 26 May 2015 09:24:13 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/7] arm: perf: share arm_pmu_device_probe Date: Tue, 26 May 2015 17:23:35 +0100 Message-Id: <1432657420-887-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1432657420-887-1-git-send-email-mark.rutland@arm.com> References: <1432657420-887-1-git-send-email-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150526_092434_338054_1910A104 X-CRM114-Status: GOOD ( 11.64 ) X-Spam-Score: -5.0 (-----) Cc: mark.rutland@arm.com, linux@arm.linux.org.uk, a.p.zijlstra@chello.nl, gregkh@linuxfoundation.org, linus.walleij@linaro.org, will.deacon@arm.com, acme@kernel.org, mingo@redhat.com, paulus@samba.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Enable the probe function to be shared with other drivers, which will inject the appropriate of_device_id and pmu_probe_info tables. Signed-off-by: Mark Rutland Cc: Will Deacon --- arch/arm/include/asm/pmu.h | 4 ++++ arch/arm/kernel/perf_event_cpu.c | 20 ++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h index 62464a4..3fc87df 100644 --- a/arch/arm/include/asm/pmu.h +++ b/arch/arm/include/asm/pmu.h @@ -145,6 +145,10 @@ struct pmu_probe_info { #define XSCALE_PMU_PROBE(_version, _fn) \ PMU_PROBE(ARM_CPU_IMP_INTEL << 24 | _version, ARM_PMU_XSCALE_MASK, _fn) +int arm_pmu_device_probe(struct platform_device *pdev, + const struct of_device_id *of_table, + const struct pmu_probe_info *probe_table); + #endif /* CONFIG_HW_PERF_EVENTS */ #endif /* __ARM_PMU_H__ */ diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c index 14a5a0a..797b569 100644 --- a/arch/arm/kernel/perf_event_cpu.c +++ b/arch/arm/kernel/perf_event_cpu.c @@ -286,16 +286,16 @@ static const struct pmu_probe_info pmu_probe_table[] = { /* * CPU PMU identification and probing. */ -static int probe_current_pmu(struct arm_pmu *pmu) +static int probe_current_pmu(struct arm_pmu *pmu, + const struct pmu_probe_info *info) { int cpu = get_cpu(); unsigned int cpuid = read_cpuid_id(); int ret = -ENODEV; - const struct pmu_probe_info *info; pr_info("probing PMU on CPU %d\n", cpu); - for (info = pmu_probe_table; info->init != NULL; info++) { + for (; info->init != NULL; info++) { if ((cpuid & info->mask) != info->cpuid) continue; ret = info->init(pmu); @@ -352,7 +352,9 @@ static int of_pmu_irq_cfg(struct arm_pmu *pmu) return 0; } -static int cpu_pmu_device_probe(struct platform_device *pdev) +int arm_pmu_device_probe(struct platform_device *pdev, + const struct of_device_id *of_table, + const struct pmu_probe_info *probe_table) { const struct of_device_id *of_id; const int (*init_fn)(struct arm_pmu *); @@ -371,14 +373,14 @@ static int cpu_pmu_device_probe(struct platform_device *pdev) pmu->plat_device = pdev; - if (node && (of_id = of_match_node(cpu_pmu_of_device_ids, pdev->dev.of_node))) { + if (node && (of_id = of_match_node(of_table, pdev->dev.of_node))) { init_fn = of_id->data; ret = of_pmu_irq_cfg(pmu); if (!ret) ret = init_fn(pmu); } else { - ret = probe_current_pmu(pmu); + ret = probe_current_pmu(pmu, probe_table); cpumask_setall(&pmu->supported_cpus); } @@ -405,6 +407,12 @@ out_free: return ret; } +static int cpu_pmu_device_probe(struct platform_device *pdev) +{ + return arm_pmu_device_probe(pdev, cpu_pmu_of_device_ids, + pmu_probe_table); +} + static struct platform_driver cpu_pmu_driver = { .driver = { .name = "arm-pmu",