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: 9235197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 222CA602F0 for ; Mon, 18 Jul 2016 19:59:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 064B1205AD for ; Mon, 18 Jul 2016 19:59:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC383205B0; Mon, 18 Jul 2016 19:59:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 55407205AD for ; Mon, 18 Jul 2016 19:59:24 +0000 (UTC) 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 1bPEfg-0004DH-6U; Mon, 18 Jul 2016 19:57:44 +0000 Received: from mail-io0-x231.google.com ([2607:f8b0:4001:c06::231]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPEaC-00077P-No for linux-arm-kernel@lists.infradead.org; Mon, 18 Jul 2016 19:52:08 +0000 Received: by mail-io0-x231.google.com with SMTP id b62so328131iod.3 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=I62ifQm2oOFbMPtlKKHDQ1cAVxQcCZ/0UuicDhlDMs4P27UJnkEI2LJ+D5/mpUT2PV loJghPZoljsf4ZCbWUSMMHS/otOLL/u0uhNp1+AkDn+On4N0J5l7KfNHkW867fHlyNUt ZPKsD4JPqQTDPd3VrX4pO6VjdBuu0dHvyFnQhrRK2lBAuClTemjM7rbYvcmtzldvoTDP /8QlpRuGWGTmwVblnkP+LIlUC8jQa3KZ10tEA+qfz3x24htRNOWBH2S9mDSAmQYClGLz yLn0nM2+GW0tcZTNIccBQXUFP8H+5EJQoqIhpigok7LoCbau5iK7ZSVjtQ/84QtESgw2 vwDQ== X-Gm-Message-State: ALyK8tIM/EgubXbUxRhX9yp9xRwZmeIyIqX9GqWljHwlfaG/7LRJUXERlLz7/Nr5kWGcpYV2 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160718_125205_069038_04C24D66 X-CRM114-Status: GOOD ( 15.76 ) 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: alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org, Mathieu Poirier MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(+) 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;