From: John Garry <john.garry@huawei.com>
To: <Frank.li@nxp.com>, <will@kernel.org>, <mark.rutland@arm.com>,
<robh+dt@kernel.org>, <zhangshaokun@hisilicon.com>,
<qiangqing.zhang@nxp.com>
Cc: <linuxarm@huawei.com>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <acme@kernel.org>,
<jolsa@redhat.com>, <irogers@google.com>,
John Garry <john.garry@huawei.com>
Subject: [PATCH v2 4/4] perf/smmuv3: Support sysfs identifier file
Date: Thu, 8 Oct 2020 17:26:21 +0800 [thread overview]
Message-ID: <1602149181-237415-5-git-send-email-john.garry@huawei.com> (raw)
In-Reply-To: <1602149181-237415-1-git-send-email-john.garry@huawei.com>
SMMU_PMCG_IIDR was added in the SMMUv3.3 spec.
For the perf tool to know the specific HW implementation, expose the
PMCG_IIDR contents only when set.
Signed-off-by: John Garry <john.garry@huawei.com>
---
drivers/perf/arm_smmuv3_pmu.c | 39 +++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
index 5274f7fe359e..74474bb322c3 100644
--- a/drivers/perf/arm_smmuv3_pmu.c
+++ b/drivers/perf/arm_smmuv3_pmu.c
@@ -74,6 +74,7 @@
#define SMMU_PMCG_CFGR_NCTR GENMASK(5, 0)
#define SMMU_PMCG_CR 0xE04
#define SMMU_PMCG_CR_ENABLE BIT(0)
+#define SMMU_PMCG_IIDR 0xE08
#define SMMU_PMCG_CEID0 0xE20
#define SMMU_PMCG_CEID1 0xE28
#define SMMU_PMCG_IRQ_CTRL 0xE50
@@ -112,6 +113,7 @@ struct smmu_pmu {
void __iomem *reloc_base;
u64 counter_mask;
u32 options;
+ u32 iidr;
bool global_filter;
};
@@ -552,6 +554,40 @@ static struct attribute_group smmu_pmu_events_group = {
.is_visible = smmu_pmu_event_is_visible,
};
+static ssize_t smmu_pmu_identifier_attr_show(struct device *dev,
+ struct device_attribute *attr,
+ char *page)
+{
+ struct smmu_pmu *smmu_pmu = to_smmu_pmu(dev_get_drvdata(dev));
+
+ return snprintf(page, PAGE_SIZE, "0x%08x\n", smmu_pmu->iidr);
+}
+
+static umode_t smmu_pmu_identifier_attr_visible(struct kobject *kobj,
+ struct attribute *attr,
+ int n)
+{
+ struct device *dev = kobj_to_dev(kobj);
+ struct smmu_pmu *smmu_pmu = to_smmu_pmu(dev_get_drvdata(dev));
+
+ if (!smmu_pmu->iidr)
+ return 0;
+ return attr->mode;
+}
+
+static struct device_attribute smmu_pmu_identifier_attr =
+ __ATTR(identifier, 0444, smmu_pmu_identifier_attr_show, NULL);
+
+static struct attribute *smmu_pmu_identifier_attrs[] = {
+ &smmu_pmu_identifier_attr.attr,
+ NULL
+};
+
+static struct attribute_group smmu_pmu_identifier_group = {
+ .attrs = smmu_pmu_identifier_attrs,
+ .is_visible = smmu_pmu_identifier_attr_visible,
+};
+
/* Formats */
PMU_FORMAT_ATTR(event, "config:0-15");
PMU_FORMAT_ATTR(filter_stream_id, "config1:0-31");
@@ -575,6 +611,7 @@ static const struct attribute_group *smmu_pmu_attr_grps[] = {
&smmu_pmu_cpumask_group,
&smmu_pmu_events_group,
&smmu_pmu_format_group,
+ &smmu_pmu_identifier_group,
NULL
};
@@ -795,6 +832,8 @@ static int smmu_pmu_probe(struct platform_device *pdev)
return err;
}
+ smmu_pmu->iidr = readl_relaxed(smmu_pmu->reg_base + SMMU_PMCG_IIDR);
+
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "smmuv3_pmcg_%llx",
(res_0->start) >> SMMU_PMCG_PA_SHIFT);
if (!name) {
--
2.26.2
next prev parent reply other threads:[~2020-10-08 9:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 9:26 [PATCH v2 0/4] perf drivers: Add sysfs identifier file John Garry
2020-10-08 9:26 ` [PATCH v2 1/4] drivers/perf: hisi: Add identifier sysfs file John Garry
2020-10-08 9:26 ` [PATCH v2 2/4] bindings/perf/imx-ddr: update compatible string John Garry
2020-10-12 9:58 ` Joakim Zhang
2020-10-08 9:26 ` [PATCH v2 3/4] perf/imx_ddr: Add system PMU identifier for userspace John Garry
2020-10-08 9:26 ` John Garry [this message]
2020-11-06 13:36 ` [PATCH v2 0/4] perf drivers: Add sysfs identifier file John Garry
2020-11-25 15:44 ` Will Deacon
2020-11-25 16:00 ` John Garry
2020-11-26 1:35 ` Joakim Zhang
2020-11-26 11:35 ` John Garry
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=1602149181-237415-5-git-send-email-john.garry@huawei.com \
--to=john.garry@huawei.com \
--cc=Frank.li@nxp.com \
--cc=acme@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=irogers@google.com \
--cc=jolsa@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=qiangqing.zhang@nxp.com \
--cc=robh+dt@kernel.org \
--cc=will@kernel.org \
--cc=zhangshaokun@hisilicon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).