From patchwork Thu Aug 25 21:19:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 74749 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1049568qga; Thu, 25 Aug 2016 14:27:29 -0700 (PDT) X-Received: by 10.66.232.37 with SMTP id tl5mr20070235pac.13.1472160444004; Thu, 25 Aug 2016 14:27:24 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h63si17333629pfd.38.2016.08.25.14.27.23; Thu, 25 Aug 2016 14:27:23 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758946AbcHYV1J (ORCPT + 27 others); Thu, 25 Aug 2016 17:27:09 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:36477 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758847AbcHYV05 (ORCPT ); Thu, 25 Aug 2016 17:26:57 -0400 Received: by mail-it0-f45.google.com with SMTP id e63so297402979ith.1 for ; Thu, 25 Aug 2016 14:26:52 -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=rmeR7DpsA018dwX1s7y/fBG64Ja74UF44WD3Uq5JC8g=; b=XP30tGeTpXiEVKEArjNScHiY+7ynesPUzSLnRIUK8pEZc81yXsm/zBL2RQ++iq18L3 smK/fpHHMBy7b8KMN8mQ4PeNFm4T51DZCOBXMqzuz0Fm2LiTSODOH5TrHzDMGS5aTdun eYuq27RHbM1VYytPQwnq/T1O8yz8oSkRuVh60= 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=rmeR7DpsA018dwX1s7y/fBG64Ja74UF44WD3Uq5JC8g=; b=cbHRnCMOo/bk+Bk8KsxPITQAEk9QVDgLdJHxxzBvGFTVnVew8F/7oe/uvdOdNu5LGG Bmm7UGx4Y77onyj2DazzzGWv8HS80oCt6Z8MvBwl4nQjbTgx63I0PR+BBR2QClSLwfaL 47zOVsmaF0v400I6kd6hYnwVT4j7hLa4P+2x2PuQ4enSdacF7C661XcXPEZtVTjbTaAv STLPUrCV20hhbp+KDvAl5sum4z119Bsxko9IA0h0FkMGDNZHOyXB98HY3URXjY8CicRr m5ZXbnT3AXv5zHNBF1EpZAvg3q238VIojVO4m1gc3y121vYCEAC0y4LnRvBLNDqrZPdz YuSw== X-Gm-Message-State: AE9vXwNKYQJUK/oy1FVqf/smNqZE0CMtyVJbpD0JxySKXcSXaLQtGB+fw/wsGzecns9JtnQi X-Received: by 10.36.41.205 with SMTP id p196mr8019909itp.76.1472160017916; Thu, 25 Aug 2016 14:20:17 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id o5sm14506120ith.20.2016.08.25.14.20.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Aug 2016 14:20:17 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 26/28] coresight: etm4x: configuring include/exclude function Date: Thu, 25 Aug 2016 15:19:16 -0600 Message-Id: <1472159958-5981-27-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472159958-5981-1-git-send-email-mathieu.poirier@linaro.org> References: <1472159958-5981-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The include/exclude function of a tracer is applicable to address range and start/stop filters. To avoid duplication and reuse code moving the include/exclude configuration to a function of its own. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm4x.c | 35 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index aca624010b9f..1044ed609d81 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -205,13 +205,6 @@ static int etm4_parse_event_config(struct etmv4_drvdata *drvdata, /* Always start from the default config */ etm4_set_default(config); - /* - * By default the tracers are configured to trace the whole address - * range. Narrow the field only if requested by user space. - */ - if (config->mode) - etm4_config_trace_mode(config); - /* Go from generic option to ETMv4 specifics */ if (attr->config & BIT(ETM_OPT_CYCACC)) config->cfg |= ETMv4_MODE_CYCACC; @@ -581,14 +574,28 @@ static void etm4_set_default_config(struct etmv4_config *config) config->vinst_ctrl |= BIT(0); } -static void etm4_set_comparator_filter(struct etmv4_config *config, - u64 start, u64 stop, int comparator) +static u64 etm4_get_access_type(struct etmv4_config *config) { u64 access_type = 0; - /* EXLEVEL_NS, bits[12:15], always stay away from hypervisor mode. */ + /* + * EXLEVEL_NS, bits[15:12] + * The Exception levels are: + * Bit[12] Exception level 0 - Application + * Bit[13] Exception level 1 - OS + * Bit[14] Exception level 2 - Hypervisor + * Bit[15] Never implemented + * + * Always stay away from hypervisor mode. + */ access_type = ETM_EXLEVEL_NS_HYP; + if (config->mode & ETM_MODE_EXCL_KERN) + access_type |= ETM_EXLEVEL_NS_OS; + + if (config->mode & ETM_MODE_EXCL_USER) + access_type |= ETM_EXLEVEL_NS_APP; + /* * EXLEVEL_S, bits[11:8], don't trace anything happening * in secure state. @@ -597,6 +604,14 @@ static void etm4_set_comparator_filter(struct etmv4_config *config, ETM_EXLEVEL_S_OS | ETM_EXLEVEL_S_HYP); + return access_type; +} + +static void etm4_set_comparator_filter(struct etmv4_config *config, + u64 start, u64 stop, int comparator) +{ + u64 access_type = etm4_get_access_type(config); + /* First half of default address comparator */ config->addr_val[comparator] = start; config->addr_acc[comparator] = access_type;