From patchwork Tue Sep 6 16:37:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 75565 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp641405qgf; Tue, 6 Sep 2016 09:40:40 -0700 (PDT) X-Received: by 10.98.156.212 with SMTP id u81mr2305332pfk.44.1473180040150; Tue, 06 Sep 2016 09:40:40 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id yd1si12105088pab.148.2016.09.06.09.40.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Sep 2016 09:40:40 -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 1bhJPJ-0000i2-CX; Tue, 06 Sep 2016 16:39:33 +0000 Received: from mail-yb0-x236.google.com ([2607:f8b0:4002:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bhJNg-00087N-64 for linux-arm-kernel@lists.infradead.org; Tue, 06 Sep 2016 16:37:54 +0000 Received: by mail-yb0-x236.google.com with SMTP id d205so66189556ybh.0 for ; Tue, 06 Sep 2016 09:37:31 -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=/Tf4/i3IXJ6Lda4fhaqLTNdtfvPt2hUQuYvsCFFiuq0=; b=bHaW1FTma76jrf1CCGsX86JgVe35HoaxaNALDKlYsQhPT1urLoc9IyJdah2X8mSq/B ZAhEJFVVX567HCdseyxk0RXPk4jII8MtXNJHA/XGLxqhgurfmJIfbPwGMx8pvYTtSy+I g2tseaM4iPPp7+NAK8ABw5YanLI1JrTfp3Yyc= 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=/Tf4/i3IXJ6Lda4fhaqLTNdtfvPt2hUQuYvsCFFiuq0=; b=QpllnKTgFS/6RsrKyMEJ2oDpgWWbiUud2hvTqiqYnpP2NB6HDHK4Sv62SXKIGw0vS8 XIm/HQZzNGTvEuyryD+YpgO0oFU54AtpACzor4ZicUt51MRH/D6sdoGVk3xjzf/0pxR8 viOO61FNi+1k1DEs49+TzvWfMZmUB9fWeyvSWaUZrlHtDMbx3i1YDPDrWCNtdbmw+N1p 4drpKXgDSx6Q9mS8tAKn0AJbJ7cuNzQh7w/GHkYDoGflIbMJ75CqyQRtl9w0F7dzgvw7 IZEqe9ITG13ll0x1CwAANtKlaWvHG4mFSSx97jSAw4j4QLAAG5H/iioCrRd3gYmdwa7I 0GBA== X-Gm-Message-State: AE9vXwMx4SwPOmE7Qt27K0RqY0kWqem9gpv+KpR2bqevINtsmepnz2gLx77gD8zulmlKmh3a X-Received: by 10.36.37.194 with SMTP id g185mr30674377itg.89.1473179850885; Tue, 06 Sep 2016 09:37:30 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id w1sm1772733iod.11.2016.09.06.09.37.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Sep 2016 09:37:30 -0700 (PDT) From: Mathieu Poirier To: acme@kernel.org Subject: [RESEND][PATCH V7 5/5] perf tools: adding sink configuration for cs_etm PMU Date: Tue, 6 Sep 2016 10:37:17 -0600 Message-Id: <1473179837-3293-6-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473179837-3293-1-git-send-email-mathieu.poirier@linaro.org> References: <1473179837-3293-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160906_093752_494389_44970D82 X-CRM114-Status: GOOD ( 13.68 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4002:c09:0:0:0:236 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: acme@infradead.org, peterz@infradead.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, mingo@redhat.com, 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 Acked-by: Jiri Olsa --- tools/perf/arch/arm/util/cs-etm.c | 56 +++++++++++++++++++++++++++++++++++++++ tools/perf/arch/arm/util/cs-etm.h | 3 +++ tools/perf/arch/arm/util/pmu.c | 3 +++ 3 files changed, 62 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..dfea6b635525 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,55 @@ 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); + + 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;