Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version
@ 2026-05-08 16:23 James Morse
  2026-05-08 16:23 ` [PATCH v3 1/4] arm_mpam: Fix false positive assert failure during mpam_disable() James Morse
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: James Morse @ 2026-05-08 16:23 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zengheng4
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, ben.horgan, mrigendra.chaubey, fenghuay,
	ahmed.genidi

This is a v3 of Zeng's series to add support for MPAM v0.1.
Included are the changes Ben and I suggested, and a couple of bugs found while
testing it.

I've put the bug fixes first as you can hit these with mainline.
The patches for v0.1 enable MPAM on those platforms as this extra ID register
was missed.

Based on v7.1-rc2, and can be retrieved from 
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/arch_v0.1/v3


Thanks,

James

v2: https://patch.msgid.link/20260203095406.6437-1-zengheng4@huawei.com
v1: https://lore.kernel.org/all/20260104133434.1887677-1-zengheng4@huawei.com/

James Morse (2):
  arm_mpam: Fix false positive assert failure during mpam_disable()
  arm_mpam: Check whether the config array is allocated before
    destroying it

Zeng Heng (2):
  arm64: cpufeature: Add support for the MPAM v0.1 architecture version
  arm_mpam: Update architecture version check for MPAM MSC

 arch/arm64/include/asm/cpufeature.h |  7 ++++++
 arch/arm64/include/asm/el2_setup.h  |  4 +++-
 arch/arm64/kernel/cpufeature.c      | 15 ++++++++----
 drivers/resctrl/mpam_devices.c      | 36 +++++++++++++++++++++++++----
 drivers/resctrl/mpam_internal.h     |  1 +
 5 files changed, 53 insertions(+), 10 deletions(-)

-- 
2.53.0



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

* [PATCH v3 1/4] arm_mpam: Fix false positive assert failure during mpam_disable()
  2026-05-08 16:23 [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version James Morse
@ 2026-05-08 16:23 ` James Morse
  2026-05-08 16:23 ` [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it James Morse
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: James Morse @ 2026-05-08 16:23 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zengheng4
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, ben.horgan, mrigendra.chaubey, fenghuay,
	ahmed.genidi

mpam_assert_partid_sizes_fixed() is used to document that the caller
doesn't expect the discovered PARTID size to change while it is walking
a list sized by PARTID. Typically the MSC state is not written to until
all the MSC have been discovered and this value is set.

However, if discovering the MSC fails and schedules mpam_disable(),
then the MSC state is written to reset it. In this case the
discovered PARTID size may be become smaller - but only PARTID 0
will be used once resctrl_exit() has been called.

Skip the WARN_ON_ONCE() if mpam_disable_reason has been set.

Fixes: 3bd04fe7d807bb ("arm_mpam: Extend reset logic to allow devices to be reset at any time")
Signed-off-by: James Morse <james.morse@arm.com>
---
 drivers/resctrl/mpam_devices.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 41b14344b16f..bef5e9e9e844 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -164,11 +164,17 @@ static void mpam_free_garbage(void)
 /*
  * Once mpam is enabled, new requestors cannot further reduce the available
  * partid. Assert that the size is fixed, and new requestors will be turned
- * away.
+ * away. This is needed when walking over structures sized by PARTID.
+ *
+ * During mpam_disable() these structures are not fixed, but the MSC state
+ * is still reset using whatever sizes have been discovered so far. As only
+ * PARTID 0 will be used after mpam_disable(), any race would be benign.
+ * Skip the check if a mpam_disable_reason has been set.
  */
 static void mpam_assert_partid_sizes_fixed(void)
 {
-	WARN_ON_ONCE(!partid_max_published);
+	if (!mpam_disable_reason)
+		WARN_ON_ONCE(!partid_max_published);
 }
 
 static u32 __mpam_read_reg(struct mpam_msc *msc, u16 reg)
-- 
2.53.0



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

* [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it
  2026-05-08 16:23 [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version James Morse
  2026-05-08 16:23 ` [PATCH v3 1/4] arm_mpam: Fix false positive assert failure during mpam_disable() James Morse
@ 2026-05-08 16:23 ` James Morse
  2026-05-08 16:23 ` [PATCH v3 3/4] arm64: cpufeature: Add support for the MPAM v0.1 architecture version James Morse
  2026-05-08 16:23 ` [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC James Morse
  3 siblings, 0 replies; 7+ messages in thread
From: James Morse @ 2026-05-08 16:23 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zengheng4
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, ben.horgan, mrigendra.chaubey, fenghuay,
	ahmed.genidi

__destroy_component_cfg() is called to free the configuration array.
It uses the embedded 'garbage' structure, which means the array has
to be allocated.

If __destroy_component_cfg() is called from mpam_disable() before the
configuration was ever allocated, then a NULL pointer is dereferenced.

Check for this case and return early if the configuration is not
allocated.

__destroy_component_cfg() also frees the mbwu_state as this is allocated
by __allocate_component_cfg(). As the mbwu_state is allocated after
comp->cfg is set, and is also under mpam_list_lock, only the first
pointer needs checking.

Fixes: 3bd04fe7d807bb ("arm_mpam: Extend reset logic to allow devices to be reset any time")
Signed-off-by: James Morse <james.morse@arm.com>
---
 drivers/resctrl/mpam_devices.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index bef5e9e9e844..916d8fd45ed5 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2591,6 +2591,9 @@ static void __destroy_component_cfg(struct mpam_component *comp)
 
 	lockdep_assert_held(&mpam_list_lock);
 
+	if (!comp->cfg)
+		return;
+
 	add_to_garbage(comp->cfg);
 	list_for_each_entry(vmsc, &comp->vmsc, comp_list) {
 		msc = vmsc->msc;
-- 
2.53.0



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

* [PATCH v3 3/4] arm64: cpufeature: Add support for the MPAM v0.1 architecture version
  2026-05-08 16:23 [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version James Morse
  2026-05-08 16:23 ` [PATCH v3 1/4] arm_mpam: Fix false positive assert failure during mpam_disable() James Morse
  2026-05-08 16:23 ` [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it James Morse
@ 2026-05-08 16:23 ` James Morse
  2026-05-08 16:23 ` [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC James Morse
  3 siblings, 0 replies; 7+ messages in thread
From: James Morse @ 2026-05-08 16:23 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zengheng4
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, ben.horgan, mrigendra.chaubey, fenghuay,
	ahmed.genidi

From: Zeng Heng <zengheng4@huawei.com>

According to the MPAM spec [1], the supported architecture versions are
v1.0, v1.1 and v0.1. MPAM versions v0.1 and v1.1 are functionally
identical, but v0.1 additionally supports the FORCE_NS feature.

ID_AA64PR | ID_AA64PR | MPAM Extension | Notes
F0_EL1.   | F1_EL1.   | Architecture   |
MPAM      | MPAM_frac | version        |
---------------------------------------------------------------------------
0b0000    | 0b0001    | v0.1           | MPAM v0.1 is implemented.
          |           |                | MPAM v0.1 is the same as MPAM v1.1
          |           |                | with FORCE_NS which is
          |           |                | incompatible with MPAM v1.0.
---------------------------------------------------------------------------
0b0001    | 0b0000    | v1.0           | MPAM v1.0 is implemented.
---------------------------------------------------------------------------
0b0001    | 0b0001    | v1.1           | MPAM v1.1 is implemented.
          |           |                | MPAM v1.1 includes all features of
          |           |                | MPAM v1.0.
          |           |                | It must not include FORCE_NS.

FORCE_NS is a feature that operates in EL3 mode. Consequently, the current
Linux MPAM driver is also compatible with MPAM v0.1. To support v0.1, the
existing driver which only checks ID_AA64PFR0_EL1.MPAM for the major
version needs to examine ID_AA64PFR1_EL1.MPAM_frac for the minor version
as well.

[1] https://developer.arm.com/documentation/ddi0598/db/?lang=en

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: James Morse <james.morse@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
---
 arch/arm64/include/asm/cpufeature.h |  7 +++++++
 arch/arm64/include/asm/el2_setup.h  |  4 +++-
 arch/arm64/kernel/cpufeature.c      | 15 +++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index 4de51f8d92cb..a57870fa96db 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -620,6 +620,13 @@ static inline bool id_aa64pfr0_mpam(u64 pfr0)
 	return val > 0;
 }
 
+static inline bool id_aa64pfr1_mpamfrac(u64 pfr1)
+{
+	u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_EL1_MPAM_frac_SHIFT);
+
+	return val > 0;
+}
+
 static inline bool id_aa64pfr1_mte(u64 pfr1)
 {
 	u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_EL1_MTE_SHIFT);
diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h
index 587507a9980e..aa8ec9df8024 100644
--- a/arch/arm64/include/asm/el2_setup.h
+++ b/arch/arm64/include/asm/el2_setup.h
@@ -510,7 +510,9 @@
 #endif
 
 .macro finalise_el2_state
-	check_override id_aa64pfr0, ID_AA64PFR0_EL1_MPAM_SHIFT, .Linit_mpam_\@, .Lskip_mpam_\@, x1, x2
+	check_override id_aa64pfr0, ID_AA64PFR0_EL1_MPAM_SHIFT, .Linit_mpam_\@, .Lmpam_minor_\@, x1, x2
+.Lmpam_minor_\@:
+	check_override id_aa64pfr1, ID_AA64PFR1_EL1_MPAM_frac_SHIFT, .Linit_mpam_\@, .Lskip_mpam_\@, x1, x2
 
 .Linit_mpam_\@:
 	mov	x0, #MPAM2_EL2_EnMPAMSM_MASK
diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 6d53bb15cf7b..0a1d198b3995 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -1164,6 +1164,14 @@ static __init void detect_system_supports_pseudo_nmi(void)
 static inline void detect_system_supports_pseudo_nmi(void) { }
 #endif
 
+static bool detect_ftr_has_mpam(void)
+{
+	u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);
+	u64 pfr1 = read_sanitised_ftr_reg(SYS_ID_AA64PFR1_EL1);
+
+	return id_aa64pfr0_mpam(pfr0) || id_aa64pfr1_mpamfrac(pfr1);
+}
+
 void __init init_cpu_features(struct cpuinfo_arm64 *info)
 {
 	/* Before we start using the tables, make sure it is sorted */
@@ -1211,7 +1219,7 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
 		cpacr_restore(cpacr);
 	}
 
-	if (id_aa64pfr0_mpam(read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1))) {
+	if (detect_ftr_has_mpam()) {
 		info->reg_mpamidr = read_cpuid(MPAMIDR_EL1);
 		init_cpu_ftr_reg(SYS_MPAMIDR_EL1, info->reg_mpamidr);
 	}
@@ -1467,7 +1475,7 @@ void update_cpu_features(int cpu,
 		cpacr_restore(cpacr);
 	}
 
-	if (id_aa64pfr0_mpam(read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1))) {
+	if (detect_ftr_has_mpam()) {
 		info->reg_mpamidr = read_cpuid(MPAMIDR_EL1);
 		taint |= check_update_ftr_reg(SYS_MPAMIDR_EL1, cpu,
 					info->reg_mpamidr, boot->reg_mpamidr);
@@ -2486,7 +2494,7 @@ cpucap_panic_on_conflict(const struct arm64_cpu_capabilities *cap)
 static bool
 test_has_mpam(const struct arm64_cpu_capabilities *entry, int scope)
 {
-	if (!has_cpuid_feature(entry, scope))
+	if (!detect_ftr_has_mpam())
 		return false;
 
 	/* Check firmware actually enabled MPAM on this cpu. */
@@ -3093,7 +3101,6 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
 		.capability = ARM64_MPAM,
 		.matches = test_has_mpam,
 		.cpu_enable = cpu_enable_mpam,
-		ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, MPAM, 1)
 	},
 	{
 		.desc = "Memory Partitioning And Monitoring Virtualisation",
-- 
2.53.0



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

* [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC
  2026-05-08 16:23 [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version James Morse
                   ` (2 preceding siblings ...)
  2026-05-08 16:23 ` [PATCH v3 3/4] arm64: cpufeature: Add support for the MPAM v0.1 architecture version James Morse
@ 2026-05-08 16:23 ` James Morse
  2026-05-08 16:35   ` Ben Horgan
  3 siblings, 1 reply; 7+ messages in thread
From: James Morse @ 2026-05-08 16:23 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, zengheng4
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, ben.horgan, mrigendra.chaubey, fenghuay,
	ahmed.genidi

From: Zeng Heng <zengheng4@huawei.com>

In addition to updating the CPU MPAM version check, the MPAM MSC version
check also need to be updated. mpam_msc_check_aidr() is added to check
the MSC AIDR register, ensuring that both the major and minor version
numbers fall within the supported range of the MPAM architecture version.

Signed-off-by: Zeng Heng <zengheng4@huawei.com>
[ morse: changed mpam_msc_check_aidr() to accept versions like v1.2 ]
Signed-off-by: James Morse <james.morse@arm.com>
---
 drivers/resctrl/mpam_devices.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 916d8fd45ed5..1771e9712ca2 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -224,6 +224,24 @@ static inline void _mpam_write_monsel_reg(struct mpam_msc *msc, u16 reg, u32 val
 
 #define mpam_write_monsel_reg(msc, reg, val)   _mpam_write_monsel_reg(msc, MSMON_##reg, val)
 
+static bool mpam_msc_check_aidr(struct mpam_msc *msc)
+{
+	u32 aidr = __mpam_read_reg(msc, MPAMF_AIDR);
+	u32 major = FIELD_GET(MPAMF_AIDR_ARCH_MAJOR_REV, aidr);
+	u32 minor = FIELD_GET(MPAMF_AIDR_ARCH_MINOR_REV, aidr);
+
+	/*
+	 * v0.0 and >v2.x aren't supported, but anything else should be backward
+	 * compatible to v0.1 or v1.0.
+	 */
+	if (!major && !minor)
+		return false;
+	if (major > 1)
+		return false;
+
+	return true;
+}
+
 static u64 mpam_msc_read_idr(struct mpam_msc *msc)
 {
 	u64 idr_high = 0, idr_low;
@@ -951,9 +969,8 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
 
 	lockdep_assert_held(&msc->probe_lock);
 
-	idr = __mpam_read_reg(msc, MPAMF_AIDR);
-	if ((idr & MPAMF_AIDR_ARCH_MAJOR_REV) != MPAM_ARCHITECTURE_V1) {
-		dev_err_once(dev, "MSC does not match MPAM architecture v1.x\n");
+	if (!mpam_msc_check_aidr(msc)) {
+		dev_err_once(dev, "MSC does not match architecture v1.x\n");
 		return -EIO;
 	}
 
-- 
2.53.0



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

* Re: [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC
  2026-05-08 16:23 ` [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC James Morse
@ 2026-05-08 16:35   ` Ben Horgan
  2026-05-09  6:26     ` Zeng Heng
  0 siblings, 1 reply; 7+ messages in thread
From: Ben Horgan @ 2026-05-08 16:35 UTC (permalink / raw)
  To: James Morse, linux-kernel, linux-arm-kernel, zengheng4
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, mrigendra.chaubey, fenghuay, ahmed.genidi

Hi James,

On 5/8/26 17:23, James Morse wrote:
> From: Zeng Heng <zengheng4@huawei.com>
> 
> In addition to updating the CPU MPAM version check, the MPAM MSC version
> check also need to be updated. mpam_msc_check_aidr() is added to check
> the MSC AIDR register, ensuring that both the major and minor version
> numbers fall within the supported range of the MPAM architecture version.
> 
> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
> [ morse: changed mpam_msc_check_aidr() to accept versions like v1.2 ]
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
>  drivers/resctrl/mpam_devices.c | 23 ++++++++++++++++++++---
>  1 file changed, 20 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 916d8fd45ed5..1771e9712ca2 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
> @@ -224,6 +224,24 @@ static inline void _mpam_write_monsel_reg(struct mpam_msc *msc, u16 reg, u32 val
>  
>  #define mpam_write_monsel_reg(msc, reg, val)   _mpam_write_monsel_reg(msc, MSMON_##reg, val)
>  
> +static bool mpam_msc_check_aidr(struct mpam_msc *msc)
> +{
> +	u32 aidr = __mpam_read_reg(msc, MPAMF_AIDR);
> +	u32 major = FIELD_GET(MPAMF_AIDR_ARCH_MAJOR_REV, aidr);
> +	u32 minor = FIELD_GET(MPAMF_AIDR_ARCH_MINOR_REV, aidr);
> +
> +	/*
> +	 * v0.0 and >v2.x aren't supported, but anything else should be backward
> +	 * compatible to v0.1 or v1.0.
> +	 */
> +	if (!major && !minor)
> +		return false;
> +	if (major > 1)
> +		return false;
> +
> +	return true;
> +}
> +
>  static u64 mpam_msc_read_idr(struct mpam_msc *msc)
>  {
>  	u64 idr_high = 0, idr_low;
> @@ -951,9 +969,8 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
>  
>  	lockdep_assert_held(&msc->probe_lock);
>  
> -	idr = __mpam_read_reg(msc, MPAMF_AIDR);
> -	if ((idr & MPAMF_AIDR_ARCH_MAJOR_REV) != MPAM_ARCHITECTURE_V1) {

nit: MPAM_ARCHITECTURE_V1 is now unused.

Reviewed-by: Ben Horgan <ben.horgan@arm.com>

Thanks,

Ben

> -		dev_err_once(dev, "MSC does not match MPAM architecture v1.x\n");
> +	if (!mpam_msc_check_aidr(msc)) {
> +		dev_err_once(dev, "MSC does not match architecture v1.x\n");
>  		return -EIO;
>  	}
>  



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

* Re: [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC
  2026-05-08 16:35   ` Ben Horgan
@ 2026-05-09  6:26     ` Zeng Heng
  0 siblings, 0 replies; 7+ messages in thread
From: Zeng Heng @ 2026-05-09  6:26 UTC (permalink / raw)
  To: Ben Horgan, James Morse, linux-kernel, linux-arm-kernel
  Cc: wangkefeng.wang, xry111, catalin.marinas, yang, reinette.chatre,
	will, thuth, mrigendra.chaubey, fenghuay, ahmed.genidi

Hi all,

On 2026/5/9 0:35, Ben Horgan wrote:
> Hi James,
> 
> On 5/8/26 17:23, James Morse wrote:
>> From: Zeng Heng <zengheng4@huawei.com>
>>
>> In addition to updating the CPU MPAM version check, the MPAM MSC version
>> check also need to be updated. mpam_msc_check_aidr() is added to check
>> the MSC AIDR register, ensuring that both the major and minor version
>> numbers fall within the supported range of the MPAM architecture version.
>>
>> Signed-off-by: Zeng Heng <zengheng4@huawei.com>
>> [ morse: changed mpam_msc_check_aidr() to accept versions like v1.2 ]
>> Signed-off-by: James Morse <james.morse@arm.com>
>> ---
>>   drivers/resctrl/mpam_devices.c | 23 ++++++++++++++++++++---
>>   1 file changed, 20 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
>> index 916d8fd45ed5..1771e9712ca2 100644
>> --- a/drivers/resctrl/mpam_devices.c
>> +++ b/drivers/resctrl/mpam_devices.c
>> @@ -224,6 +224,24 @@ static inline void _mpam_write_monsel_reg(struct mpam_msc *msc, u16 reg, u32 val
>>   
>>   #define mpam_write_monsel_reg(msc, reg, val)   _mpam_write_monsel_reg(msc, MSMON_##reg, val)
>>   
>> +static bool mpam_msc_check_aidr(struct mpam_msc *msc)
>> +{
>> +	u32 aidr = __mpam_read_reg(msc, MPAMF_AIDR);
>> +	u32 major = FIELD_GET(MPAMF_AIDR_ARCH_MAJOR_REV, aidr);
>> +	u32 minor = FIELD_GET(MPAMF_AIDR_ARCH_MINOR_REV, aidr);
>> +
>> +	/*
>> +	 * v0.0 and >v2.x aren't supported, but anything else should be backward
>> +	 * compatible to v0.1 or v1.0.
>> +	 */
>> +	if (!major && !minor)
>> +		return false;
>> +	if (major > 1) >> +		return false;

Would it make sense to introduce a new macro that defines the maximum
supported major version?

~~~
#define MPAM_ARCH_MAJOR_VERSION_MAX    0x1

if (major > MPAM_ARCH_MAJOR_VERSION_MAX)
	return false;
~~~


Best regards,
Zeng Heng

>> +
>> +	return true;
>> +}
>> +
>>   static u64 mpam_msc_read_idr(struct mpam_msc *msc)
>>   {
>>   	u64 idr_high = 0, idr_low;
>> @@ -951,9 +969,8 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
>>   
>>   	lockdep_assert_held(&msc->probe_lock);
>>   
>> -	idr = __mpam_read_reg(msc, MPAMF_AIDR);
>> -	if ((idr & MPAMF_AIDR_ARCH_MAJOR_REV) != MPAM_ARCHITECTURE_V1) { >
> nit: MPAM_ARCHITECTURE_V1 is now unused.
> 
> Reviewed-by: Ben Horgan <ben.horgan@arm.com>
> 


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

end of thread, other threads:[~2026-05-09  6:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 16:23 [PATCH v3 0/4] arm_mpam: Add support for the MPAM v0.1 architecture version James Morse
2026-05-08 16:23 ` [PATCH v3 1/4] arm_mpam: Fix false positive assert failure during mpam_disable() James Morse
2026-05-08 16:23 ` [PATCH v3 2/4] arm_mpam: Check whether the config array is allocated before destroying it James Morse
2026-05-08 16:23 ` [PATCH v3 3/4] arm64: cpufeature: Add support for the MPAM v0.1 architecture version James Morse
2026-05-08 16:23 ` [PATCH v3 4/4] arm_mpam: Update architecture version check for MPAM MSC James Morse
2026-05-08 16:35   ` Ben Horgan
2026-05-09  6:26     ` Zeng Heng

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