From patchwork Mon Feb 1 18:13:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 12059679 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 392F1C433DB for ; Mon, 1 Feb 2021 18:19:44 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D5F3564E50 for ; Mon, 1 Feb 2021 18:19:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5F3564E50 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=kqYfo7AvRDJtvB9iv/hKE7TnXdbz4fGWrWdlGOwe73A=; b=Jhcuqd9dvJRKGcg3WKayISPmB d2VF7pyos+toWVjWkWt5X9ZNURZ9zwhmWfF4KDMcplJmWKSvbFyeJ1z+e2LBl4RpIElgKwzFkeuYT ymQ9+dG9+/J+UADA9/1XvP7hT+svqNOJPquD3BP6ap3VqtSAT4kNG9garnH4Pl7Fntxy3gvXRFAYx hfwV5rJcaUR9A6PUgKnIlRszqcv7KoGNbjRnUxYOytBWUbDmmt6EaSQeewbbU3/146HhSDlw5fXlt yQkVHmDpPWrRiq11KwxaAuTNBlJe38TgQ4chf3G3NhdBHKc9H7q/S2UQJI+BdxQlm6IaOtM1yfCc/ MJp6vaaAw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6dlZ-0004rb-Gb; Mon, 01 Feb 2021 18:17:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l6diY-0003D0-DK for linux-arm-kernel@merlin.infradead.org; Mon, 01 Feb 2021 18:14:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UUTXKEyDoj2yYHV7VRlaeVtzyllZkVV0kWljFdybBQc=; b=FHom6d0ZTwMooSmvWqaKuhU1AO O7f80Z3X/WbFPN5eymacp3YonE7WPqTz05pxrwJyuccMj7Aff9Q1tVg144oDMPh85vgatHNlS86Sl B6SHaq9/tpCS93yA1nGHZ2XpKuta5xgv0ub7AlH0vbUSQfqWYVeN0J1Ds81RjhN49xvfep3t5crC1 bAp2f/RGGqlubGMxusc0sY3VOvMBza6LGwrLNov1oMq5V1nEbOl1YUPPYTUWGGoBJqPXdDW3Exrj0 HyUUErkyPts46W2rhAlxMp2BCQf5fTHMXzFVgbXZ+KkRvc7pqocikAG3lwyxqtXtnkQkfD+uJa/Ts eDDF6YuQ==; Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1l6diV-00E8Dh-Rs for linux-arm-kernel@lists.infradead.org; Mon, 01 Feb 2021 18:14:28 +0000 Received: by mail-pj1-x1032.google.com with SMTP id d2so76897pjs.4 for ; Mon, 01 Feb 2021 10:14:27 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=UUTXKEyDoj2yYHV7VRlaeVtzyllZkVV0kWljFdybBQc=; b=opEvKWv5QoRwT30WTVzp5yrWzeuFQtpKLqPwN8Uyb+jH4PdqkIXmeagv0guR0tAaRp 5wdxYueQ+YTMW8fqWq8tWfxtdL1zH/MBesu0wlKxKEoIDDohAiJ0U3quFRHBYMXaSWUD px8hRCQAT+318iemlpV699CeudNUzgiMAvRU9f7RhAzx3gQ1cTCUm21zauI60nHw68Uj U4UPizNOJWPdmd11tDOT5WulZhz6Rdw6y3Z/YMkMD6UUpPN8iZTL3qGxRvr5ydRH5X7o hAwmdU0sWBeDlbsihAaODfX9iAJn9IImiYUf/60LG4znVAAGl37aXYVhhmqnOkp3voCw muGg== 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:mime-version:content-transfer-encoding; bh=UUTXKEyDoj2yYHV7VRlaeVtzyllZkVV0kWljFdybBQc=; b=CF0jIsSfdih7YGKPcfv+aRlqGQCAF2ayXNN1gws6KnHih9bBTsWe1H+e18C3gC+h0S j/9/VQT0RWmvbjwVEEfoPbfsxcf2KBHI9NtWHlZKfiyHS6eucepgIA/MohToZwDCDtgg Eu9YXxmAqiScgLNv7ebtz1h5kCh8vDWL1nQa+bGqI2RWa1uPuMn65uJu4OtS0PKhYsFR yG6v4zbQWE0GIxK9LIzJY9pROPJXp3Cbs9Qin5RmFWKGZ4LvENMLWI9ayeK0JYXURLxB 3hcoSdbFDDhPMnseh15GlCv4Y8TAcFDO5QO6+SwZE3DwSJCVHfFhbg8SlsNjFX4mm/RP M8ww== X-Gm-Message-State: AOAM532w8byyRff/iqeh1P95WEldweCBpNlYAaifzpG0fI/aW6Y7sorH pvOMPByF5IlwBGlE6XOp7ZZPmQ== X-Google-Smtp-Source: ABdhPJw/nAiZDK/T+Pgg2La1m2T8BiZb/t0a59Wp8Mcd+RaxYAaOlqp3bhxJDqV3tO8KAEN95i4sdA== X-Received: by 2002:a17:90a:8c13:: with SMTP id a19mr152090pjo.80.1612203265683; Mon, 01 Feb 2021 10:14:25 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id e12sm75784pjj.23.2021.02.01.10.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Feb 2021 10:14:25 -0800 (PST) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 30/31] coresight: Add support for v8.4 SelfHosted tracing Date: Mon, 1 Feb 2021 11:13:50 -0700 Message-Id: <20210201181351.1475223-31-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210201181351.1475223-1-mathieu.poirier@linaro.org> References: <20210201181351.1475223-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210201_181428_352634_2EAB86BA X-CRM114-Status: GOOD ( 14.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 Link: https://lore.kernel.org/r/20210110224850.1880240-29-suzuki.poulose@arm.com Signed-off-by: Mathieu Poirier --- .../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 c6238e208685..473ab7480a36 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)