mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arm_mpam: Fix software reset values of MPAMCFG_PRI
@ 2026-05-15  8:58 Ben Horgan
  2026-07-16 16:47 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Horgan @ 2026-05-15  8:58 UTC (permalink / raw)
  To: ben.horgan
  Cc: james.morse, reinette.chatre, fenghuay, linux-kernel,
	catalin.marinas, linux-arm-kernel

Priority partitioning is not supported other than to set the per-PARTID
defaults in MPAMCFG_PRI, INTPRI and DSPRI, to the highest priority. When 0
is the lowest priority, all ones is the highest priority. However, these
values are calculated with an extra higher bit set.

Luckily, there is still no chance of setting functional bits incorrectly.
When the priority widths are maximal, this is ensured as the fields have
width 16 and a u16 holds the value for each field. When the widths are
smaller, the higher order bits beyond the advertised widths,
MPAMF_PRI_IDR.DSPRI_WD and MPAMF_PRI_IDR.INTPRI_WD, in the priority fields
INTPRI and DSPRI are not used to calculate the priority.  It is not
specified whether these higher order bits are RAZ/WI or Res0 and so it is
desirable not to set them to avoid the chance of misleading reads.

Correct the priority reset values.

Fixes: 880df85d8673 ("arm_mpam: Probe and reset the rest of the features")
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
---
 drivers/resctrl/mpam_devices.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 41b14344b16f..a627dc2c53de 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -1539,12 +1539,9 @@ static u16 mpam_wa_t241_calc_min_from_max(struct mpam_props *props,
 static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
 				      struct mpam_config *cfg)
 {
-	u32 pri_val = 0;
 	u16 cmax = MPAMCFG_CMAX_CMAX;
 	struct mpam_msc *msc = ris->vmsc->msc;
 	struct mpam_props *rprops = &ris->props;
-	u16 dspri = GENMASK(rprops->dspri_wd, 0);
-	u16 intpri = GENMASK(rprops->intpri_wd, 0);
 
 	mutex_lock(&msc->part_sel_lock);
 	__mpam_part_sel(ris->ris_idx, partid, msc);
@@ -1609,16 +1606,25 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid,
 
 	if (mpam_has_feature(mpam_feat_intpri_part, rprops) ||
 	    mpam_has_feature(mpam_feat_dspri_part, rprops)) {
-		/* aces high? */
-		if (!mpam_has_feature(mpam_feat_intpri_part_0_low, rprops))
-			intpri = 0;
-		if (!mpam_has_feature(mpam_feat_dspri_part_0_low, rprops))
-			dspri = 0;
+		u32 pri_val = 0;
+
+		if (mpam_has_feature(mpam_feat_intpri_part, rprops)) {
+			u16 intpri = GENMASK(rprops->intpri_wd - 1, 0);
+
+			/* aces high? */
+			if (!mpam_has_feature(mpam_feat_intpri_part_0_low, rprops))
+				intpri = 0;
 
-		if (mpam_has_feature(mpam_feat_intpri_part, rprops))
 			pri_val |= FIELD_PREP(MPAMCFG_PRI_INTPRI, intpri);
-		if (mpam_has_feature(mpam_feat_dspri_part, rprops))
+		}
+		if (mpam_has_feature(mpam_feat_dspri_part, rprops)) {
+			u16 dspri = GENMASK(rprops->dspri_wd - 1, 0);
+
+			if (!mpam_has_feature(mpam_feat_dspri_part_0_low, rprops))
+				dspri = 0;
+
 			pri_val |= FIELD_PREP(MPAMCFG_PRI_DSPRI, dspri);
+		}
 
 		mpam_write_partsel_reg(msc, PRI, pri_val);
 	}
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] arm_mpam: Fix software reset values of MPAMCFG_PRI
  2026-05-15  8:58 [PATCH] arm_mpam: Fix software reset values of MPAMCFG_PRI Ben Horgan
@ 2026-07-16 16:47 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2026-07-16 16:47 UTC (permalink / raw)
  To: Ben Horgan
  Cc: catalin.marinas, kernel-team, Will Deacon, james.morse,
	reinette.chatre, fenghuay, linux-kernel, linux-arm-kernel

On Fri, 15 May 2026 09:58:25 +0100, Ben Horgan wrote:
> Priority partitioning is not supported other than to set the per-PARTID
> defaults in MPAMCFG_PRI, INTPRI and DSPRI, to the highest priority. When 0
> is the lowest priority, all ones is the highest priority. However, these
> values are calculated with an extra higher bit set.
> 
> Luckily, there is still no chance of setting functional bits incorrectly.
> When the priority widths are maximal, this is ensured as the fields have
> width 16 and a u16 holds the value for each field. When the widths are
> smaller, the higher order bits beyond the advertised widths,
> MPAMF_PRI_IDR.DSPRI_WD and MPAMF_PRI_IDR.INTPRI_WD, in the priority fields
> INTPRI and DSPRI are not used to calculate the priority.  It is not
> specified whether these higher order bits are RAZ/WI or Res0 and so it is
> desirable not to set them to avoid the chance of misleading reads.
> 
> [...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm_mpam: Fix software reset values of MPAMCFG_PRI
      https://git.kernel.org/arm64/c/9469764292e0

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-16 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-15  8:58 [PATCH] arm_mpam: Fix software reset values of MPAMCFG_PRI Ben Horgan
2026-07-16 16:47 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®