From patchwork Tue Feb 6 14:26:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 10203159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1050A60327 for ; Tue, 6 Feb 2018 14:27:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01C4F28849 for ; Tue, 6 Feb 2018 14:27:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E68D4289B1; Tue, 6 Feb 2018 14:27:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C3CA628849 for ; Tue, 6 Feb 2018 14:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=w7kXw3v1Amw3NIMaZIdxgKGi09tgk9Lb8AoyKxhHU2A=; b=uJTdvrtu3ilkQFaPkxZi7nnmHu 8TM65XL8OFzQpNu/uIVz6WYyfgTDH0A5oQxke8XcWobX+f4Yjm6l7QCWDhlpVcxpUUGiGlGF2493V grsr8+Ye8vU/6KYHID8bjEjMXhBrvhKECG8BhdnSHnlCLVWzjd4RiUj3OBp4T0JLDw+eY03uYyzin gtAywfiJiKq1+JRlYv0eviq4if5ZOyPdK456+T3Dkrv9v5HGaym8eI1/BeprjqAkyFOO79PkAmkNy ziJ8Kc72zBfYSrF+cWZhmY2iirDpwResjHtUBehjHaL5k9snuZFl7Fa/HDX6KBgqN5oYGSNXjUn5x 9jburrZw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ej4DV-0005le-Q5; Tue, 06 Feb 2018 14:27:25 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ej4Cv-0005Cu-KW for linux-arm-kernel@lists.infradead.org; Tue, 06 Feb 2018 14:26:55 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 8F841273145 From: Sebastian Reichel To: Shawn Guo , Sascha Hauer , Fabio Estevam , Will Deacon , Mark Rutland Subject: [PATCHv2 1/3] drivers/perf: arm_pmu: Add platform hardware setup hooks. Date: Tue, 6 Feb 2018 15:26:27 +0100 Message-Id: <20180206142629.534-2-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180206142629.534-1-sebastian.reichel@collabora.co.uk> References: <20180206142629.534-1-sebastian.reichel@collabora.co.uk> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, Ian Ray , Rob Herring , Nandor Han , Sebastian Reichel , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Allow platform specific code to be called when enabling or disabling the hardware. Signed-off-by: Martin Fuzzey Signed-off-by: Peter Senna Tschudin [rebased to v4.12] Signed-off-by: Nandor Han [Simplify and cleanup for upstreaming] Signed-off-by: Sebastian Reichel --- drivers/perf/arm_pmu.c | 12 ++++++++++++ include/linux/perf/arm_pmu.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 7bc5eee96b31..9c282914ee67 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -452,8 +452,10 @@ static int armpmu_event_init(struct perf_event *event) static void armpmu_enable(struct pmu *pmu) { struct arm_pmu *armpmu = to_arm_pmu(pmu); + struct arm_pmu_platdata *platdata = armpmu_get_platdata(armpmu); struct pmu_hw_events *hw_events = this_cpu_ptr(armpmu->hw_events); int enabled = bitmap_weight(hw_events->used_mask, armpmu->num_events); + int err; /* For task-bound events we may be called on other CPUs */ if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) @@ -461,17 +463,27 @@ static void armpmu_enable(struct pmu *pmu) if (enabled) armpmu->start(armpmu); + + if (platdata && platdata->reserve_hardware) { + err = platdata->reserve_hardware(armpmu); + if (err) + dev_warn(&armpmu->plat_device->dev, "Could not reserve PMU hardware!\n"); + } } static void armpmu_disable(struct pmu *pmu) { struct arm_pmu *armpmu = to_arm_pmu(pmu); + struct arm_pmu_platdata *platdata = armpmu_get_platdata(armpmu); /* For task-bound events we may be called on other CPUs */ if (!cpumask_test_cpu(smp_processor_id(), &armpmu->supported_cpus)) return; armpmu->stop(armpmu); + + if (platdata && platdata->release_hardware) + platdata->release_hardware(armpmu); } /* diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index af0f44effd44..942ae9bfe971 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -17,6 +17,8 @@ #include #include +struct arm_pmu; + /* * struct arm_pmu_platdata - ARM PMU platform data * @@ -31,6 +33,8 @@ struct arm_pmu_platdata { irqreturn_t (*handle_irq)(int irq, void *dev, irq_handler_t pmu_handler); + int (*reserve_hardware)(struct arm_pmu *arm_pmu); + void (*release_hardware)(struct arm_pmu *arm_pmu); unsigned long irq_flags; }; @@ -112,6 +116,7 @@ struct arm_pmu { int (*map_event)(struct perf_event *event); int num_events; u64 max_period; + bool reserved_hardware; bool secure_access; /* 32-bit ARM only */ #define ARMV8_PMUV3_MAX_COMMON_EVENTS 0x40 DECLARE_BITMAP(pmceid_bitmap, ARMV8_PMUV3_MAX_COMMON_EVENTS);