From patchwork Fri Sep 18 16:26:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 53928 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 4CD21218E3 for ; Fri, 18 Sep 2015 16:28:41 +0000 (UTC) Received: by lamf6 with SMTP id f6sf21685234lam.1 for ; Fri, 18 Sep 2015 09:28:40 -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=VMyb3o/cEzTAM6O1XcQ4KF+b5e2u6F+BfvU2xoVQwJg=; b=LRKz0Id6bgY8/nanTb6XHrVT8OVtzdkbLd69JIwUlIBpJcO+xg+NhVT1tvhrBcXGHc sdWraDzo6p232ylSPmxlkF6DCiDPReDsF2YEukOIxyVzkhJFDuNril+rdJ0XesHYOnGG 24445nHRkAzFxkopGEzPK18T4FXip9WzG2Wv8XCf5gpwA7kba2ewFNufhvSMvTr31KlO LPHbomhQfss45Eb/zc5f2qKQI6aMtruPDT70oEvZUux14UlkRSFL4kvzo2mhom7cnW56 Om1CKHWbLGQk9Ey8NBQzJBP+3iGc0PDhVgB4rdwi5+DZLW9tTVIah6IE8zFm/Q/HVhdS dkMw== X-Gm-Message-State: ALoCoQkdFfRBwL55J3cW8yNmQJB9NNkTZep9IPo3tbK7wb/oclt7npBpMUUlZKq/DmiCuq82YTvL X-Received: by 10.194.115.135 with SMTP id jo7mr1060524wjb.7.1442593720224; Fri, 18 Sep 2015 09:28:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.137 with SMTP id dc9ls243603lad.71.gmail; Fri, 18 Sep 2015 09:28:40 -0700 (PDT) X-Received: by 10.152.37.135 with SMTP id y7mr3605830laj.106.1442593720041; Fri, 18 Sep 2015 09:28:40 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id wp2si6595090lbb.136.2015.09.18.09.28.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Sep 2015 09:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lamp12 with SMTP id p12so33031909lam.0 for ; Fri, 18 Sep 2015 09:28:39 -0700 (PDT) X-Received: by 10.152.28.9 with SMTP id x9mr3549139lag.73.1442593719868; Fri, 18 Sep 2015 09:28:39 -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 w3csp402133lbq; Fri, 18 Sep 2015 09:28:38 -0700 (PDT) X-Received: by 10.107.135.169 with SMTP id r41mr16801419ioi.152.1442593718794; Fri, 18 Sep 2015 09:28:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w21si7516273ioi.156.2015.09.18.09.28.38; Fri, 18 Sep 2015 09:28:38 -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 S932127AbbIRQ2f (ORCPT + 30 others); Fri, 18 Sep 2015 12:28:35 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33688 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754799AbbIRQ12 (ORCPT ); Fri, 18 Sep 2015 12:27:28 -0400 Received: by pacex6 with SMTP id ex6so55408806pac.0 for ; Fri, 18 Sep 2015 09:27:27 -0700 (PDT) X-Received: by 10.68.237.161 with SMTP id vd1mr7938642pbc.168.1442593647191; Fri, 18 Sep 2015 09:27:27 -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.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 09:27:26 -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 18/20] coresight: etm3x: pushing down perf configuration to tracer Date: Fri, 18 Sep 2015 10:26:32 -0600 Message-Id: <1442593594-10665-19-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.43 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: , The perf command line tool supports configuration for cycle accurate and timestamps. Configuration for those field is found in the 'config' field of the event configuration attributes. Since the bit fields were organised to match, the only thing that is needed is to make sure no extra fields were set. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm-perf.c | 12 +++++------ drivers/hwtracing/coresight/coresight-etm3x.c | 27 +++++++++++++++++++++++- include/linux/coresight.h | 3 ++- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c index de0198e72603..a662842f3327 100644 --- a/drivers/hwtracing/coresight/coresight-etm-perf.c +++ b/drivers/hwtracing/coresight/coresight-etm-perf.c @@ -122,7 +122,7 @@ out: return ret; } -static int etm_event_config_single_source(int source) +static int etm_event_config_single_source(int source, struct perf_event *event) { struct coresight_device *csdev; @@ -134,10 +134,10 @@ static int etm_event_config_single_source(int source) if (csdev->type != CORESIGHT_DEV_TYPE_SOURCE) return -EINVAL; - return source_ops(csdev)->configure(csdev); + return source_ops(csdev)->configure(csdev, event); } -static int etm_event_config_sources(int source) +static int etm_event_config_sources(int source, struct perf_event *event) { int cpu, ret; @@ -147,13 +147,13 @@ static int etm_event_config_sources(int source) /* source == -1 is for all CPUs. */ if (source != -1) { /* configure one source */ - ret = etm_event_config_single_source(source); + ret = etm_event_config_single_source(source, event); goto out; } /* same process as above, but for all CPUs */ for_each_online_cpu(cpu) { - ret = etm_event_config_single_source(cpu); + ret = etm_event_config_single_source(cpu, event); if (ret) goto reset; } @@ -220,7 +220,7 @@ static int etm_event_init(struct perf_event *event) if (ret) goto out; - ret = etm_event_config_sources(event->cpu); + ret = etm_event_config_sources(event->cpu, event); event->destroy = etm_event_destroy; out: diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index 6a44ea330a4a..077b49714259 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -313,6 +313,25 @@ static void etm_power_down(struct coresight_device *csdev) pm_runtime_put(csdev->dev.parent); } +#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | ETMCR_TIMESTAMP_EN) + +static int etm_parse_event_config(struct etm_drvdata *drvdata, + struct perf_event *event) +{ + u64 config = event->attr.config; + + /* + * At this time only cycle accurate and timestamp options are + * available. As such clear everything else that may have been + * configured and set the ETM control register based on what was + * requested. + */ + config &= ETM3X_SUPPORTED_OPTIONS; + drvdata->ctrl = config; + + return 0; +} + /** * etm_configure_cpu - configure ETM registers * @csdev - the etm that needs to be configure. @@ -334,6 +353,8 @@ static void etm_configure_cpu(void *info) etm_set_prog(drvdata); etmcr = etm_readl(drvdata, ETMCR); + /* Clear setting from a previous run if need be */ + etmcr &= ~ETM3X_SUPPORTED_OPTIONS; etmcr |= drvdata->port_size; etmcr |= ETMCR_ETM_EN; etm_writel(drvdata, drvdata->ctrl | etmcr, ETMCR); @@ -379,10 +400,14 @@ static void etm_configure_cpu(void *info) CS_LOCK(drvdata->base); } -static int etm_configure(struct coresight_device *csdev) +static int etm_configure(struct coresight_device *csdev, + struct perf_event *event) { struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); + if (etm_parse_event_config(drvdata, event)) + return -EINVAL; + return smp_call_function_single(drvdata->cpu, etm_configure_cpu, csdev, 1); } diff --git a/include/linux/coresight.h b/include/linux/coresight.h index da76b2951f10..e1a14c84082f 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -237,7 +237,8 @@ struct coresight_ops_source { int (*cpu_id)(struct coresight_device *csdev); int (*trace_id)(struct coresight_device *csdev); bool (*is_enabled)(struct coresight_device *csdev); - int (*configure)(struct coresight_device *csdev); + int (*configure)(struct coresight_device *csdev, + struct perf_event *event); int (*trace_enable)(struct coresight_device *csdev, bool enable); int (*enable)(struct coresight_device *csdev); void (*disable)(struct coresight_device *csdev);