Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp722015iob; Tue, 3 May 2022 08:19:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAwNtEFth5gWuBjtSj2qh59PlA5i18IiNGJL4pRI9S9L6zlHBjQgrstlyW2EWPbScxDhqT X-Received: by 2002:a17:902:e5d2:b0:15e:9467:187 with SMTP id u18-20020a170902e5d200b0015e94670187mr14543103plf.123.1651591179288; Tue, 03 May 2022 08:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651591179; cv=none; d=google.com; s=arc-20160816; b=UpVT+Xws6PWucS6Qo8jP4WslaLc4rFcWwt6t8c4n3SE8gA0MrrP/wqtGGq/F82k0db 153Eph5+aXUZjmC669xwgKyhag2DmvZvNs1uCYqkgjUERZ6k1XJUs9/gygxByBaQ9rnQ 2qYJh8nGlJeqIXIM1Yj+ITBvIVqpQmyMMJqwJVllnPKGEKEnC9O+0IF9Ug3n5u/hMqML zDSLVp0VTAvwhge9fMKkicmYy1veTdigxYkCDST4/SddDPxsvhi5xHNu7U9AvbA+Lky7 WzGo53fzzyYi9/hPK3mTgsWuYVzpwtQlC8PQqM4rkw5+uT7/ZIdOxsN1BrMghfUv0pB2 aMpw== 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 :message-id:date:subject:cc:to:from; bh=yk6GfaVF1N2EWOZa1h0NxVsGgLOVSVk8FUcBuAT59bc=; b=dek3u+9W0Ncm3GQM53cuea1tqwSs7DvReqdsp0+dmAwOB/bSGzuNFMQpLt9vKA3Qbq tsSgdp8ZZlEKF6jLPqrCgM756mLIsgUKIHFhCFx1DMRxDxJxiEIUP7IHEy+EXGofGsnJ nxhvZku+rqAhqTnBO5oj445QEKzc/kfdmfq6172dGIojgSaLXK4CVKfXPQgjtRF5Cruc emRl0gNdfPSnIsYf0Jel4PjER5DM4CmfL5xdZ3D700SKfiFcY8cj8714cNHZxKxqYR+W IFMfa+Bp/h3shZzpUAOhCPWr/mRUFmUkQ16wNjXR35jln2k51h56i1Wk/4LW78urlGya PmAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z30-20020a634c1e000000b0039d4f859427si9804428pga.191.2022.05.03.08.19.22; Tue, 03 May 2022 08:19:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235390AbiECMjW (ORCPT + 99 others); Tue, 3 May 2022 08:39:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235024AbiECMjV (ORCPT ); Tue, 3 May 2022 08:39:21 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E3BD923BEF for ; Tue, 3 May 2022 05:35:48 -0700 (PDT) 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 A8D631042; Tue, 3 May 2022 05:35:48 -0700 (PDT) Received: from e127744.cambridge.arm.com (e127744.cambridge.arm.com [10.1.28.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 916BB3F73D; Tue, 3 May 2022 05:35:46 -0700 (PDT) From: German Gomez To: coresight@lists.linaro.org, mathieu.poirier@linaro.org, suzuki.poulose@arm.com Cc: james.clark@arm.com, leo.yan@linaro.org, mike.leach@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, German Gomez Subject: [PATCH v2 1/2] coresight: etm4x: Expose default timestamp source in sysfs Date: Tue, 3 May 2022 13:35:36 +0100 Message-Id: <20220503123537.1003035-1-german.gomez@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new sysfs interface in /sys/bus/coresight/devices/etm/ts_source indicating the configured timestamp source when the ETM device driver was probed. The perf tool will use this information to detect if the trace data timestamp matches the kernel time, enabling correlation of CoreSight trace with perf events. Suggested-by: Suzuki K Poulose Signed-off-by: German Gomez Reviewed-by: Leo Yan --- v1: - https://lore.kernel.org/all/20220429123100.268059-2-german.gomez@arm.com/ v2: - Inline etmv4_to_ts_source() function. - Collect review tag from Leo. --- arch/arm64/include/asm/sysreg.h | 1 + .../coresight/coresight-etm4x-sysfs.c | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 38508e507d73a..263a7bee06f9a 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -1146,6 +1146,7 @@ #define SYS_MPIDR_SAFE_VAL (BIT(31)) #define TRFCR_ELx_TS_SHIFT 5 +#define TRFCR_ELx_TS_MASK ((0x3UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_VIRTUAL ((0x1UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_GUEST_PHYSICAL ((0x2UL) << TRFCR_ELx_TS_SHIFT) #define TRFCR_ELx_TS_PHYSICAL ((0x3UL) << TRFCR_ELx_TS_SHIFT) diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c index a0640fa5c55bd..2a48827a4e135 100644 --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c @@ -2264,6 +2264,34 @@ static ssize_t cpu_show(struct device *dev, } static DEVICE_ATTR_RO(cpu); +static ssize_t ts_source_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int val; + struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent); + + if (!drvdata->trfcr) { + val = -1; + goto out; + } + + switch (drvdata->trfcr & TRFCR_ELx_TS_MASK) { + case TRFCR_ELx_TS_VIRTUAL: + case TRFCR_ELx_TS_GUEST_PHYSICAL: + case TRFCR_ELx_TS_PHYSICAL: + val = FIELD_GET(TRFCR_ELx_TS_MASK, drvdata->trfcr); + break; + default: + val = -1; + break; + } + +out: + return sysfs_emit(buf, "%d\n", val); +} +static DEVICE_ATTR_RO(ts_source); + static struct attribute *coresight_etmv4_attrs[] = { &dev_attr_nr_pe_cmp.attr, &dev_attr_nr_addr_cmp.attr, @@ -2318,6 +2346,7 @@ static struct attribute *coresight_etmv4_attrs[] = { &dev_attr_vmid_val.attr, &dev_attr_vmid_masks.attr, &dev_attr_cpu.attr, + &dev_attr_ts_source.attr, NULL, }; -- 2.25.1