Commit 2d9bc8aa authored by Wang ShaoBo's avatar Wang ShaoBo Committed by Zheng Zengkai
Browse files

arm64/mpam: Store intpri and dspri for mpam device reset



hulk inclusion
category: feature
feature: ARM MPAM support
bugzilla: 48265
CVE: NA

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

Register MPAMCFG_PRI's default value is also used for software default
usage after probing resources, two fields hwdef_intpri and hwdef_dspri are
placed into mpam_device structure to store the default priority setting.

Signed-off-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
Reviewed-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent eb6ed2c7
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -134,7 +134,10 @@
 * MPAMCFG_MBW_MAX SET - temp Hard code
 */
#define MPAMCFG_PRI_DSPRI_SHIFT			16
#define MPAMCFG_PRI_GET(r)  ((r & GENMASK(15, 0)) | (r & GENMASK(31, 16)) >> 16)
#define MPAMCFG_INTPRI_GET(r)  (r & GENMASK(15, 0))
#define MPAMCFG_DSPRI_GET(r)   ((r & GENMASK(31, 16)) >> 16)
/* Always same if both supported */
#define MPAMCFG_PRI_GET(r)     (MPAMCFG_DSPRI_GET(r) | MPAMCFG_INTPRI_GET(r))

/* MPAMF_PRI_IDR - MPAM features priority partitioning ID register */
#define MPAMF_PRI_IDR_HAS_INTPRI        BIT(0)
+16 −11
Original line number Diff line number Diff line
@@ -206,26 +206,37 @@ static int mpam_device_probe(struct mpam_device *dev)
	/* Priority partitioning */
	if (MPAMF_IDR_HAS_PRI_PART(hwfeatures)) {
		u32 pri_features = mpam_read_reg(dev, MPAMF_PRI_IDR);
		u32 hwdef_pri = mpam_read_reg(dev, MPAMCFG_PRI);

		pr_debug("probe: probed PRI_PART\n");

		dev->intpri_wd = (pri_features & MPAMF_PRI_IDR_INTPRI_WD) >>
				MPAMF_PRI_IDR_INTPRI_WD_SHIFT;
		if (dev->intpri_wd && (pri_features &
				MPAMF_PRI_IDR_HAS_INTPRI)) {
		if (dev->intpri_wd && (pri_features & MPAMF_PRI_IDR_HAS_INTPRI)) {
			mpam_set_feature(mpam_feat_intpri_part, &dev->features);
			dev->hwdef_intpri = MPAMCFG_INTPRI_GET(hwdef_pri);
			if (pri_features & MPAMF_PRI_IDR_INTPRI_0_IS_LOW)
				mpam_set_feature(mpam_feat_intpri_part_0_low,
					&dev->features);
			else
				/* keep higher value higher priority */
				dev->hwdef_intpri = GENMASK(dev->intpri_wd - 1, 0) &
					~dev->hwdef_intpri;

		}

		dev->dspri_wd = (pri_features & MPAMF_PRI_IDR_DSPRI_WD) >>
				MPAMF_PRI_IDR_DSPRI_WD_SHIFT;
		if (dev->dspri_wd && (pri_features & MPAMF_PRI_IDR_HAS_DSPRI)) {
			mpam_set_feature(mpam_feat_dspri_part, &dev->features);
			dev->hwdef_dspri = MPAMCFG_DSPRI_GET(hwdef_pri);
			if (pri_features & MPAMF_PRI_IDR_DSPRI_0_IS_LOW)
				mpam_set_feature(mpam_feat_dspri_part_0_low,
					&dev->features);
			else
				/* keep higher value higher priority */
				dev->hwdef_dspri = GENMASK(dev->dspri_wd - 1, 0) &
					~dev->hwdef_dspri;
		}
	}

@@ -723,8 +734,7 @@ static void mpam_reset_device_bitmap(struct mpam_device *dev, u16 reg, u16 wd)
static void mpam_reset_device_config(struct mpam_component *comp,
				struct mpam_device *dev, u32 partid)
{
	u16 intpri = GENMASK(dev->intpri_wd, 0);
	u16 dspri = GENMASK(dev->dspri_wd, 0);
	u16 intpri, dspri;
	u32 pri_val = 0;
	u32 mbw_max;

@@ -751,13 +761,8 @@ static void mpam_reset_device_config(struct mpam_component *comp,

	if (mpam_has_feature(mpam_feat_intpri_part, dev->features) ||
		mpam_has_feature(mpam_feat_dspri_part, dev->features)) {
		/* aces high? */
		if (!mpam_has_feature(mpam_feat_intpri_part_0_low,
				dev->features))
			intpri = 0;
		if (!mpam_has_feature(mpam_feat_dspri_part_0_low,
				dev->features))
			dspri = 0;
		intpri = dev->hwdef_intpri;
		dspri = dev->hwdef_dspri;

		if (mpam_has_feature(mpam_feat_intpri_part, dev->features))
			pri_val |= intpri;
+4 −0
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@ struct mpam_device {
	u16         num_pmg;
	u16         num_csu_mon;
	u16         num_mbwu_mon;

	/* for reset device MPAMCFG_PRI */
	u16         hwdef_intpri;
	u16         hwdef_dspri;
};

/*