From patchwork Thu Aug 25 20:20:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 74737 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1025201qga; Thu, 25 Aug 2016 13:23:09 -0700 (PDT) X-Received: by 10.66.164.227 with SMTP id yt3mr19789244pab.117.1472156589695; Thu, 25 Aug 2016 13:23:09 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id a8si17002896pay.278.2016.08.25.13.23.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Aug 2016 13:23:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bd1A8-0004Dy-3D; Thu, 25 Aug 2016 20:22:08 +0000 Received: from mail-it0-x234.google.com ([2607:f8b0:4001:c0b::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bd19F-0003sv-CO for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2016 20:21:17 +0000 Received: by mail-it0-x234.google.com with SMTP id x131so293784202ite.0 for ; Thu, 25 Aug 2016 13:20:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0i00WnlU91DIqxXivliSusNZoB8vmmBDG2q9YF0t4fU=; b=gahlFh8tHnMqaJTvXgxIqDQuVT03IHpacn7GMhDmvWPTZrQzp5ooQjMk3112hor9Dk SlN0IIrurqc9rBksA2FxEaabLiw4lf5c+41Xv9c3bA73xfT+WNO+m43Oe+Z38ginl9Hl VZ9zf8nXee/Y7Q6wnyL9sBJxEbYS+4WnnDzZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0i00WnlU91DIqxXivliSusNZoB8vmmBDG2q9YF0t4fU=; b=TJcp76PGS37yF582ESDEPARZlAzncbI83mN+GbdngpwUp6KQwLQupEZsqj8nmnJhWt 4R2FfENCeXLpkmRTgXHMBL1nQfqSQBWqt37V40pBkCMFoI2gEukkq04HieqHURG2q61/ c8TScM+th26rgixWrXY9TSo/PA99I7j0MLIF6F7/jqueocFLrkUZzJyhD2iqAggjDB0h t960HN5J98olUq3rciVTqGlMNT63sEstbUp1E5QsQjqE4u7V6HlBNrEr3kdMaLbqymCr WEJgnuDyEUnm3yeH1YY9DSkVqoA6bFlC5bTjX3BHVCLCzFj5um93VMLUvp5ml239KyhX aVOQ== X-Gm-Message-State: AEkooutkVuC79PWtmeOfo59/eLGakoDV1D5zn5d2Sxl/YQrrFWNRhBUEqdXlFQTqjeEsk+Cs X-Received: by 10.107.15.229 with SMTP id 98mr12195544iop.123.1472156454325; Thu, 25 Aug 2016 13:20:54 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id t35sm6187910ioi.7.2016.08.25.13.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Aug 2016 13:20:54 -0700 (PDT) From: Mathieu Poirier To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org Subject: [PATCH V6 5/5] perf tools: adding sink configuration for cs_etm PMU Date: Thu, 25 Aug 2016 14:20:45 -0600 Message-Id: <1472156445-24283-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472156445-24283-1-git-send-email-mathieu.poirier@linaro.org> References: <1472156445-24283-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160825_132113_652808_0891E167 X-CRM114-Status: GOOD ( 14.08 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:4001:c0b:0:0:0:234 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Using the PMU::set_drv_config() callback to enable the CoreSight sink that will be used for the trace session. Signed-off-by: Mathieu Poirier --- tools/perf/arch/arm/util/cs-etm.c | 58 +++++++++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/cs-etm.h | 3 ++ tools/perf/arch/arm/util/pmu.c | 3 ++ 3 files changed, 64 insertions(+) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c index 829c479614f1..47d584da5819 100644 --- a/tools/perf/arch/arm/util/cs-etm.c +++ b/tools/perf/arch/arm/util/cs-etm.c @@ -27,12 +27,16 @@ #include "../../util/auxtrace.h" #include "../../util/cpumap.h" #include "../../util/evlist.h" +#include "../../util/evsel.h" #include "../../util/pmu.h" #include "../../util/thread_map.h" #include "../../util/cs-etm.h" #include +#define ENABLE_SINK_MAX 128 +#define CS_BUS_DEVICE_PATH "/bus/coresight/devices/" + struct cs_etm_recording { struct auxtrace_record itr; struct perf_pmu *cs_etm_pmu; @@ -557,3 +561,57 @@ struct auxtrace_record *cs_etm_record_init(int *err) out: return NULL; } + +static FILE *cs_device__open_file(const char *name) +{ + struct stat st; + char path[PATH_MAX]; + const char *sysfs; + + sysfs = sysfs__mountpoint(); + if (!sysfs) + return NULL; + + snprintf(path, PATH_MAX, + "%s" CS_BUS_DEVICE_PATH "%s", sysfs, name); + + printf("path: %s\n", path); + + if (stat(path, &st) < 0) + return NULL; + + return fopen(path, "w"); + +} + +static __attribute__((format(printf, 2, 3))) +int cs_device__print_file(const char *name, const char *fmt, ...) +{ + va_list args; + FILE *file; + int ret = -EINVAL; + + va_start(args, fmt); + file = cs_device__open_file(name); + if (file) { + ret = vfprintf(file, fmt, args); + fclose(file); + } + va_end(args); + return ret; +} + +int cs_etm_set_drv_config(struct perf_evsel_config_term *term) +{ + int ret; + char enable_sink[ENABLE_SINK_MAX]; + + snprintf(enable_sink, ENABLE_SINK_MAX, "%s/%s", + term->val.drv_cfg, "enable_sink"); + + ret = cs_device__print_file(enable_sink, "%d", 1); + if (ret < 0) + return ret; + + return 0; +} diff --git a/tools/perf/arch/arm/util/cs-etm.h b/tools/perf/arch/arm/util/cs-etm.h index 909f486d02d1..5256741be549 100644 --- a/tools/perf/arch/arm/util/cs-etm.h +++ b/tools/perf/arch/arm/util/cs-etm.h @@ -18,6 +18,9 @@ #ifndef INCLUDE__PERF_CS_ETM_H__ #define INCLUDE__PERF_CS_ETM_H__ +#include "../../util/evsel.h" + struct auxtrace_record *cs_etm_record_init(int *err); +int cs_etm_set_drv_config(struct perf_evsel_config_term *term); #endif diff --git a/tools/perf/arch/arm/util/pmu.c b/tools/perf/arch/arm/util/pmu.c index af9fb666b44f..c11f8a13d14d 100644 --- a/tools/perf/arch/arm/util/pmu.c +++ b/tools/perf/arch/arm/util/pmu.c @@ -19,8 +19,10 @@ #include #include +#include "cs-etm.h" #include "../../util/pmu.h" + struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) { @@ -28,6 +30,7 @@ struct perf_event_attr if (!strcmp(pmu->name, CORESIGHT_ETM_PMU_NAME)) { /* add ETM default config here */ pmu->selectable = true; + pmu->set_drv_config = cs_etm_set_drv_config; } #endif return NULL;