From patchwork Thu Jan 18 17:43:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 10173755 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 6A3FF603B5 for ; Thu, 18 Jan 2018 17:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 556182846F for ; Thu, 18 Jan 2018 17:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4984E28478; Thu, 18 Jan 2018 17:45:02 +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 DF4022846F for ; Thu, 18 Jan 2018 17:45:01 +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=RitpNIXyhfkzwFzLYpqAcN5TI6exYKNl8nV0nnayCrE=; b=csuhJ8RaQ2ZkdycELWKwbgq6/m IWir66y8qkcXqowpnY54RXvQdkBPfNSUMqk0Xdai43AW+YjaunhbtbLxfuOrYoVc4lOv8FECt18vZ IDpvQcUWPQKOHjSU7DXmHidgq7hzWY8vhWKvR3AnGkaVODmvg17D9KM1huZZdBih6yCcKSfNNtgkb VACYCOTt/aqpo8Lt6JS+M5SNqDNq39OMhsQZIulKoCwc9mcCq029pCAfEoLk8q6/gd4xanFWtkZy1 NNTEfldiFTRJf1Fn14xRYkrjysBbtrRfNxg1auymUsWOBqT8GNmW9zJfXhkChTtXjTzlgChSMoXis /bep0Eag==; 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 1ecEFF-0007oF-LB; Thu, 18 Jan 2018 17:44:57 +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 1ecEEb-0006Z5-0W for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2018 17:44:19 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id D2647273AAA From: Sebastian Reichel To: Shawn Guo , Sascha Hauer , Fabio Estevam , Will Deacon , Mark Rutland Subject: [PATCH 1/3] drivers/perf: arm_pmu: Add platform hardware setup hooks. Date: Thu, 18 Jan 2018 18:43:43 +0100 Message-Id: <20180118174345.26620-2-sebastian.reichel@collabora.co.uk> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180118174345.26620-1-sebastian.reichel@collabora.co.uk> References: <20180118174345.26620-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 | 13 +++++++++++++ include/linux/perf/arm_pmu.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index 7bc5eee96b31..165006b9a00d 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,28 @@ 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);