提交 b86c182a 编写于 作者: W Wang ShaoBo 提交者: Yang Yingliang

arm64/mpam: Implement intpartid narrowing process

hulk inclusion
category: feature
bugzilla: 34278
CVE: NA

-------------------------------------------------

According to Arm MPAM spec definition, register MPAMCFG_PART_SEL's high
16 bit should be set to 0 and MPAMCFG_INTPARTID's high 16 bit should be
set to 1 when establishing intpartid association, and we should use
intpartid in MPAMCFG_PART_SEL instead of reqpartid as long as intpartid
narrowing is implemented.
Signed-off-by: NWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: NCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 94e9729e
...@@ -91,6 +91,10 @@ ...@@ -91,6 +91,10 @@
#define MSMON_CFG_CSU_TYPE 0x43 #define MSMON_CFG_CSU_TYPE 0x43
#define MSMON_CFG_MBWU_TYPE 0x42 #define MSMON_CFG_MBWU_TYPE 0x42
/*
* Set MPAMCFG_INTPARTID internal bit
*/
#define MPAMCFG_INTPARTID_INTERNAL BIT(16)
/* /*
* Set MPAMCFG_PART_SEL internal bit * Set MPAMCFG_PART_SEL internal bit
*/ */
......
...@@ -1086,16 +1086,29 @@ static int mpam_device_frob_mon(struct mpam_device *dev, ...@@ -1086,16 +1086,29 @@ static int mpam_device_frob_mon(struct mpam_device *dev,
return 0; return 0;
} }
static int mpam_device_narrow_map(struct mpam_device *dev, u32 partid, static void mpam_device_narrow_map(struct mpam_device *dev, u32 partid,
u32 intpartid) u32 intpartid)
{ {
return 0; int cur_intpartid;
lockdep_assert_held(&dev->lock);
mpam_write_reg(dev, MPAMCFG_PART_SEL, partid);
wmb(); /* subsequent writes must be applied to our new partid */
cur_intpartid = mpam_read_reg(dev, MPAMCFG_INTPARTID);
/* write association, this need set 16 bit to 1 */
intpartid = intpartid | MPAMCFG_INTPARTID_INTERNAL;
/* reqpartid has already been associated to this intpartid */
if (cur_intpartid == intpartid)
return;
mpam_write_reg(dev, MPAMCFG_INTPARTID, intpartid);
} }
static int mpam_device_config(struct mpam_device *dev, u32 partid, static int mpam_device_config(struct mpam_device *dev, u32 partid,
struct mpam_config *cfg) struct mpam_config *cfg)
{ {
int ret;
u16 cmax = GENMASK(dev->cmax_wd, 0); u16 cmax = GENMASK(dev->cmax_wd, 0);
u32 pri_val = 0; u32 pri_val = 0;
u16 intpri, dspri, max_intpri, max_dspri; u16 intpri, dspri, max_intpri, max_dspri;
...@@ -1111,16 +1124,11 @@ static int mpam_device_config(struct mpam_device *dev, u32 partid, ...@@ -1111,16 +1124,11 @@ static int mpam_device_config(struct mpam_device *dev, u32 partid,
* upstream(resctrl) keep this order * upstream(resctrl) keep this order
*/ */
if (mpam_has_feature(mpam_feat_part_nrw, dev->features)) { if (mpam_has_feature(mpam_feat_part_nrw, dev->features)) {
if (cfg && mpam_has_feature(mpam_feat_part_nrw, cfg->valid)) { if (cfg && mpam_has_feature(mpam_feat_part_nrw, cfg->valid))
ret = mpam_device_narrow_map(dev, partid, mpam_device_narrow_map(dev, partid, cfg->intpartid);
cfg->intpartid); /* intpartid success, set 16 bit to 1*/
if (ret)
goto out;
partid = PART_SEL_SET_INTERNAL(cfg->intpartid);
} else {
partid = PART_SEL_SET_INTERNAL(cfg->intpartid); partid = PART_SEL_SET_INTERNAL(cfg->intpartid);
} }
}
mpam_write_reg(dev, MPAMCFG_PART_SEL, partid); mpam_write_reg(dev, MPAMCFG_PART_SEL, partid);
wmb(); /* subsequent writes must be applied to our new partid */ wmb(); /* subsequent writes must be applied to our new partid */
...@@ -1195,8 +1203,7 @@ static int mpam_device_config(struct mpam_device *dev, u32 partid, ...@@ -1195,8 +1203,7 @@ static int mpam_device_config(struct mpam_device *dev, u32 partid,
*/ */
mb(); mb();
out: return 0;
return ret;
} }
static void mpam_component_device_sync(void *__ctx) static void mpam_component_device_sync(void *__ctx)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册