Skip to contentSkip to conversation

arm_mpam: Fix several minor issues

RFC PATCH In review Zeng Heng 2 participants 7 messages Jul 22, 2024 – Jan 4, 2025 arm64 platform drivers

lore
Share & tools
lore

Zeng Heng

author
#0 lore raw

cover arm_mpam: Fix several minor issues

After completing the necessary software adaptation for the local chipset, the MPAM function is successfully enabled. After related tests are completed, some issues were discovered and here attempt to fix them.

Hope to get some suggestions for modifications, if I miss any rules should be followed, please let me know.

Zeng Heng (4):
arm_mpam: Correct MBA granularity calculation
arm_mpam: Fix the range calculation of the implemented bits
arm_mpam: Correct the judgment condition of the CMAX feature
arm_mpam: Fix typo about mbw_min controls

 drivers/platform/arm64/mpam/mpam_devices.c  | 8 +++++---
 drivers/platform/arm64/mpam/mpam_internal.h | 1 +
 drivers/platform/arm64/mpam/mpam_resctrl.c  | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)

--
2.25.1

author
#1 lore raw

RFC PATCH 1/4 arm_mpam: Correct MBA granularity calculation

Correct MBA granularity calculation function. As said in the comments, "bwa_wd is the number of bits implemented in the 0.xxx fixed point fraction".

Fixes 867471fefd5c ("SPLIT untested: arm_mpam: resctrl: Add support for MB resource")
---
 drivers/platform/arm64/mpam/mpam_resctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/arm64/mpam/mpam_resctrl.c +1 -1
index 2fa732a42d4f..a217f2e1f350 100644
@@ -523,7 +523,7 @@ static u32 get_mba_granularity(struct mpam_props *cprops)
 		 * bwa_wd is the number of bits implemented in the 0.xxx
 		 * fixed point fraction. 1 bit is 50%, 2 is 25% etc.
 		 */
-		return MAX_MBA_BW / (cprops->bwa_wd + 1);
+		return MAX_MBA_BW / (1 << cprops->bwa_wd);
 	}
 
 	return 0;
Signature · 1 line
2.25.1
author
#2 lore raw

RFC PATCH 2/4 arm_mpam: Fix the range calculation of the implemented bits

In reply to Zeng Heng

The implemented bits of the MAX field in the MPAMCFG_{MBW_MAX, CMAX} register are always to the left of the field, so the validated range should be like [15, 15 - width + 1].

Fixes 867471fefd5c ("SPLIT untested: arm_mpam: resctrl: Add support for MB resource")
---
 drivers/platform/arm64/mpam/mpam_resctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/arm64/mpam/mpam_resctrl.c +1 -1
index a217f2e1f350..e87fca6fc5fd 100644
@@ -585,7 +585,7 @@ static u16 percent_to_mbw_max(u8 pc, struct mpam_props *cprops)
 			break;
 	}
 
-	value &= GENMASK(15, 15 - cprops->bwa_wd);
+	value &= GENMASK(15, 15 - cprops->bwa_wd + 1);
 
 	return value;
 }
Signature · 1 line
2.25.1
author
#3 lore raw

RFC PATCH 3/4 arm_mpam: Correct the judgment condition of the CMAX feature

In reply to Zeng Heng

According to Arm Architecture MPAM Reference Manual (version DDI 0598D.b), to check whether hardware supports the CMAX feature or not, not only needs to check the CMAX_WD field of the MPAMF_CCAP_IDR register, but also needs to check the NO_CMAX field.

Fixes a275036b6767 ("arm_mpam: Probe and reset the rest of the features")
---
 drivers/platform/arm64/mpam/mpam_devices.c  | 6 ++++--
 drivers/platform/arm64/mpam/mpam_internal.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/platform/arm64/mpam/mpam_devices.c +4 -2
index acb91352c524..9acac8a22573 100644
@@ -779,8 +779,10 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
 		u32 ccap_features = mpam_read_partsel_reg(msc, CCAP_IDR);
 
 		props->cmax_wd = FIELD_GET(MPAMF_CCAP_IDR_CMAX_WD, ccap_features);
-		if (props->cmax_wd)
-			mpam_set_feature(mpam_feat_ccap_part, props);
+		if (props->cmax_wd) {
+			if (!FIELD_GET(MPAMF_CCAP_IDR_NO_CMAX, ccap_features))
+				mpam_set_feature(mpam_feat_ccap_part, props);
+		}
 	}
 
 	/* Cache Portion partitioning */
drivers/platform/arm64/mpam/mpam_internal.h +1 -0
index 61aea729aa73..0e714ce7fa96 100644
@@ -450,6 +450,7 @@ void mpam_resctrl_exit(void);
 
 /* MPAMF_CCAP_IDR - MPAM features cache capacity partitioning ID register */
 #define MPAMF_CCAP_IDR_CMAX_WD                  GENMASK(5, 0)
+#define MPAMF_CCAP_IDR_NO_CMAX                  BIT(30)
 
 /* MPAMF_MBW_IDR - MPAM features memory bandwidth partitioning ID register */
 #define MPAMF_MBW_IDR_BWA_WD            GENMASK(5, 0)
Signature · 1 line
2.25.1
author
#4 lore raw

RFC PATCH 4/4 arm_mpam: Fix typo about mbw_min controls

In reply to Zeng Heng

Correct the judgment condition about mbw_min default value.

Fixes 099f47353bc5 ("arm_mpam: Generate a configuration for min controls")
---
 drivers/platform/arm64/mpam/mpam_devices.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/arm64/mpam/mpam_devices.c +1 -1
index 9acac8a22573..64a1f1767a68 100644
@@ -1483,7 +1483,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
 	}
 
 	if (mpam_has_feature(mpam_feat_mbw_min, rprops)) {
-		if (mpam_has_feature(mpam_feat_mbw_max, cfg))
+		if (mpam_has_feature(mpam_feat_mbw_min, cfg))
 			mpam_write_partsel_reg(msc, MBW_MIN, cfg->mbw_min);
 		else
 			mpam_write_partsel_reg(msc, MBW_MIN, 0);
Signature · 1 line
2.25.1
#5 lore raw
In reply to Zeng Heng

Hello!

Quoted 6 lines · Zeng Heng

After completing the necessary software adaptation for the local chipset, the MPAM function is successfully enabled. After related tests are completed, some issues were discovered and here attempt to fix them.

Hope to get some suggestions for modifications, if I miss any rules should be followed, please let me know.

Sorry for the delay following these up - they should all be fixed in the newer versions of the tree. I've added 'CC' tags to the patches you fixed here.

Thanks,

James

author
#6 lore raw
Quoted 10 lines · James Morse

Hello!

Quoted 6 lines · Zeng Heng

After completing the necessary software adaptation for the local chipset, the MPAM function is successfully enabled. After related tests are completed, some issues were discovered and here attempt to fix them.

Hope to get some suggestions for modifications, if I miss any rules should be followed, please let me know.

Quoted 8 lines

Sorry for the delay following these up - they should all be fixed in the newer versions of the tree. I've added 'CC' tags to the patches you fixed here.

Thanks,

James

Thanks for your reply!

I have found they are all fixed in the latest branch already.

For the MPAM driver, I have updated the Narrow-PARTID feature patchset. Please feel free to provide any comments or suggestions, if you were available.

Here is the link to the v4 of the Narrow-PARTID feature:
https://lore.kernel.org/all/[email protected]/

Thank you in advance.

Greetings for new year,
Zeng Heng