From patchwork Fri Sep 18 16:26:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 53923 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 452CB218E3 for ; Fri, 18 Sep 2015 16:27:40 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf18762633lbc.1 for ; Fri, 18 Sep 2015 09:27:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=g5KlDIudNGx9PdExAXNEyibk/r8dnNHlTyNcsuc7w/A=; b=ggAdDN6mZwaBa4ixGY/XkOh+UKSkbFWBTSqdrGSMdm801AJ/xqtseVfsSG4fFQ3bHN zYnGvzXGcyrmBuzqjlvWgm//c1tUAPdJmKTtBv1oGnSnT6NfXkW9vPbtnPAb6apYEoBv 3oQBMN+vHeXHEC67zF1xOCVTpV0JRazvGgIrnOjkUf9j8wxZ7kqa9iazy4sSpCaOEkwU lllNoyCCpw/ugEMRUbTyXJuPRPrk9am0s+SiuNTaBKds8l2p6k9tOLkiJq1BwieZALLA VHtFtNXDZOwhzmLftbfkgEJlfk4b7tvtdzbDPzXUEsMx30EUFhj4aBxIETjyV80CRfOu DqfA== X-Gm-Message-State: ALoCoQmfAGyci7QLThVRSoL6LBni2PQZcbxSjePnLJUOoBhUNFRzCBIDn0OlWJqeK4A3QJjQMVlA X-Received: by 10.180.10.202 with SMTP id k10mr4364078wib.2.1442593659237; Fri, 18 Sep 2015 09:27:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.196 with SMTP id y4ls225311lad.34.gmail; Fri, 18 Sep 2015 09:27:39 -0700 (PDT) X-Received: by 10.152.2.162 with SMTP id 2mr1722180lav.102.1442593659046; Fri, 18 Sep 2015 09:27:39 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id ao2si6720635lac.165.2015.09.18.09.27.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 09:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by lanb10 with SMTP id b10so33543071lan.3 for ; Fri, 18 Sep 2015 09:27:39 -0700 (PDT) X-Received: by 10.112.64.72 with SMTP id m8mr3466992lbs.41.1442593658875; Fri, 18 Sep 2015 09:27:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp401644lbq; Fri, 18 Sep 2015 09:27:37 -0700 (PDT) X-Received: by 10.107.132.21 with SMTP id g21mr16522898iod.175.1442593657849; Fri, 18 Sep 2015 09:27:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si7520404igx.40.2015.09.18.09.27.37; Fri, 18 Sep 2015 09:27:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754791AbbIRQ1Z (ORCPT + 30 others); Fri, 18 Sep 2015 12:27:25 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:36133 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754732AbbIRQ1U (ORCPT ); Fri, 18 Sep 2015 12:27:20 -0400 Received: by padhk3 with SMTP id hk3so55052349pad.3 for ; Fri, 18 Sep 2015 09:27:20 -0700 (PDT) X-Received: by 10.66.144.135 with SMTP id sm7mr8218410pab.106.1442593639970; Fri, 18 Sep 2015 09:27:19 -0700 (PDT) Received: from t430.cg.shawcable.net ([184.64.168.246]) by smtp.gmail.com with ESMTPSA id la4sm9847027pbc.76.2015.09.18.09.27.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 09:27:19 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org, a.p.zijlstra@chello.nl, alexander.shishkin@linux.intel.com, acme@kernel.org, mingo@redhat.com, corbet@lwn.net Cc: adrian.hunter@intel.com, zhang.chunyan@linaro.org, mike.leach@arm.com, tor@ti.com, al.grant@arm.com, pawel.moll@arm.com, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 13/20] coresight: etm-perf: new PMU driver for ETM tracers Date: Fri, 18 Sep 2015 10:26:27 -0600 Message-Id: <1442593594-10665-14-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442593594-10665-1-git-send-email-mathieu.poirier@linaro.org> References: <1442593594-10665-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mathieu.poirier@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Perf is a well known and used tool for performance monitoring and much more. A such it is an ideal condaditate for integration with coresight based HW tracing. This patch introduce a minimal PMU that represent a coresight tracer to the Perf core. Signed-off-by: Mathieu Poirier --- MAINTAINERS | 1 + drivers/hwtracing/coresight/Makefile | 2 +- drivers/hwtracing/coresight/coresight-etm-perf.c | 65 ++++++++++++++++++++++++ include/linux/coresight-pmu.h | 18 +++++++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 drivers/hwtracing/coresight/coresight-etm-perf.c create mode 100644 include/linux/coresight-pmu.h diff --git a/MAINTAINERS b/MAINTAINERS index 7ba7ab749c85..b462a90a256d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -989,6 +989,7 @@ ARM/CORESIGHT FRAMEWORK AND DRIVERS M: Mathieu Poirier L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) S: Maintained +F: include/linux/coresight* F: drivers/hwtracing/coresight/* F: Documentation/trace/coresight.txt F: Documentation/devicetree/bindings/arm/coresight.txt diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile index 99f8e5f6256e..2ab2627060a4 100644 --- a/drivers/hwtracing/coresight/Makefile +++ b/drivers/hwtracing/coresight/Makefile @@ -1,7 +1,7 @@ # # Makefile for CoreSight drivers. # -obj-$(CONFIG_CORESIGHT) += coresight.o +obj-$(CONFIG_CORESIGHT) += coresight.o coresight-etm-perf.o obj-$(CONFIG_OF) += of_coresight.o obj-$(CONFIG_CORESIGHT_LINK_AND_SINK_TMC) += coresight-tmc.o obj-$(CONFIG_CORESIGHT_SINK_TPIU) += coresight-tpiu.o diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c new file mode 100644 index 000000000000..759b8d69b4e6 --- /dev/null +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -0,0 +1,65 @@ +/* + * Copyright(C) 2015 Linaro Limited. All rights reserved. + * Author: Mathieu Poirier + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "coresight-priv.h" + +static struct pmu etm_pmu; + +/* ETMCR is 'config' */ +PMU_FORMAT_ATTR(cycacc, "config:12"); +PMU_FORMAT_ATTR(timestamp, "config:28"); + +static struct attribute *etm_config_formats_attr[] = { + &format_attr_cycacc.attr, + &format_attr_timestamp.attr, + NULL, +}; + +static struct attribute_group etm_pmu_format_group = { + .name = "format", + .attrs = etm_config_formats_attr, +}; + +static const struct attribute_group *etm_pmu_attr_groups[] = { + &etm_pmu_format_group, + NULL, +}; + +static void etm_event_read(struct perf_event *event) {} + +static int __init etm_perf_init(void) +{ + etm_pmu.capabilities = PERF_PMU_CAP_EXCLUSIVE; + + etm_pmu.attr_groups = etm_pmu_attr_groups; + etm_pmu.task_ctx_nr = perf_sw_context; + etm_pmu.read = etm_event_read; + + return perf_pmu_register(&etm_pmu, CORESIGHT_ETM_PMU_NAME, -1); +} +module_init(etm_perf_init); diff --git a/include/linux/coresight-pmu.h b/include/linux/coresight-pmu.h new file mode 100644 index 000000000000..261361060f0b --- /dev/null +++ b/include/linux/coresight-pmu.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2012, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _LINUX_CORESIGHT_PMU_H +#define _LINUX_CORESIGHT_PMU_H + +#define CORESIGHT_ETM_PMU_NAME "cs_etm" + +#endif