From: Xie XiuQi <xiexiuqi(a)huawei.com>
commit 71a5096363780cb9d6bec6fda2d387e37219a4f9 openEuler-1.0
hulk inclusion
category: feature
bugzilla: 5510
CVE: NA
Signed-off-by: Xie XiuQi <xiexiuqi(a)huawei.com>
Reviewed-by: Hanjun Guo <guohanjun(a)huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang(a)huawei.com>
Signed-off-by: Xin Hao <haoxing990(a)gmail.com>
---
arch/arm64/include/asm/mpam_resource.h | 5 +++
arch/arm64/kernel/mpam.c | 44 ++++++++++++++++++++++++--
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/include/asm/mpam_resource.h
b/arch/arm64/include/asm/mpam_resource.h
index b634209f21a5..efc660974d69 100644
--- a/arch/arm64/include/asm/mpam_resource.h
+++ b/arch/arm64/include/asm/mpam_resource.h
@@ -49,6 +49,11 @@
#define HAS_MSMON BIT(30)
/* MPAMF_IDR */
+#define MPAMF_IDR_PMG_MAX_MASK ((BIT(8) - 1) << 16)
+#define MPAMF_IDR_PARTID_MAX_MASK (BIT(16) - 1)
+#define MPAMF_IDR_PMG_MAX_GET(v) ((v & MPAMF_IDR_PMG_MAX_MASK) >> 16)
+#define MPAMF_IDR_PARTID_MAX_GET(v) (v & MPAMF_IDR_PARTID_MAX_MASK)
+
/* TODO */
#define CPBM_WD_MASK 0xFFFF
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
index adce5d3508e1..542fd7fe8ce6 100644
--- a/arch/arm64/kernel/mpam.c
+++ b/arch/arm64/kernel/mpam.c
@@ -691,8 +691,30 @@ int cpus_ctrl_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
return 0;
}
+static int resctrl_num_partid_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v)
+{
+ struct resctrl_resource *r = of->kn->parent->priv;
+ struct raw_resctrl_resource *rr = (struct raw_resctrl_resource *)r->res;
+
+ seq_printf(seq, "%d\n", rr->num_partid);
+
+ return 0;
+}
+
+static int resctrl_num_pmg_show(struct kernfs_open_file *of,
+ struct seq_file *seq, void *v)
+{
+ struct resctrl_resource *r = of->kn->parent->priv;
+ struct raw_resctrl_resource *rr = (struct raw_resctrl_resource *)r->res;
+
+ seq_printf(seq, "%d\n", rr->num_pmg);
+
+ return 0;
+}
+
int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
- cpumask_var_t tmpmask)
+ cpumask_var_t tmpmask)
{
return 0;
}
@@ -908,6 +930,20 @@ static int resctrl_group_tasks_show(struct kernfs_open_file *of,
/* rdtgroup information files for one cache resource. */
static struct rftype res_specific_files[] = {
+ {
+ .name = "num_partids",
+ .mode = 0444,
+ .kf_ops = &resctrl_group_kf_single_ops,
+ .seq_show = resctrl_num_partid_show,
+ .fflags = RF_CTRL_INFO,
+ },
+ {
+ .name = "num_pmgs",
+ .mode = 0444,
+ .kf_ops = &resctrl_group_kf_single_ops,
+ .seq_show = resctrl_num_pmg_show,
+ .fflags = RF_MON_INFO,
+ },
{
.name = "last_cmd_status",
.mode = 0444,
@@ -983,6 +1019,7 @@ static void mpam_domains_init(struct resctrl_resource *r)
struct list_head *add_pos = NULL, *l;
struct rdt_domain *d;
struct raw_resctrl_resource *rr = (struct raw_resctrl_resource *)r->res;
+ u32 val;
char *types[] = {"MPAM_RESOURCE_SMMU", "MPAM_RESOURCE_CACHE",
"MPAM_RESOURCE_MC"};
@@ -1015,7 +1052,10 @@ static void mpam_domains_init(struct resctrl_resource *r)
d->base = n->base;
cpumask_copy(&d->cpu_mask, &n->cpu_mask);
rr->default_ctrl = n->default_ctrl;
- rr->num_partid = 32;
+
+ val = mpam_readl(d->base + MPAMF_IDR);
+ rr->num_partid = MPAMF_IDR_PARTID_MAX_GET(val);
+ rr->num_pmg = MPAMF_IDR_PMG_MAX_GET(val);
d->cpus_list = n->cpus_list;
--
2.31.0