From patchwork Tue Jul 29 12:33:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fuzzey X-Patchwork-Id: 4640291 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 5D1EB9F36A for ; Tue, 29 Jul 2014 12:35:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BAC7A200FF for ; Tue, 29 Jul 2014 12:35:36 +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 E29BC200C1 for ; Tue, 29 Jul 2014 12:35:35 +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 1XC6az-0006Vb-3D; Tue, 29 Jul 2014 12:33:33 +0000 Received: from mta1.parkeon.com ([91.121.43.66]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XC6an-0006Bp-O4 for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 12:33:25 +0000 Received: from ip71.parkeon.com ([213.152.31.71] helo=mta2.parkeon.com) by mta1.parkeon.com with esmtp (Exim 4.76) (envelope-from ) id 1XC6aT-0002rP-A1; Tue, 29 Jul 2014 14:33:01 +0200 Received: from mail.besancon.parkeon.com ([10.32.16.23]) by mta2.parkeon.com with esmtp (Exim 4.77) (envelope-from ) id 1XC6aR-0004kV-G2; Tue, 29 Jul 2014 14:32:59 +0200 Received: from [10.32.51.161] (port=47430 helo=[127.0.0.1]) by mail.besancon.parkeon.com with esmtp (Exim 4.71) (envelope-from ) id 1XC6aT-0002AQ-6I; Tue, 29 Jul 2014 14:33:01 +0200 Subject: [PATCH 2/4] ARM: perf: Add platform specific start/stop callbacks. To: Shawn Guao , Will Deacon , linux-arm-kernel@lists.infradead.org From: Martin Fuzzey Date: Tue, 29 Jul 2014 14:33:01 +0200 Message-ID: <20140729123301.13347.39881.stgit@localhost> In-Reply-To: <20140729123256.13347.79778.stgit@localhost> References: <20140729123256.13347.79778.stgit@localhost> User-Agent: StGit/0.16 MIME-Version: 1.0 X-Virus-Scanned: by ClamAV at mta2.parkeon.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140729_053321_976047_659447FF X-CRM114-Status: GOOD ( 12.37 ) X-Spam-Score: -0.7 (/) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,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 Some platforms (such as i.MX53) require SOC specific registers to be manipulated to make the PMU work. Add callback hooks to support this. Signed-off-by: Martin Fuzzey --- arch/arm/include/asm/pmu.h | 9 +++++++++ arch/arm/kernel/perf_event.c | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/pmu.h b/arch/arm/include/asm/pmu.h index 0bd181f..0f361c9 100644 --- a/arch/arm/include/asm/pmu.h +++ b/arch/arm/include/asm/pmu.h @@ -15,6 +15,8 @@ #include #include +struct arm_pmu; + /* * struct arm_pmu_platdata - ARM PMU platform data * @@ -32,12 +34,18 @@ * succession this handler will only be called following the * final call to pm_runtime_put() that actually disables the * hardware. + * @start: an optional handler which will be called before starting + * the PMU to do any platform specific setup + * @stop: an optional handler which be called after stopping the PMU + * to do any platform specific teardown */ struct arm_pmu_platdata { irqreturn_t (*handle_irq)(int irq, void *dev, irq_handler_t pmu_handler); int (*runtime_resume)(struct device *dev); int (*runtime_suspend)(struct device *dev); + void (*start)(struct arm_pmu *arm_pmu); + void (*stop)(struct arm_pmu *arm_pmu); }; #ifdef CONFIG_HW_PERF_EVENTS @@ -67,6 +75,7 @@ struct pmu_hw_events { */ unsigned int activated_flags; #define ARM_PMU_ACTIVATED_SECURE_DEBUG (1 << 0) + #define ARM_PMU_ACTIVATED_PLATFORM (1 << 1) }; struct arm_pmu { diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c index 4238bcb..d0d9a25 100644 --- a/arch/arm/kernel/perf_event.c +++ b/arch/arm/kernel/perf_event.c @@ -469,16 +469,27 @@ static void armpmu_enable(struct pmu *pmu) { struct arm_pmu *armpmu = to_arm_pmu(pmu); struct pmu_hw_events *hw_events = armpmu->get_hw_events(); + struct arm_pmu_platdata *plat = + dev_get_platdata(&armpmu->plat_device->dev); + int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); - if (enabled) + if (enabled) { + if (plat && plat->start) + plat->start(armpmu); armpmu->start(armpmu); + } } static void armpmu_disable(struct pmu *pmu) { struct arm_pmu *armpmu = to_arm_pmu(pmu); + struct arm_pmu_platdata *plat = + dev_get_platdata(&armpmu->plat_device->dev); + armpmu->stop(armpmu); + if (plat && plat->stop) + plat->stop(armpmu); } #ifdef CONFIG_PM_RUNTIME