Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp590212pxb; Thu, 19 Nov 2020 08:49:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTjAIbqQ6IYhk2S5mL1rOWYyMhPr/m5Mo95h/mlCSJ8U+3+/rbsMyQ+GDfuDKoY26Bh3pW X-Received: by 2002:a50:9b02:: with SMTP id o2mr8424776edi.208.1605804558584; Thu, 19 Nov 2020 08:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605804558; cv=none; d=google.com; s=arc-20160816; b=g/agbBr2gGj6FuTot+FZ5nU7evCLnCTQqpQqHytu0CYoV+EHM6+0PfllLzdWfukRWN zHNjOEqaWJErlRB+j9F+7mOJuI11LotZCtx74TM9veGm7qkieLgbPd89SCSD1W8j+/5Q YHtUhfQU9db1wJZyu287HtCUyKMSRlMMm0sG65/FrA7fWrav4vT4ap46GD6AkicqeN+2 CwtWq9Vtdz6K7GsMF3PqGMzavBy2fA0CXa5WqdSy8wrYYV5z7XHyf5lBMQlNCU41lz6K DWtrYB4IUQ/J1hGcC7IfNBgwn1tGjGcoWQNq5hDTd3b06qAFkSQQe0q2NFcjIHj+C+pC l4Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=u1oX++OjvOgTLtrkX4CIC/h5uXUDCtRzpYzYGlcn0XU=; b=u6sy/UFpU8+dZTYvSgu58OSitvx190PWIg6zRFoE2RSwkDeVYb7FomeluT2YYtWCNm 7C+x7+i3H6pYBp4fkW+h3Y/VlSR0nr2RWoPowp13BzfFgFRBVjTHODwToGsIpCh0dVPf ylVgSq9gt7Sv1b4oBMl2XzTbzQsh+PpSnh0zi6uOOMGB/DiRZ8JdWrFf4rKoZvs3Yxbg y7bTSJ4Z2jmmI/vYRn7ipgtnqCyWBhcX2NTGdPRhP9PiEPEV28fiyF1r9WkamA5HANU7 q/RMFI37fZCiqftm5mCzKRt1iMT78W5jAdqvkFMQpxckShPcFHRco7R/A/hx7jVk+6HW t8IQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr7si140778ejb.592.2020.11.19.08.48.55; Thu, 19 Nov 2020 08:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729328AbgKSQqp (ORCPT + 99 others); Thu, 19 Nov 2020 11:46:45 -0500 Received: from foss.arm.com ([217.140.110.172]:34672 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729280AbgKSQqn (ORCPT ); Thu, 19 Nov 2020 11:46:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B21DF1650; Thu, 19 Nov 2020 08:46:38 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2FB3B3F718; Thu, 19 Nov 2020 08:46:37 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: mathieu.poirier@linaro.org, mike.leach@linaro.org, linux-kernel@vger.kernel.org, anshuman.khandual@arm.com, jonathan.zhouwen@huawei.com, coresight@lists.linaro.org, Catalin Marinas , Will Deacon , Suzuki K Poulose Subject: [PATCH v4 25/25] coresight: Add support for v8.4 SelfHosted tracing Date: Thu, 19 Nov 2020 16:45:47 +0000 Message-Id: <20201119164547.2982871-26-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20201119164547.2982871-1-suzuki.poulose@arm.com> References: <20201119164547.2982871-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Zhou v8.4 tracing extensions added support for trace filtering controlled by TRFCR_ELx. This must be programmed to allow tracing at EL1/EL2 and EL0. The timestamp used is the virtual time. Also enable CONTEXIDR_EL2 tracing if we are running the kernel at EL2. Cc: Catalin Marinas Cc: Mathieu Poirier Cc: Mike Leach Cc: Will Deacon Signed-off-by: Jonathan Zhou [ Move the trace filtering setup etm_init_arch_data() and clean ups] Signed-off-by: Suzuki K Poulose --- .../coresight/coresight-etm4x-core.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-core.c b/drivers/hwtracing/coresight/coresight-etm4x-core.c index 1d054d2ab2a0..647685736134 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -760,6 +760,30 @@ static bool etm4_init_csdev_access(struct etmv4_drvdata *drvdata, return false; } +static void cpu_enable_tracing(void) +{ + u64 dfr0 = read_sysreg(id_aa64dfr0_el1); + u64 trfcr; + + if (!(dfr0 >> ID_AA64DFR0_TRACE_FILT_SHIFT)) + return; + + /* + * If the CPU supports v8.4 SelfHosted Tracing, enable + * tracing at the kernel EL and EL0, forcing to use the + * virtual time as the timestamp. + */ + trfcr = (TRFCR_ELx_TS_VIRTUAL | + TRFCR_ELx_ExTRE | + TRFCR_ELx_E0TRE); + + /* If we are running at EL2, allow tracing the CONTEXTIDR_EL2. */ + if (is_kernel_in_hyp_mode()) + trfcr |= TRFCR_EL2_CX; + + write_sysreg_s(trfcr, SYS_TRFCR_EL1); +} + static void etm4_init_arch_data(void *info) { u32 etmidr0; @@ -943,6 +967,7 @@ static void etm4_init_arch_data(void *info) /* NUMCNTR, bits[30:28] number of counters available for tracing */ drvdata->nr_cntr = BMVAL(etmidr5, 28, 30); etm4_cs_lock(drvdata, csa); + cpu_enable_tracing(); } static inline u32 etm4_get_victlr_access_type(struct etmv4_config *config) -- 2.24.1