From patchwork Sun Oct 18 18:24:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 55212 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id A9FB822FFA for ; Sun, 18 Oct 2015 18:31:35 +0000 (UTC) Received: by wiyb4 with SMTP id b4sf16843493wiy.2 for ; Sun, 18 Oct 2015 11:31:35 -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=25PErAAL5LnzrYcmmnJRLhkgvd6vYcuiNysq7VJrzEM=; b=kz1GBQRYGlB4Q+s9iE1+6K7jPlud/+rOuReIN78xNU9rctam8k2tYXA6P4n999KFyR jpgDea5E8lGeUtX4MEHsdOeGAJ+EEK04UCKIFxNSXy7g2YcUk25q6S8zQKXyBkNzILHI v4jRR+A19aSXKoQwRFeUwhk96Umvl4KsUwg8rSLWtBGOzbHmCnENyL9Jg/zIfvB+oj58 usgUuV0amDeEqkjv9vby8fdghpC7JKgeYPhG8KkHvhePG4r0jhe7l50HenjMd+cLDzbJ mTvP2W/6k/GY2sJxgyBfozpWL5M7sVYcxrNI7Ngw5s7SWWoBIFjwvonCZIyolSiqJm9S 6M8Q== X-Gm-Message-State: ALoCoQmasKX83QeinDl+dm9IGVMwoJ9rniCwaYvF9kn4bQ6Q+kOLTzhj8Xb2rksDFIaNchUOMBG4 X-Received: by 10.112.132.10 with SMTP id oq10mr6010152lbb.1.1445193095000; Sun, 18 Oct 2015 11:31:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.167.140 with SMTP id q134ls526517lfe.23.gmail; Sun, 18 Oct 2015 11:31:34 -0700 (PDT) X-Received: by 10.25.147.209 with SMTP id v200mr8243977lfd.22.1445193094823; Sun, 18 Oct 2015 11:31:34 -0700 (PDT) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id l19si20141711lfg.34.2015.10.18.11.31.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 11:31:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lffz202 with SMTP id z202so15164867lff.3 for ; Sun, 18 Oct 2015 11:31:34 -0700 (PDT) X-Received: by 10.25.207.82 with SMTP id f79mr8456563lfg.73.1445193094675; Sun, 18 Oct 2015 11:31:34 -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 w3csp1079430lbq; Sun, 18 Oct 2015 11:31:33 -0700 (PDT) X-Received: by 10.66.150.3 with SMTP id ue3mr864017pab.46.1445193093577; Sun, 18 Oct 2015 11:31:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id pb3si2526054pbb.65.2015.10.18.11.31.33; Sun, 18 Oct 2015 11:31:33 -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 S1753062AbbJRSbc (ORCPT + 28 others); Sun, 18 Oct 2015 14:31:32 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:35891 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752264AbbJRSZy (ORCPT ); Sun, 18 Oct 2015 14:25:54 -0400 Received: by pacfv9 with SMTP id fv9so70832549pac.3 for ; Sun, 18 Oct 2015 11:25:53 -0700 (PDT) X-Received: by 10.66.190.6 with SMTP id gm6mr29504671pac.27.1445192753574; Sun, 18 Oct 2015 11:25:53 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [184.64.168.246]) by smtp.gmail.com with ESMTPSA id hq1sm20402076pbb.43.2015.10.18.11.25.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Oct 2015 11:25:53 -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, nicolas.pitre@linaro.org 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, mathieu.poirier@linaro.org Subject: [PATCH V2 12/30] coresight: etm3x: adding perf_get/set_config() API Date: Sun, 18 Oct 2015 12:24:29 -0600 Message-Id: <1445192687-24112-13-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1445192687-24112-1-git-send-email-mathieu.poirier@linaro.org> References: <1445192687-24112-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.49 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: , Adding a source operation to build a tracer configuration from a perf_event. That way possibly complex parsing of the information coveyed by the event doesn't have to be carried out every time the configuration is needed. Since event configuration can change between concurrent sessions, the possibility of associating a tracer with a configuration is also provided. As such Perf can assign session configuration to tracers as it sees fit. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm3x.c | 70 +++++++++++++++++++++++++-- include/linux/coresight.h | 5 ++ 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 8a133d761f6a..0994bf0a8334 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "coresight-etm.h" @@ -312,6 +313,40 @@ void etm_config_trace_mode(struct etm_drvdata *drvdata, config->addr_type[1] = ETM_ADDR_TYPE_RANGE; } +#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | ETMCR_TIMESTAMP_EN) + +static int etm_parse_event_config(struct etm_drvdata *drvdata, + struct etm_config *config, + struct perf_event *event) +{ + u32 mode = 0; + u64 event_config = event->attr.config; + + if (event->attr.exclude_kernel) + mode = ETM_MODE_EXCL_KERN; + + if (event->attr.exclude_user) + mode = ETM_MODE_EXCL_USER; + + /* + * By default the tracers are configured to trace the whole address + * range. Narrow the field only if requested by user space. + */ + if (mode) + etm_config_trace_mode(drvdata, config, mode); + + /* + * At this time only cycle accurate and timestamp options are + * available. + */ + if (event_config & ~ETM3X_SUPPORTED_OPTIONS) + return -EINVAL; + + config->ctrl = event_config; + + return 0; +} + static void etm_enable_hw(void *info) { int i; @@ -425,6 +460,31 @@ static int etm_trace_id(struct coresight_device *csdev) return etm_get_trace_id(drvdata); } +static void *perf_etm_get_config(struct coresight_device *csdev, + struct perf_event *event) +{ + struct etm_config *config = NULL; + struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + + config = kzalloc(sizeof(struct etm_config), GFP_KERNEL); + if (!config) + return config; + + etm_set_default(config); + + if (etm_parse_event_config(drvdata, config, event)) + return ERR_PTR(-EINVAL); + + return config; +} + +static void perf_etm_set_config(struct coresight_device *csdev, void *config) +{ + struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + + drvdata->config = config; +} + static int sysfs_etm_enable(struct coresight_device *csdev) { struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); @@ -523,10 +583,12 @@ static void sysfs_etm_disable(struct coresight_device *csdev) } static const struct coresight_ops_source etm_source_ops = { - .cpu_id = etm_cpu_id, - .trace_id = etm_trace_id, - .sysfs_enable = sysfs_etm_enable, - .sysfs_disable = sysfs_etm_disable, + .cpu_id = etm_cpu_id, + .trace_id = etm_trace_id, + .perf_get_config = perf_etm_get_config, + .perf_set_config = perf_etm_set_config, + .sysfs_enable = sysfs_etm_enable, + .sysfs_disable = sysfs_etm_disable, }; static const struct coresight_ops etm_cs_ops = { diff --git a/include/linux/coresight.h b/include/linux/coresight.h index f9210df15f03..32463da877eb 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -209,12 +209,17 @@ struct coresight_ops_link { * is associated to. * @trace_id: returns the value of the component's trace ID as known to the HW. + * @perf_get_config: builds the ETM configuration after event' specifics. + * @perf_set_config: associate a tracer with a configuration.. * @sysfs_enable: enables tracing for a source, from sysFS. * @sysfs_disable: disables tracing for a source, from sysFS. */ struct coresight_ops_source { int (*cpu_id)(struct coresight_device *csdev); int (*trace_id)(struct coresight_device *csdev); + void *(*perf_get_config)(struct coresight_device *csdev, + struct perf_event *event); + void (*perf_set_config)(struct coresight_device *csdev, void *config); int (*sysfs_enable)(struct coresight_device *csdev); void (*sysfs_disable)(struct coresight_device *csdev); };