From: Xie XiuQi <xiexiuqi(a)huawei.com>
commit 51721fdf840e9158f567b742b882294153472a97 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 | 40 +++++++-------------------
arch/arm64/kernel/mpam_mon.c | 8 ------
3 files changed, 15 insertions(+), 38 deletions(-)
diff --git a/arch/arm64/include/asm/mpam_resource.h
b/arch/arm64/include/asm/mpam_resource.h
index 0b442cb96171..4150d706090e 100644
--- a/arch/arm64/include/asm/mpam_resource.h
+++ b/arch/arm64/include/asm/mpam_resource.h
@@ -54,6 +54,11 @@
#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)
+#define MPAMF_IDR_HAS_CCAP_PART(v) ((v) & HAS_CCAP_PART)
+#define MPAMF_IDR_HAS_CPOR_PART(v) ((v) & HAS_CPOR_PART)
+#define MPAMF_IDR_HAS_MBW_PART(v) ((v) & HAS_MBW_PART)
+#define MPAMF_IDR_HAS_MSMON(v) ((v) & HAS_MSMON)
+
/* MPAMF_x_IDR */
#define NUM_MON_MASK (BIT(16) - 1)
#define MPAMF_IDR_NUM_MON(v) ((v) & NUM_MON_MASK)
diff --git a/arch/arm64/kernel/mpam.c b/arch/arm64/kernel/mpam.c
index 3884f1320084..6383c7d60135 100644
--- a/arch/arm64/kernel/mpam.c
+++ b/arch/arm64/kernel/mpam.c
@@ -400,35 +400,6 @@ static __init void mpam_init_padding(void)
}
}
-static __init bool get_rdt_alloc_resources(void)
-{
- bool ret = true;
-
- return ret;
-}
-
-static __init bool get_rdt_mon_resources(void)
-{
- bool ret = true;
-
- mpam_get_mon_config(&resctrl_resources_all[MPAM_RESOURCE_CACHE]);
- mpam_get_mon_config(&resctrl_resources_all[MPAM_RESOURCE_MC]);
- return ret;
-}
-
-static __init bool get_resctrl_resources(void)
-{
- if (!cpus_have_const_cap(ARM64_HAS_MPAM)) {
- pr_info("This cpu don't support MPAM feature: pfr0: %016llx\n",
read_sysreg_s(SYS_ID_AA64PFR0_EL1));
- return false;
- }
-
- rdt_alloc_capable = get_rdt_alloc_resources();
- rdt_mon_capable = get_rdt_mon_resources();
-
- return (rdt_mon_capable || rdt_alloc_capable);
-}
-
void post_resctrl_mount(void)
{
if (rdt_alloc_capable)
@@ -1233,10 +1204,19 @@ static void mpam_domains_init(struct resctrl_resource *r)
rr->num_partid = MPAMF_IDR_PARTID_MAX_GET(val);
rr->num_pmg = MPAMF_IDR_PMG_MAX_GET(val);
+ r->mon_capable = MPAMF_IDR_HAS_MSMON(val);
+ r->mon_enabled = MPAMF_IDR_HAS_MSMON(val);
+
if (r->rid == MPAM_RESOURCE_CACHE) {
+ r->alloc_capable = MPAMF_IDR_HAS_CPOR_PART(val);
+ r->alloc_enabled = MPAMF_IDR_HAS_CPOR_PART(val);
+
val = mpam_readl(d->base + MPAMF_CSUMON_IDR);
rr->num_mon = MPAMF_IDR_NUM_MON(val);
} else if (r->rid == MPAM_RESOURCE_MC) {
+ r->alloc_capable = MPAMF_IDR_HAS_MBW_PART(val);
+ r->alloc_enabled = MPAMF_IDR_HAS_MBW_PART(val);
+
val = mpam_readl(d->base + MPAMF_MBWUMON_IDR);
rr->num_mon = MPAMF_IDR_NUM_MON(val);
}
@@ -1273,7 +1253,7 @@ static int __init mpam_late_init(void)
struct resctrl_resource *r;
int state, ret;
- if (!get_resctrl_resources())
+ if (!cpus_have_const_cap(ARM64_HAS_MPAM))
return -ENODEV;
mpam_init_padding();
diff --git a/arch/arm64/kernel/mpam_mon.c b/arch/arm64/kernel/mpam_mon.c
index 4e5f64fda50a..9bc081635e93 100644
--- a/arch/arm64/kernel/mpam_mon.c
+++ b/arch/arm64/kernel/mpam_mon.c
@@ -121,11 +121,3 @@ void free_rmid(u32 pmg)
{
free_pmg(pmg);
}
-
-int mpam_get_mon_config(struct resctrl_resource *r)
-{
- r->mon_capable = true;
- r->mon_enabled = true;
-
- return 0;
-}
--
2.31.0