public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ilkka Koskinen <ilkka@os.amperecomputing.com>
To: Robin Murphy <robin.murphy@arm.com>,
	Will Deacon <will@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] perf/arm-cmn: Add support for model specific parameters
Date: Fri, 26 Jan 2024 14:12:14 -0800	[thread overview]
Message-ID: <20240126221215.1537377-3-ilkka@os.amperecomputing.com> (raw)
In-Reply-To: <20240126221215.1537377-1-ilkka@os.amperecomputing.com>

Newer models have slightly different parameter fields or may introduce
completely new ones. Thus, prepare for it by making also the parameters
model specific.

Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
---
 drivers/perf/arm-cmn.c | 45 +++++++++++++++++++++++++++++-------------
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c
index 93eb47ea7e25..dc6370396ad0 100644
--- a/drivers/perf/arm-cmn.c
+++ b/drivers/perf/arm-cmn.c
@@ -628,6 +628,7 @@ struct arm_cmn_event_attr {
 
 struct arm_cmn_format_attr {
 	struct device_attribute attr;
+	enum cmn_model model;
 	u64 field;
 	int config;
 };
@@ -1265,29 +1266,44 @@ static ssize_t arm_cmn_format_show(struct device *dev,
 	return sysfs_emit(buf, "config%d:%d-%d\n", fmt->config, lo, hi);
 }
 
-#define _CMN_FORMAT_ATTR(_name, _cfg, _fld)				\
+static umode_t arm_cmn_format_attr_is_visible(struct kobject *kobj,
+					      struct attribute *attr,
+					      int unused)
+{
+	struct device *dev = kobj_to_dev(kobj);
+	struct arm_cmn *cmn = to_cmn(dev_get_drvdata(dev));
+	struct arm_cmn_format_attr *fmt = container_of(attr, typeof(*fmt), attr.attr);
+
+	if (!(fmt->model & arm_cmn_model(cmn)))
+		return 0;
+
+	return attr->mode;
+}
+
+#define _CMN_FORMAT_ATTR(_model, _name, _cfg, _fld)			\
 	(&((struct arm_cmn_format_attr[]) {{				\
 		.attr = __ATTR(_name, 0444, arm_cmn_format_show, NULL),	\
+		.model = _model,					\
 		.config = _cfg,						\
 		.field = _fld,						\
 	}})[0].attr.attr)
-#define CMN_FORMAT_ATTR(_name, _fld)	_CMN_FORMAT_ATTR(_name, 0, _fld)
+#define CMN_FORMAT_ATTR(_model, _name, _fld)	_CMN_FORMAT_ATTR(_model, _name, 0, _fld)
 
 static struct attribute *arm_cmn_format_attrs[] = {
-	CMN_FORMAT_ATTR(type, CMN_CONFIG_TYPE),
-	CMN_FORMAT_ATTR(eventid, CMN_CONFIG_EVENTID),
-	CMN_FORMAT_ATTR(occupid, CMN_CONFIG_OCCUPID),
-	CMN_FORMAT_ATTR(bynodeid, CMN_CONFIG_BYNODEID),
-	CMN_FORMAT_ATTR(nodeid, CMN_CONFIG_NODEID),
+	CMN_FORMAT_ATTR(CMN_ANY, type, CMN_CONFIG_TYPE),
+	CMN_FORMAT_ATTR(CMN_ANY, eventid, CMN_CONFIG_EVENTID),
+	CMN_FORMAT_ATTR(CMN_ANY, occupid, CMN_CONFIG_OCCUPID),
+	CMN_FORMAT_ATTR(CMN_ANY, bynodeid, CMN_CONFIG_BYNODEID),
+	CMN_FORMAT_ATTR(CMN_ANY, nodeid, CMN_CONFIG_NODEID),
 
-	CMN_FORMAT_ATTR(wp_dev_sel, CMN_CONFIG_WP_DEV_SEL),
-	CMN_FORMAT_ATTR(wp_chn_sel, CMN_CONFIG_WP_CHN_SEL),
-	CMN_FORMAT_ATTR(wp_grp, CMN_CONFIG_WP_GRP),
-	CMN_FORMAT_ATTR(wp_exclusive, CMN_CONFIG_WP_EXCLUSIVE),
-	CMN_FORMAT_ATTR(wp_combine, CMN_CONFIG_WP_COMBINE),
+	CMN_FORMAT_ATTR(CMN_ANY, wp_dev_sel, CMN_CONFIG_WP_DEV_SEL),
+	CMN_FORMAT_ATTR(CMN_ANY, wp_chn_sel, CMN_CONFIG_WP_CHN_SEL),
+	CMN_FORMAT_ATTR(CMN_ANY, wp_grp, CMN_CONFIG_WP_GRP),
+	CMN_FORMAT_ATTR(CMN_ANY, wp_exclusive, CMN_CONFIG_WP_EXCLUSIVE),
+	CMN_FORMAT_ATTR(CMN_ANY, wp_combine, CMN_CONFIG_WP_COMBINE),
 
-	_CMN_FORMAT_ATTR(wp_val, 1, CMN_CONFIG1_WP_VAL),
-	_CMN_FORMAT_ATTR(wp_mask, 2, CMN_CONFIG2_WP_MASK),
+	_CMN_FORMAT_ATTR(CMN_ANY, wp_val, 1, CMN_CONFIG1_WP_VAL),
+	_CMN_FORMAT_ATTR(CMN_ANY, wp_mask, 2, CMN_CONFIG2_WP_MASK),
 
 	NULL
 };
@@ -1295,6 +1311,7 @@ static struct attribute *arm_cmn_format_attrs[] = {
 static const struct attribute_group arm_cmn_format_attrs_group = {
 	.name = "format",
 	.attrs = arm_cmn_format_attrs,
+	.is_visible = arm_cmn_format_attr_is_visible,
 };
 
 static ssize_t arm_cmn_cpumask_show(struct device *dev,
-- 
2.40.1


  parent reply	other threads:[~2024-01-26 22:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 22:12 [PATCH 0/3] perf/arm-cmn: Add support for tertiary match group Ilkka Koskinen
2024-01-26 22:12 ` [PATCH 1/3] perf/arm-cmn: Decouple wp_config registers from filter group number Ilkka Koskinen
2024-01-29 17:06   ` Robin Murphy
2024-01-30  5:28     ` Ilkka Koskinen
2024-01-26 22:12 ` Ilkka Koskinen [this message]
2024-01-26 22:12 ` [PATCH 3/3] perf/arm-cmn: Enable support for tertiary match group Ilkka Koskinen
2024-01-29 17:07   ` Robin Murphy
2024-01-30  5:35     ` Ilkka Koskinen

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=20240126221215.1537377-3-ilkka@os.amperecomputing.com \
    --to=ilkka@os.amperecomputing.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox