Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp1879446pxb; Sun, 10 Jan 2021 14:54:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWk2m35QX0Ym/lm8jw1JiNP9ZxJ+6QcBZ6NEzG0bXXce6Hq/RrVAXXJkwXT97GJGToARpY X-Received: by 2002:a17:906:5796:: with SMTP id k22mr8792642ejq.435.1610319243960; Sun, 10 Jan 2021 14:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610319243; cv=none; d=google.com; s=arc-20160816; b=bkPpoubrpGSkum9mYpSnuu42PsRODKfROgJsJ8SvwR090aKNFgsWbw8iFslvZHJVBU /7f0F5JoflOXLZE+LB4ra+0zkgrvuwDMHpzxGlJ0qKWJX9bdqnh+K3OAavag7Cosm4Ha mqEyIITTk0+2IMgg0JHg5sSmh6IleHfPAgnLAc/stm2GXQKOxfxrB3zjZn0sLi/7LX+1 Ut+lqdGpoIg6qZjkFwt3YdbZwykC8bdO+3GyjaGdgi4jVNeQtOCyLx8AW/o5BfgSkkpi F4jOjMOP/5+WE9qzVZAWQ9WMKBVKbhEfKoufHwHytEcN8H1XlsgN99UDegnDfhFMKdLb Nmow== 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=ycO/XqH9Lp6VdPLqtg8D3pDqSgqzNKv0hEmbJEuMi7U=; b=UrUNoY1WEWB7WdNd6wnTYItRt1TT4Jw80XqutrKFXQhiqPt8IU+7C9bSq8Wjbu9vyQ nkB/IW8cdNBkl01INOx9O+eW4q+OWK0NruuB5hSJqYqkNBonvS9wh1E67x5F4vy/s0R/ on/40zMchj0FIHRfB272oTfLojryzz7piEIvx++AAGUzw/rCHT8/WPFfUg0pW2xFl+tr WqAiQoFnmWB6AIQy6qcUbVrGc3sbhRUHEcx678SR0X4OqDJswEYeRt9u4PHRRsYfr/fv kM6e/U8W2RgSaiQN/RHgmPdTVlJegTa2bm5UCMrZ658Z2UkfaK3CT0+RV+6ZsU4F+TI+ GxKQ== 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 e20si5937688ejq.444.2021.01.10.14.53.40; Sun, 10 Jan 2021 14:54:03 -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 S1727379AbhAJWvB (ORCPT + 99 others); Sun, 10 Jan 2021 17:51:01 -0500 Received: from foss.arm.com ([217.140.110.172]:39084 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727313AbhAJWvB (ORCPT ); Sun, 10 Jan 2021 17:51:01 -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 4E12515DB; Sun, 10 Jan 2021 14:49:46 -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 D8C213F719; Sun, 10 Jan 2021 14:49:44 -0800 (PST) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: coresight@lists.linaro.org, mathieu.poirier@linaro.org, anshuman.khandual@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, linux-kernel@vger.kernel.org, jonathan.zhouwen@huawei.com, catalin.marinas@arm.com, Will Deacon , Suzuki K Poulose Subject: [PATCH v7 28/28] coresight: Add support for v8.4 SelfHosted tracing Date: Sun, 10 Jan 2021 22:48:50 +0000 Message-Id: <20210110224850.1880240-29-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20210110224850.1880240-1-suzuki.poulose@arm.com> References: <20210110224850.1880240-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: Mike Leach Cc: Will Deacon Reviewed-by: Mathieu Poirier 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 3d3165dd09d4..18c1a80abab8 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-core.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-core.c @@ -859,6 +859,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 (!cpuid_feature_extract_unsigned_field(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; @@ -1044,6 +1068,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