]> git.dujemihanovic.xyz Git - linux.git/commitdiff
perf/arm-cmn: Add sysfs identifier
authorRobin Murphy <robin.murphy@arm.com>
Mon, 12 Jun 2023 17:16:33 +0000 (18:16 +0100)
committerWill Deacon <will@kernel.org>
Fri, 16 Jun 2023 09:28:21 +0000 (10:28 +0100)
Expose a sysfs identifier encapsulating the CMN part number and revision
so that jevents can narrow down a fundamental set of possible events for
calculating metrics. Configuration-dependent aspects - such as whether a
given node type is present, and/or a given node ID is valid - are still
not covered, and in general it's hard to see how userspace could handle
them, so we won't be removing any data or validation logic from the
driver any time soon, but at least it's a step in a useful direction.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Reviewed-and-tested-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Tested-by: Jing Zhang <renyu.zj@linux.alibaba.com>
Link: https://lore.kernel.org/r/b8a14c14fcdf028939ebf57849863e8ae01743de.1686588640.git.robin.murphy@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/perf/arm-cmn.c

index 4a1dc4b527f61c850dfc14bb01cc6ead8507977c..b8c15878bc86dacd9fa27285243d653cc94e9c25 100644 (file)
@@ -1199,19 +1199,31 @@ static ssize_t arm_cmn_cpumask_show(struct device *dev,
 static struct device_attribute arm_cmn_cpumask_attr =
                __ATTR(cpumask, 0444, arm_cmn_cpumask_show, NULL);
 
-static struct attribute *arm_cmn_cpumask_attrs[] = {
+static ssize_t arm_cmn_identifier_show(struct device *dev,
+                                      struct device_attribute *attr, char *buf)
+{
+       struct arm_cmn *cmn = to_cmn(dev_get_drvdata(dev));
+
+       return sysfs_emit(buf, "%03x%02x\n", cmn->part, cmn->rev);
+}
+
+static struct device_attribute arm_cmn_identifier_attr =
+               __ATTR(identifier, 0444, arm_cmn_identifier_show, NULL);
+
+static struct attribute *arm_cmn_other_attrs[] = {
        &arm_cmn_cpumask_attr.attr,
+       &arm_cmn_identifier_attr.attr,
        NULL,
 };
 
-static const struct attribute_group arm_cmn_cpumask_attr_group = {
-       .attrs = arm_cmn_cpumask_attrs,
+static const struct attribute_group arm_cmn_other_attrs_group = {
+       .attrs = arm_cmn_other_attrs,
 };
 
 static const struct attribute_group *arm_cmn_attr_groups[] = {
        &arm_cmn_event_attrs_group,
        &arm_cmn_format_attrs_group,
-       &arm_cmn_cpumask_attr_group,
+       &arm_cmn_other_attrs_group,
        NULL
 };