From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12DB2C433F5 for ; Mon, 2 May 2022 16:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=faP2c11XuaOz7DODIJ1gwzfclIRtKt0MirHdsJgLsF0=; b=HUZhVvPY3vEGCF GMtOr8rbm2sdEIIdfyWLfmsqolWkuN2hJuoMhQsMYHrpsNKKDzLdQ1Q7OQ5sdj3VKz6zB6U1o949J ZmrBObHJ4sgnM12pqaTZ2D8z9NluyzzCrmYdhsa6ZqDKom27K8vrjiL1+vMGl9cYRuUVhALeoDqJk Tc02PycTOvJewF/zrdJOjikBXxpqVneKxxb4E9rjoHUCtvkoFddzZOspCPh+PTOq6SLESbVHiBoBV xW5zG7Oev+Sac7dvghnAOM90ptSNfqjoQv+H+cHuq19fSdz+rbR+LkRuRwcgHmPWjdvNm7iuPnj6e YkA2+tYI0KLkANplDBsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nlZEg-001o1M-52; Mon, 02 May 2022 16:49:23 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nlZEZ-001nyU-Rc for linux-arm-kernel@lists.infradead.org; Mon, 02 May 2022 16:49:18 +0000 Received: by mail-pj1-x102a.google.com with SMTP id t11-20020a17090ad50b00b001d95bf21996so16549236pju.2 for ; Mon, 02 May 2022 09:49:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0pMZ4chT6I/f3Jk5AKYOsdoQMhcv2o17LMQaLhnOXVk=; b=hinFYAiucdiinOlK5arn5v6mBgMF+zpJgW1TT9ZxROBsC8tD5/z3U695lPX+XFa6pO R2eL4z06ZrIqpXyXmcekpdFhNn7bPRTNkT+BSE3i0N2v/NEZmVhObdQTB50HBVh2teDr yJWsX3wzg+pY/elBuNTIJLLKmlO4rG+KNJdC/YwDQYAjN+IvtBlCWuFNE0f0umXbFVJC DVVO9ug6oxnR8hhpw6tD/nlnmONDxzcE4pXDUXa5loxxMbxk3HiTp66BBE6GLHOKXcS4 vqDOccqgbOLkIYTUDkbjyv0k/ls9c0orp5jw90PRMQfbx5Qk6jhEsJETuDixAv1oh7ux r97g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0pMZ4chT6I/f3Jk5AKYOsdoQMhcv2o17LMQaLhnOXVk=; b=bykzLJwpENOnM0prDtr1J9ZjsfDqkL67+FUdtX1sKBepM9+uSWD6hRxhbtYMP/PNLB Wuin2KR/Exs9M4trpbwkvfR9tln+CpkjVfupnT7YebMLQ1WODONrsF4RZbGTCFt9XTCx w+7gGJ1pZ/AlBSFLiC+o0cBUM3pw18zokaHJ6jmgXbXGJtJh9X1dVLpx4z0wAAq8koIF VTPXz4aoA/+jU46Htz6SZpbffFPiMAWevdSB7tvS6zvWYq1FtFDMOZDaPC2Po/ElmMlk v00Xz8yzOQ+2CCnUidZDXMB5BF4N6tXfiauhwEMn7d5AiHEAlyiKWXB/EJC9Y1jHfekb rQ1Q== X-Gm-Message-State: AOAM530YP1y0Ywrugy9lVR9IVE0PBAjWeXHj79/Ojzn7YWwisccQFAc5 GYlJdIgVSI488beSbTZVvsZwUA== X-Google-Smtp-Source: ABdhPJwO0LnrbY4Zkvwvt567SkuKoTCwV12+xRTQ+hWfPwOQbPNwvvs/go45eTzJYSog8YYYxhFZ3Q== X-Received: by 2002:a17:90a:af98:b0:1d4:67d4:d122 with SMTP id w24-20020a17090aaf9800b001d467d4d122mr54456pjq.166.1651510154259; Mon, 02 May 2022 09:49:14 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id c136-20020a63358e000000b003c14af5063bsm11882556pga.83.2022.05.02.09.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 09:49:13 -0700 (PDT) Date: Mon, 2 May 2022 10:49:11 -0600 From: Mathieu Poirier To: German Gomez Cc: coresight@lists.linaro.org, suzuki.poulose@arm.com, james.clark@arm.com, leo.yan@linaro.org, mike.leach@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] coresight: etm4x: Expose default timestamp source in sysfs Message-ID: <20220502164911.GB2498226@p14s> References: <20220429123100.268059-1-german.gomez@arm.com> <20220429123100.268059-2-german.gomez@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220429123100.268059-2-german.gomez@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220502_094915_940742_7BBB82A3 X-CRM114-Status: GOOD ( 23.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Apr 29, 2022 at 01:30:59PM +0100, German Gomez wrote: > 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 > --- > arch/arm64/include/asm/sysreg.h | 1 + > .../coresight/coresight-etm4x-sysfs.c | 34 +++++++++++++++++++ > 2 files changed, 35 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..c0c375c0cfde2 100644 > --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c > @@ -2264,6 +2264,39 @@ static ssize_t cpu_show(struct device *dev, > } > static DEVICE_ATTR_RO(cpu); > > +static int etmv4_to_ts_source(struct etmv4_drvdata *drvdata) > +{ > + int val; > + > + if (!drvdata->trfcr) > + return -1; > + > + 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; > + } I don't think the above is big and/or complex enough to mandate a separate function - please move to ts_source_show(). > + > + return val; > +} > + > +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); > + > + val = etmv4_to_ts_source(drvdata); > + 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 +2351,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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel