From patchwork Tue Jul 11 11:25:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Leach X-Patchwork-Id: 9834541 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 A147960363 for ; Tue, 11 Jul 2017 11:26:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9223D1FEBA for ; Tue, 11 Jul 2017 11:26:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86C1A251F4; Tue, 11 Jul 2017 11:26:51 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0AB081FEBA for ; Tue, 11 Jul 2017 11:26:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8hUIhIAbROG8VvLcqp9hFyX+FF7uSJgDEHCD3qB+AyU=; b=j+2TCOHd4B1/af51XS/FDwWbIC gzETWJTY9Ouc4ELtecvGjYYUoYlTf9hrSAJGhpugSAI5FcMSBn0Q0y+7uGIZQrftW0BzUiLj1ixgk Lmj7w9hfMfxsolPYmBc/M2UqzgD5cf1nj0nQk+3DbZQor0TIu7scj+ZwuOlpWlHV/epL8xHHNU2ia RlT3/258gE/260NRReLqdvhegw3n2QqBx28kfFPEhTnmmHz7dEPF/SzXjp0LUsRa7vF6HV5k3XrnJ lt2gCJsQUvEW/qeac0LTgKVoIHuYNrnvvOaJMrBGl+dCcUnHY8rdqRWknD/tosfOE6uJRsHfMSdfE HjAS3ILQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dUtJZ-0005WR-Tw; Tue, 11 Jul 2017 11:26:49 +0000 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dUtJ8-0004iZ-J8 for linux-arm-kernel@lists.infradead.org; Tue, 11 Jul 2017 11:26:25 +0000 Received: by mail-wr0-x236.google.com with SMTP id 77so179025759wrb.1 for ; Tue, 11 Jul 2017 04:26:02 -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=FKaCu0rsMtM1yeRzYje+NTTpYV92oJ9EQfHpbtmYWfA=; b=PClkl6aMmGcZAld+eYRS846CZqLhSoJ+PgWhdQTs37l/Gte+ImE0kaJ0C7+Elihbyf 6TxcyBW9qj0gBD958/QIQIbzTpovVPTUKRsu5zdM0U9MvUcRO9EbFeJRMq5qZkoSut7H UdlUl2Uqyr5SWYwlb6K6syPo1TexZGySndhNA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FKaCu0rsMtM1yeRzYje+NTTpYV92oJ9EQfHpbtmYWfA=; b=W0dSWYw0AkxNQYS4dbMiib1s3zxdrXqbtXgEfaTGdR8GQ1PCOsdKvSoQq6Be2nxQME VSV0gbXlQ6pdutYzMtJkDJ6GHuum2/4KDgYCDKspZjqF2qq5Molx66Uby728/cetdGrN HgytPCLtm/Od50EC30TaJdCxYRHT9FzcaXneY1jbpszqEUk2aOVGIdJQZ/VDwvgLOLwU o6ZPPKD/VdEFtE5+hGPUb47U4MwlUvxS9ioCOiH9tpE6xpNTRHfXpcrLPWptKtI26Be/ ENVONbHzkrjoHUNSkFbl5D2JtyV6WpD5wThFbixcnzdMLfVSCRflaNUY0OmCaYP9mkfV Ngaw== X-Gm-Message-State: AIVw110gF8KanHTO0DCL7IOocLDUMRgQzpT4hM5V4C+0+1jDGr1PjgA9 jBKEHiqLH1XupLY1 X-Received: by 10.28.207.66 with SMTP id f63mr11181997wmg.73.1499772360791; Tue, 11 Jul 2017 04:26:00 -0700 (PDT) Received: from linaro.org (cpc116592-blbn11-2-0-cust240.10-1.cable.virginm.net. [80.5.18.241]) by smtp.gmail.com with ESMTPSA id d1sm16217847wra.43.2017.07.11.04.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Jul 2017 04:25:59 -0700 (PDT) From: Mike Leach To: mathieu.poirier@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/3] coresight: ptm: Adds trace return stack option programming for PTM. Date: Tue, 11 Jul 2017 12:25:50 +0100 Message-Id: <1499772351-2210-3-git-send-email-mike.leach@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499772351-2210-1-git-send-email-mike.leach@linaro.org> References: <1499772351-2210-1-git-send-email-mike.leach@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170711_042622_789217_B74508E3 X-CRM114-Status: GOOD ( 15.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Leach 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 Adds handling to program the return stack option into PTM hardware if specified in the perf command line. If option is not supported by the hardware then it will be ignored. This allows capture to move between core/ETM combinations that have the hardware support to those that do not. Signed-off-by: Mike Leach --- drivers/hwtracing/coresight/coresight-etm.h | 1 + drivers/hwtracing/coresight/coresight-etm3x.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-etm.h b/drivers/hwtracing/coresight/coresight-etm.h index ad063d7..70b0a24 100644 --- a/drivers/hwtracing/coresight/coresight-etm.h +++ b/drivers/hwtracing/coresight/coresight-etm.h @@ -106,6 +106,7 @@ #define ETMTECR1_START_STOP BIT(25) /* ETMCCER - 0x1E8 */ #define ETMCCER_TIMESTAMP BIT(22) +#define ETMCCER_RETSTACK BIT(23) #define ETM_MODE_EXCLUDE BIT(0) #define ETM_MODE_CYCACC BIT(1) diff --git a/drivers/hwtracing/coresight/coresight-etm3x.c b/drivers/hwtracing/coresight/coresight-etm3x.c index a51b6b6..a0973f6 100644 --- a/drivers/hwtracing/coresight/coresight-etm3x.c +++ b/drivers/hwtracing/coresight/coresight-etm3x.c @@ -308,7 +308,9 @@ void etm_config_trace_mode(struct etm_config *config) config->addr_type[1] = ETM_ADDR_TYPE_RANGE; } -#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | ETMCR_TIMESTAMP_EN) +#define ETM3X_SUPPORTED_OPTIONS (ETMCR_CYC_ACC | \ + ETMCR_TIMESTAMP_EN | \ + ETMCR_RETURN_STACK) static int etm_parse_event_config(struct etm_drvdata *drvdata, struct perf_event *event) @@ -339,14 +341,24 @@ static int etm_parse_event_config(struct etm_drvdata *drvdata, etm_config_trace_mode(config); /* - * At this time only cycle accurate and timestamp options are - * available. + * At this time only cycle accurate, return stack and timestamp + * options are available. */ if (attr->config & ~ETM3X_SUPPORTED_OPTIONS) return -EINVAL; config->ctrl = attr->config; + /* + * Possible to have cores with PTM (supports ret stack) and ETM + * (never has ret stack) on the same SoC. So if we have a request + * for return stack that can't be honoured on this core then + * clear the bit - trace will still continue normally + */ + if ((config->ctrl & ETMCR_RETURN_STACK) && + !(drvdata->etmccer & ETMCCER_RETSTACK)) + config->ctrl &= ~ETMCR_RETURN_STACK; + return 0; }