From patchwork Mon Jul 18 19:51:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 72250 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp291028qga; Mon, 18 Jul 2016 12:52:37 -0700 (PDT) X-Received: by 10.66.47.133 with SMTP id d5mr58487429pan.48.1468871557729; Mon, 18 Jul 2016 12:52:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si5037758pfj.191.2016.07.18.12.52.37; Mon, 18 Jul 2016 12:52:37 -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 S1752460AbcGRTvx (ORCPT + 29 others); Mon, 18 Jul 2016 15:51:53 -0400 Received: from mail-io0-f172.google.com ([209.85.223.172]:35113 "EHLO mail-io0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752336AbcGRTvo (ORCPT ); Mon, 18 Jul 2016 15:51:44 -0400 Received: by mail-io0-f172.google.com with SMTP id m101so366137ioi.2 for ; Mon, 18 Jul 2016 12:51:44 -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=HFj3dKW1+DiTp5RM+qZ1PsgrR4ys8UNTNzA5WOpcHZg=; b=d+gdx4GW5A/4Pi55P0b/P752G222UQrj58eebQNcrYHcKxsrE8lwQrDkKckN+uagv5 v0/qsH3Bspy4lI+Q9V6R38GXniaDwZ1Ft0hwE6kJjsjb7z8gKs41Us4p4luQQN7Wz/Qb fy9eKl/A10Y4UPGj2qvCtUb8/U96k+bnov2aI= 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=HFj3dKW1+DiTp5RM+qZ1PsgrR4ys8UNTNzA5WOpcHZg=; b=RROuHgT2QaMUzHCSLdVcowcnGSjTbw/Mm/PHQxE/G7xB2Gr78EJaTWiE8Iw9oc93ly /loNEINiRF4Kd+ydTd19x8YPFufNtL8/5oU8hAlHQMZlUKPSH+wT+oNRu8aSh4OsLpQb vQVGVT86Gdrgcws4matfVUxv0OjYyVnK50Cg/O/b2dylZbIOPJ0fnTETRngwqeegaxbN rog6TY89K2rFQpvxrRLAbCxtFEuw9WMiCwGsEmGdFLGo8bZXiPXIPXRT5WlviFKDnJLT G4d0M5HFrSmqeUtjkpXA/UBzEL+dLph6bl1H4CMN1roa1XsPqP+Z4FH4fLAuOlAEKMol 9t1g== X-Gm-Message-State: ALyK8tIvaWX9sOu907qAYwcqg2BMrj5hj6AR+6qlow7OblIGTFLX88i2Pb9jRAYhmfEBZn0Y X-Received: by 10.107.201.213 with SMTP id z204mr41159076iof.109.1468871503887; Mon, 18 Jul 2016 12:51:43 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id r128sm5270676ita.6.2016.07.18.12.51.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jul 2016 12:51:43 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, Mathieu Poirier Subject: [PATCH 09/10] coresight: etm4x: adding configurable start/stop filtering Date: Mon, 18 Jul 2016 13:51:30 -0600 Message-Id: <1468871491-10997-10-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468871491-10997-1-git-send-email-mathieu.poirier@linaro.org> References: <1468871491-10997-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 With this patch we add start/stop filtering as specified on the perf cmd line. When the IP matches the start address trace generation gets triggered. The stop condition is achieved when the IP matches the stop address. Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-etm4x.c | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-etm4x.c b/drivers/hwtracing/coresight/coresight-etm4x.c index b807333ce6a1..58fd37021db4 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x.c +++ b/drivers/hwtracing/coresight/coresight-etm4x.c @@ -338,12 +338,25 @@ static void etm4_disable_hw(void *info) static int etm4_disable_perf(struct coresight_device *csdev, struct perf_event *event) { + u32 control; + struct etm_filters *filters = event->hw.addr_filters; struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) return -EINVAL; etm4_disable_hw(drvdata); + + /* + * Check if the start/stop logic was active when the unit was stopped. + * That way we can re-enable the start/stop logic when the process is + * scheduled again. Configuration of the start/stop logic happens in + * function etm4_set_event_filters(). + */ + control = readl_relaxed(drvdata->base + TRCVICTLR); + /* TRCVICTLR::SSSTATUS, bit[9] */ + filters->ssstatus = (control & BIT(9)); + return 0; } @@ -660,6 +673,27 @@ static void etm4_set_comparator_filter(struct etmv4_config *config, config->viiectlr |= BIT(comparator / 2); } +static void etm4_set_start_stop_filter(struct etmv4_config *config, + u64 address, int comparator, + enum etm_addr_type type) +{ + int shift; + u64 access_type = etm4_get_access_type(config); + + /* Configure the comparator */ + config->addr_val[comparator] = address; + config->addr_acc[comparator] = access_type; + config->addr_type[comparator] = type; + + /* + * Configure ViewInst Start-Stop control register. + * Addresses configured to start tracing go from bit 0 to n-1, + * while those configured to stop tracing from 16 to 16 + n-1. + */ + shift = (type == ETM_ADDR_TYPE_START ? 0 : 16); + config->vissctlr |= BIT(shift + comparator); +} + static void etm4_set_default_filter(struct etmv4_config *config) { u64 start, stop; @@ -724,6 +758,14 @@ static int etm4_get_next_comparator(struct etmv4_drvdata *drvdata, u32 type) /* Address range comparators go in pairs */ index += 2; break; + case ETM_ADDR_TYPE_START: + case ETM_ADDR_TYPE_STOP: + if (config->addr_type[index] == ETM_ADDR_TYPE_NONE) + return index; + + /* Start/stop address can have odd indexes */ + index += 1; + break; default: return -EINVAL; } @@ -737,6 +779,7 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata, struct perf_event *event) { int i, comparator, ret = 0; + u64 address; struct etmv4_config *config = &drvdata->config; struct etm_filters *filters = event->hw.addr_filters; @@ -779,6 +822,34 @@ static int etm4_set_event_filters(struct etmv4_drvdata *drvdata, /* No start-stop filtering for ViewInst */ config->vissctlr = 0x0; break; + case ETM_ADDR_TYPE_START: + case ETM_ADDR_TYPE_STOP: + /* Get the right start or stop address */ + address = (type == ETM_ADDR_TYPE_START ? + filter->start_addr : + filter->stop_addr); + + /* Configure comparator */ + etm4_set_start_stop_filter(config, address, + comparator, type); + + /* + * If filters::ssstatus == 1, trace acquisition was + * started but the process was yanked away before the + * the stop address was hit. As such the start/stop + * logic needs to be re-started so that tracing can + * resume where it left. + * + * The start/stop logic status when a process is + * scheduled out is checked in function + * etm4_disable_perf(). + */ + if (filters->ssstatus) + config->vinst_ctrl |= BIT(9); + + /* No include/exclude filtering for ViewInst */ + config->viiectlr = 0x0; + break; default: ret = -EINVAL; goto out;