All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: James Clark <james.clark@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach <mike.leach@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 5/6] coresight: Add format attribute for setting the timestamp interval
Date: Wed, 1 Oct 2025 14:55:46 +0100	[thread overview]
Message-ID: <20251001135546.GP7985@e132581.arm.com> (raw)
In-Reply-To: <708a5bbd-2bad-4f94-8fd1-6bd10825ba71@linaro.org>

On Wed, Oct 01, 2025 at 02:44:06PM +0100, James Clark wrote:

[...]

> > ATTR_CFG_FLD_ts_level_* is only used in coresight-etm4x-core.c, it is not
> > used in coresight-etm-perf.c. Thus, we don't need to include
> > coresight-etm4x.h in coresight-etm-perf.c. Do I miss anything?
> 
> Yes, GEN_PMU_FORMAT_ATTR() uses them but it makes it hard to see.

I did a quick test, it is feasible to move ATTR_CFG_* macros in
coresight-etm-perf.h. This is a more suitable ?

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.h b/drivers/hwtracing/coresight/coresight-etm-perf.h
index 5febbcdb8696..2679d5b2dd9a 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.h
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.h
@@ -8,6 +8,7 @@
 #define _CORESIGHT_ETM_PERF_H
 
 #include <linux/percpu-defs.h>
+#include <linux/perf/arm_pmu.h>
 #include "coresight-priv.h"
 
 struct coresight_device;
@@ -20,6 +21,12 @@ struct cscfg_config_desc;
  */
 #define ETM_ADDR_CMP_MAX       8
 
+#define ATTR_CFG_FLD_ts_level_CFG      config3
+#define ATTR_CFG_FLD_ts_level_LO       12
+#define ATTR_CFG_FLD_ts_level_HI       15
+#define ATTR_CFG_FLD_ts_level_MASK     GENMASK(ATTR_CFG_FLD_ts_level_HI, \
+                                               ATTR_CFG_FLD_ts_level_LO)
+

> > A similiar case is the attr 'cc_threshold' is only used by ETMv4, it is
> > exported always. It is not bad for me to always expose these attrs but
> > in the are ignored in the ETMv3 driver - so we even don't need to
> > bother adding .visible() callback.
> > 
> 
> I disagree with always showing them. I think they should be hidden if
> they're not used, or at least return an error to avoid confusing users. It
> also wastes config bits if they're allocated but never used.

It is fine for not exposing ETMv4 only attrs for ETMv3.

> Either way, this was done because of the header mechanics which can only be
> avoided by adding more changes than just the #ifdefs. There are also already
> ETM4 #ifdefs in the file.

Yeah, actually we can remove ETM4 #ifdefs, something like:

 /*
  * contextid always traces the "PID".  The PID is in CONTEXTIDR_EL1
@@ -90,9 +83,9 @@ static ssize_t format_attr_contextid_show(struct device *dev,
 {
        int pid_fmt = ETM_OPT_CTXTID;
 
-#if IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X)
-       pid_fmt = is_kernel_in_hyp_mode() ? ETM_OPT_CTXTID2 : ETM_OPT_CTXTID;
-#endif
+       if (IS_ENABLED(CONFIG_CORESIGHT_SOURCE_ETM4X))
+               pid_fmt = is_kernel_in_hyp_mode() ? ETM_OPT_CTXTID2 : ;
+
        return sprintf(page, "config:%d\n", pid_fmt);
 }

Thanks,
Leo


  reply	other threads:[~2025-10-01 13:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14 10:49 [PATCH v2 0/6] coresight: Add format attribute for setting the timestamp interval James Clark
2025-08-14 10:49 ` [PATCH v2 1/6] coresight: Change syncfreq to be a u8 James Clark
2025-08-14 10:49 ` [PATCH v2 2/6] coresight: Fix holes in struct etmv4_config James Clark
2025-08-14 10:49 ` [PATCH v2 3/6] coresight: Repack struct etmv4_drvdata James Clark
2025-09-30 14:41   ` Leo Yan
2025-08-14 10:49 ` [PATCH v2 4/6] coresight: Refactor etm4_config_timestamp_event() James Clark
2025-09-30 14:56   ` Leo Yan
2025-08-14 10:49 ` [PATCH v2 5/6] coresight: Add format attribute for setting the timestamp interval James Clark
2025-09-30 15:14   ` Leo Yan
2025-10-01 12:40     ` James Clark
2025-10-01 13:28       ` Leo Yan
2025-10-01 13:39         ` Leo Yan
2025-10-01 13:44         ` James Clark
2025-10-01 13:55           ` Leo Yan [this message]
2025-08-14 10:49 ` [PATCH v2 6/6] coresight: docs: Document etm4x ts_interval James Clark
2025-09-30 15:20 ` [PATCH v2 0/6] coresight: Add format attribute for setting the timestamp interval Leo Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251001135546.GP7985@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=james.clark@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@linaro.org \
    --cc=suzuki.poulose@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.