Expand the probing support with the control and monitor types
we can use with resctrl.
CC: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: James Morse <james.morse@arm.com>
---
Changes since v1:
* added an underscore to a variable name.
Changes since RFC:
* Made mpam_ris_hw_probe_hw_nrdy() more in C.
* Added static assert on features bitmap size.
---
drivers/resctrl/mpam_devices.c | 151 ++++++++++++++++++++++++++++++++
drivers/resctrl/mpam_internal.h | 53 +++++++++++
2 files changed, 204 insertions(+)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index a26b012452e2..ba8e8839cdc4 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -138,6 +138,20 @@ static inline void _mpam_write_partsel_reg(struct mpam_msc *msc, u16 reg, u32 va
}
#define mpam_write_partsel_reg(msc, reg, val) _mpam_write_partsel_reg(msc, MPAMCFG_##reg, val)
+static inline u32 _mpam_read_monsel_reg(struct mpam_msc *msc, u16 reg)
+{
+ mpam_mon_sel_lock_held(msc);
+ return __mpam_read_reg(msc, reg);
+}
+#define mpam_read_monsel_reg(msc, reg) _mpam_read_monsel_reg(msc, MSMON_##reg)
+
+static inline void _mpam_write_monsel_reg(struct mpam_msc *msc, u16 reg, u32 val)
+{
+ mpam_mon_sel_lock_held(msc);
+ __mpam_write_reg(msc, reg, val);
+}
+#define mpam_write_monsel_reg(msc, reg, val) _mpam_write_monsel_reg(msc, MSMON_##reg, val)
+
static u64 mpam_msc_read_idr(struct mpam_msc *msc)
{
u64 idr_high = 0, idr_low;
@@ -572,6 +586,136 @@ static struct mpam_msc_ris *mpam_get_or_create_ris(struct mpam_msc *msc,
return found;
}
+/*
+ * IHI009A.a has this nugget: "If a monitor does not support automatic behaviour
+ * of NRDY, software can use this bit for any purpose" - so hardware might not
+ * implement this - but it isn't RES0.
+ *
+ * Try and see what values stick in this bit. If we can write either value,
+ * its probably not implemented by hardware.
+ */
+static bool _mpam_ris_hw_probe_hw_nrdy(struct mpam_msc_ris * ris, u32 mon_reg)
+{
+ u32 now;
+ u64 mon_sel;
+ bool can_set, can_clear;
+ struct mpam_msc *msc = ris->vmsc->msc;
+
+ if (WARN_ON_ONCE(!mpam_mon_sel_lock(msc)))
+ return false;
+
+ mon_sel = FIELD_PREP(MSMON_CFG_MON_SEL_MON_SEL, 0) |
+ FIELD_PREP(MSMON_CFG_MON_SEL_RIS, ris->ris_idx);
+ _mpam_write_monsel_reg(msc, mon_reg, mon_sel);
+
+ _mpam_write_monsel_reg(msc, mon_reg, MSMON___NRDY);
+ now = _mpam_read_monsel_reg(msc, mon_reg);
+ can_set = now & MSMON___NRDY;
+
+ _mpam_write_monsel_reg(msc, mon_reg, 0);
+ now = _mpam_read_monsel_reg(msc, mon_reg);
+ can_clear = !(now & MSMON___NRDY);
+ mpam_mon_sel_unlock(msc);
+
+ return (!can_set || !can_clear);
+}
+
+#define mpam_ris_hw_probe_hw_nrdy(_ris, _mon_reg) \
+ _mpam_ris_hw_probe_hw_nrdy(_ris, MSMON_##_mon_reg)
+
+static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
+{
+ int err;
+ struct mpam_msc *msc = ris->vmsc->msc;
+ struct device *dev = &msc->pdev->dev;
+ struct mpam_props *props = &ris->props;
+
+ lockdep_assert_held(&msc->probe_lock);
+ lockdep_assert_held(&msc->part_sel_lock);
+
+ /* Cache Portion partitioning */
+ if (FIELD_GET(MPAMF_IDR_HAS_CPOR_PART, ris->idr)) {
+ u32 cpor_features = mpam_read_partsel_reg(msc, CPOR_IDR);
+
+ props->cpbm_wd = FIELD_GET(MPAMF_CPOR_IDR_CPBM_WD, cpor_features);
+ if (props->cpbm_wd)
+ mpam_set_feature(mpam_feat_cpor_part, props);
+ }
+
+ /* Memory bandwidth partitioning */
+ if (FIELD_GET(MPAMF_IDR_HAS_MBW_PART, ris->idr)) {
+ u32 mbw_features = mpam_read_partsel_reg(msc, MBW_IDR);
+
+ /* portion bitmap resolution */
+ props->mbw_pbm_bits = FIELD_GET(MPAMF_MBW_IDR_BWPBM_WD, mbw_features);
+ if (props->mbw_pbm_bits &&
+ FIELD_GET(MPAMF_MBW_IDR_HAS_PBM, mbw_features))
+ mpam_set_feature(mpam_feat_mbw_part, props);
+
+ props->bwa_wd = FIELD_GET(MPAMF_MBW_IDR_BWA_WD, mbw_features);
+ if (props->bwa_wd && FIELD_GET(MPAMF_MBW_IDR_HAS_MAX, mbw_features))
+ mpam_set_feature(mpam_feat_mbw_max, props);
+ }
+
+ /* Performance Monitoring */
+ if (FIELD_GET(MPAMF_IDR_HAS_MSMON, ris->idr)) {
+ u32 msmon_features = mpam_read_partsel_reg(msc, MSMON_IDR);
+
+ /*
+ * If the firmware max-nrdy-us property is missing, the
+ * CSU counters can't be used. Should we wait forever?
+ */
+ err = device_property_read_u32(&msc->pdev->dev,
+ "arm,not-ready-us",
+ &msc->nrdy_usec);
+
+ if (FIELD_GET(MPAMF_MSMON_IDR_MSMON_CSU, msmon_features)) {
+ u32 csumonidr;
+
+ csumonidr = mpam_read_partsel_reg(msc, CSUMON_IDR);
+ props->num_csu_mon = FIELD_GET(MPAMF_CSUMON_IDR_NUM_MON, csumonidr);
+ if (props->num_csu_mon) {
+ bool hw_managed;
+
+ mpam_set_feature(mpam_feat_msmon_csu, props);
+
+ /* Is NRDY hardware managed? */
+ hw_managed = mpam_ris_hw_probe_hw_nrdy(ris, CSU);
+ if (hw_managed)
+ mpam_set_feature(mpam_feat_msmon_csu_hw_nrdy, props);
+ }
+
+ /*
+ * Accept the missing firmware property if NRDY appears
+ * un-implemented.
+ */
+ if (err && mpam_has_feature(mpam_feat_msmon_csu_hw_nrdy, props))
+ dev_err_once(dev, "Counters are not usable because not-ready timeout was not provided by firmware.");
+ }
+ if (FIELD_GET(MPAMF_MSMON_IDR_MSMON_MBWU, msmon_features)) {
+ bool hw_managed;
+ u32 mbwumon_idr = mpam_read_partsel_reg(msc, MBWUMON_IDR);
+
+ props->num_mbwu_mon = FIELD_GET(MPAMF_MBWUMON_IDR_NUM_MON, mbwumon_idr);
+ if (props->num_mbwu_mon)
+ mpam_set_feature(mpam_feat_msmon_mbwu, props);
+
+ if (FIELD_GET(MPAMF_MBWUMON_IDR_HAS_RWBW, mbwumon_idr))
+ mpam_set_feature(mpam_feat_msmon_mbwu_rwbw, props);
+
+ /* Is NRDY hardware managed? */
+ hw_managed = mpam_ris_hw_probe_hw_nrdy(ris, MBWU);
+ if (hw_managed)
+ mpam_set_feature(mpam_feat_msmon_mbwu_hw_nrdy, props);
+
+ /*
+ * Don't warn about any missing firmware property for
+ * MBWU NRDY - it doesn't make any sense!
+ */
+ }
+ }
+}
+
static int mpam_msc_hw_probe(struct mpam_msc *msc)
{
u64 idr;
@@ -592,6 +736,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
mutex_lock(&msc->part_sel_lock);
idr = mpam_msc_read_idr(msc);
mutex_unlock(&msc->part_sel_lock);
+
msc->ris_max = FIELD_GET(MPAMF_IDR_RIS_MAX, idr);
/* Use these values so partid/pmg always starts with a valid value */
@@ -614,6 +759,12 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
mutex_unlock(&mpam_list_lock);
if (IS_ERR(ris))
return PTR_ERR(ris);
+ ris->idr = idr;
+
+ mutex_lock(&msc->part_sel_lock);
+ __mpam_part_sel(ris_idx, 0, msc);
+ mpam_ris_hw_probe(ris);
+ mutex_unlock(&msc->part_sel_lock);
}
spin_lock(&partid_max_lock);
diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
index 4cc44d4e21c4..5ae5d4eee8ec 100644
--- a/drivers/resctrl/mpam_internal.h
+++ b/drivers/resctrl/mpam_internal.h
@@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
raw_spin_lock_init(&msc->_mon_sel_lock);
}
+/*
+ * When we compact the supported features, we don't care what they are.
+ * Storing them as a bitmap makes life easy.
+ */
+typedef u16 mpam_features_t;
+
+/* Bits for mpam_features_t */
+enum mpam_device_features {
+ mpam_feat_ccap_part = 0,
+ mpam_feat_cpor_part,
+ mpam_feat_mbw_part,
+ mpam_feat_mbw_min,
+ mpam_feat_mbw_max,
+ mpam_feat_mbw_prop,
+ mpam_feat_msmon,
+ mpam_feat_msmon_csu,
+ mpam_feat_msmon_csu_capture,
+ mpam_feat_msmon_csu_hw_nrdy,
+ mpam_feat_msmon_mbwu,
+ mpam_feat_msmon_mbwu_capture,
+ mpam_feat_msmon_mbwu_rwbw,
+ mpam_feat_msmon_mbwu_hw_nrdy,
+ mpam_feat_msmon_capt,
+ MPAM_FEATURE_LAST,
+};
+static_assert(BITS_PER_TYPE(mpam_features_t) >= MPAM_FEATURE_LAST);
+
+struct mpam_props {
+ mpam_features_t features;
+
+ u16 cpbm_wd;
+ u16 mbw_pbm_bits;
+ u16 bwa_wd;
+ u16 num_csu_mon;
+ u16 num_mbwu_mon;
+};
+
+static inline bool mpam_has_feature(enum mpam_device_features feat,
+ struct mpam_props *props)
+{
+ return (1 << feat) & props->features;
+}
+
+static inline void mpam_set_feature(enum mpam_device_features feat,
+ struct mpam_props *props)
+{
+ props->features |= (1 << feat);
+}
+
struct mpam_class {
/* mpam_components in this class */
struct list_head components;
@@ -151,6 +200,8 @@ struct mpam_vmsc {
/* mpam_msc_ris in this vmsc */
struct list_head ris;
+ struct mpam_props props;
+
/* All RIS in this vMSC are members of this MSC */
struct mpam_msc *msc;
@@ -162,6 +213,8 @@ struct mpam_vmsc {
struct mpam_msc_ris {
u8 ris_idx;
+ u64 idr;
+ struct mpam_props props;
cpumask_t affinity;
--
2.39.5
On 9/10/25 13:42, James Morse wrote: > Expand the probing support with the control and monitor types > we can use with resctrl. > > CC: Dave Martin <Dave.Martin@arm.com> > Signed-off-by: James Morse <james.morse@arm.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> A couple of minor comments below. > --- > Changes since v1: > * added an underscore to a variable name. > > Changes since RFC: > * Made mpam_ris_hw_probe_hw_nrdy() more in C. > * Added static assert on features bitmap size. > --- > drivers/resctrl/mpam_devices.c | 151 ++++++++++++++++++++++++++++++++ > drivers/resctrl/mpam_internal.h | 53 +++++++++++ > 2 files changed, 204 insertions(+) > > diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c > index a26b012452e2..ba8e8839cdc4 100644 > --- a/drivers/resctrl/mpam_devices.c > +++ b/drivers/resctrl/mpam_devices.c [SNIP] > @@ -592,6 +736,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc) > mutex_lock(&msc->part_sel_lock); > idr = mpam_msc_read_idr(msc); > mutex_unlock(&msc->part_sel_lock); > + Adding this blank line is irrelevant to this patch. It's better to move this blank line to the original patch #11. > msc->ris_max = FIELD_GET(MPAMF_IDR_RIS_MAX, idr); > > /* Use these values so partid/pmg always starts with a valid value */ > @@ -614,6 +759,12 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc) > mutex_unlock(&mpam_list_lock); > if (IS_ERR(ris)) > return PTR_ERR(ris); > + ris->idr = idr; > + > + mutex_lock(&msc->part_sel_lock); > + __mpam_part_sel(ris_idx, 0, msc); > + mpam_ris_hw_probe(ris); > + mutex_unlock(&msc->part_sel_lock); > } > > spin_lock(&partid_max_lock); > diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h > index 4cc44d4e21c4..5ae5d4eee8ec 100644 > --- a/drivers/resctrl/mpam_internal.h > +++ b/drivers/resctrl/mpam_internal.h > @@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc) > raw_spin_lock_init(&msc->_mon_sel_lock); > } > > +/* > + * When we compact the supported features, we don't care what they are. > + * Storing them as a bitmap makes life easy. > + */ > +typedef u16 mpam_features_t; > + mpam_features_t is changed to u32 later in patch #21. It's better to directly define it as u32 here and remove the type change in patch #21. [SNIP] Thanks. -Fenghua
Hi James,
On 9/10/25 21:42, James Morse wrote:
> Expand the probing support with the control and monitor types
> we can use with resctrl.
>
> CC: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: James Morse <james.morse@arm.com>
> ---
> Changes since v1:
> * added an underscore to a variable name.
>
> Changes since RFC:
> * Made mpam_ris_hw_probe_hw_nrdy() more in C.
> * Added static assert on features bitmap size.
> ---
> drivers/resctrl/mpam_devices.c | 151 ++++++++++++++++++++++++++++++++
> drivers/resctrl/mpam_internal.h | 53 +++++++++++
> 2 files changed, 204 insertions(+)
>
[snip]
>
> spin_lock(&partid_max_lock);
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 4cc44d4e21c4..5ae5d4eee8ec 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
> raw_spin_lock_init(&msc->_mon_sel_lock);
> }
>
> +/*
> + * When we compact the supported features, we don't care what they are.
> + * Storing them as a bitmap makes life easy.
> + */
> +typedef u16 mpam_features_t;
> +
> +/* Bits for mpam_features_t */
> +enum mpam_device_features {
> + mpam_feat_ccap_part = 0,
> + mpam_feat_cpor_part,
> + mpam_feat_mbw_part,
> + mpam_feat_mbw_min,
> + mpam_feat_mbw_max,
> + mpam_feat_mbw_prop,
> + mpam_feat_msmon,
> + mpam_feat_msmon_csu,
> + mpam_feat_msmon_csu_capture,
> + mpam_feat_msmon_csu_hw_nrdy,
> + mpam_feat_msmon_mbwu,
> + mpam_feat_msmon_mbwu_capture,
> + mpam_feat_msmon_mbwu_rwbw,
> + mpam_feat_msmon_mbwu_hw_nrdy,
> + mpam_feat_msmon_capt,
> + MPAM_FEATURE_LAST,
> +};
I added a garbled comment about this for v1. What I was trying to say is
that I don't think this quite matches what resctrl supports. For
instance, I don't think mpam_feat_ccap_part matches a resctrl feature.
Thanks,
Ben
Hi Ben,
On 11/09/2025 16:37, Ben Horgan wrote:
> On 9/10/25 21:42, James Morse wrote:
>> Expand the probing support with the control and monitor types
>> we can use with resctrl.
>> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
>> index 4cc44d4e21c4..5ae5d4eee8ec 100644
>> --- a/drivers/resctrl/mpam_internal.h
>> +++ b/drivers/resctrl/mpam_internal.h
>> @@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
>> raw_spin_lock_init(&msc->_mon_sel_lock);
>> }
>>
>> +/*
>> + * When we compact the supported features, we don't care what they are.
>> + * Storing them as a bitmap makes life easy.
>> + */
>> +typedef u16 mpam_features_t;
>> +
>> +/* Bits for mpam_features_t */
>> +enum mpam_device_features {
>> + mpam_feat_ccap_part = 0,
>> + mpam_feat_cpor_part,
>> + mpam_feat_mbw_part,
>> + mpam_feat_mbw_min,
>> + mpam_feat_mbw_max,
>> + mpam_feat_mbw_prop,
>> + mpam_feat_msmon,
>> + mpam_feat_msmon_csu,
>> + mpam_feat_msmon_csu_capture,
>> + mpam_feat_msmon_csu_hw_nrdy,
>> + mpam_feat_msmon_mbwu,
>> + mpam_feat_msmon_mbwu_capture,
>> + mpam_feat_msmon_mbwu_rwbw,
>> + mpam_feat_msmon_mbwu_hw_nrdy,
>> + mpam_feat_msmon_capt,
>> + MPAM_FEATURE_LAST,
>> +};
> I added a garbled comment about this for v1. What I was trying to say is
> that I don't think this quite matches what resctrl supports. For
> instance, I don't think mpam_feat_ccap_part matches a resctrl feature.
Ah - right. I thought you meant something was removed later.
Looks like I thought something could be emulated with CCAP, but that turns out not to be
true because it doesn't have an implicit isolation property, which the
resctrl:bitmap-from-userspace requires.
(I think rwbw was a later addition to the architecture and I added it to the wrong patch).
I'll move that, _prop and _rwbw to the later patch. The split is fairly arbitrary - it was
just somewhere to split an otherwise large patch, and does help determine if a bug is
going to be visible to user-space or not.
_capt can go completely. Last I heard no-one was interested in firmware descriptions of
how the capture hardware can be triggered. I suspect no-one has done anything with it.
Thanks,
James
Hi James,
On 9/29/25 18:45, James Morse wrote:
> Hi Ben,
>
> On 11/09/2025 16:37, Ben Horgan wrote:
>> On 9/10/25 21:42, James Morse wrote:
>>> Expand the probing support with the control and monitor types
>>> we can use with resctrl.
>
>>> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
>>> index 4cc44d4e21c4..5ae5d4eee8ec 100644
>>> --- a/drivers/resctrl/mpam_internal.h
>>> +++ b/drivers/resctrl/mpam_internal.h
>>> @@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
>>> raw_spin_lock_init(&msc->_mon_sel_lock);
>>> }
>>>
>>> +/*
>>> + * When we compact the supported features, we don't care what they are.
>>> + * Storing them as a bitmap makes life easy.
>>> + */
>>> +typedef u16 mpam_features_t;
>>> +
>>> +/* Bits for mpam_features_t */
>>> +enum mpam_device_features {
>>> + mpam_feat_ccap_part = 0,
>>> + mpam_feat_cpor_part,
>>> + mpam_feat_mbw_part,
>>> + mpam_feat_mbw_min,
>>> + mpam_feat_mbw_max,
>>> + mpam_feat_mbw_prop,
>>> + mpam_feat_msmon,
>>> + mpam_feat_msmon_csu,
>>> + mpam_feat_msmon_csu_capture,
>>> + mpam_feat_msmon_csu_hw_nrdy,
>>> + mpam_feat_msmon_mbwu,
>>> + mpam_feat_msmon_mbwu_capture,
>>> + mpam_feat_msmon_mbwu_rwbw,
>>> + mpam_feat_msmon_mbwu_hw_nrdy,
>>> + mpam_feat_msmon_capt,
>>> + MPAM_FEATURE_LAST,
>>> +};
>
>> I added a garbled comment about this for v1. What I was trying to say is
>> that I don't think this quite matches what resctrl supports. For
>> instance, I don't think mpam_feat_ccap_part matches a resctrl feature.
>
> Ah - right. I thought you meant something was removed later.
> Looks like I thought something could be emulated with CCAP, but that turns out not to be
> true because it doesn't have an implicit isolation property, which the
> resctrl:bitmap-from-userspace requires.
> (I think rwbw was a later addition to the architecture and I added it to the wrong patch).
>
> I'll move that, _prop and _rwbw to the later patch. The split is fairly arbitrary - it was
I think ccap gets split into finer grained features later on which seems
fine.
> just somewhere to split an otherwise large patch, and does help determine if a bug is
> going to be visible to user-space or not.
Ok, sensible, I hadn't appreciated the user-space visibility aspect.
>
> _capt can go completely. Last I heard no-one was interested in firmware descriptions of
> how the capture hardware can be triggered. I suspect no-one has done anything with it.
So, if I've understood correctly this leaves you with the following in
this patch.
mpam_feat_cpor_part,
mpam_feat_mbw_part,
mpam_feat_mbw_min,
mpam_feat_mbw_max,
mpam_feat_mbw_prop,
mpam_feat_msmon,
mpam_feat_msmon_csu,
mpam_feat_msmon_csu_hw_nrdy,
mpam_feat_msmon_mbwu,
mpam_feat_msmon_mbwu_hw_nrdy,
Looks like the correct, resctrl based, split.
>
>
> Thanks,
>
> James
Thanks,
Ben
On Wed, 10 Sep 2025 20:42:53 +0000
James Morse <james.morse@arm.com> wrote:
> Expand the probing support with the control and monitor types
> we can use with resctrl.
>
> CC: Dave Martin <Dave.Martin@arm.com>
> Signed-off-by: James Morse <james.morse@arm.com>
A few trivial things inline.
LGTM
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Out of time for today, fingers crossed I can get to the others tomorrow.
J
> static int mpam_msc_hw_probe(struct mpam_msc *msc)
> {
> u64 idr;
> @@ -592,6 +736,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
> mutex_lock(&msc->part_sel_lock);
> idr = mpam_msc_read_idr(msc);
> mutex_unlock(&msc->part_sel_lock);
> +
Stray change - push it to earlier patch.
> msc->ris_max = FIELD_GET(MPAMF_IDR_RIS_MAX, idr);
>
> /* Use these values so partid/pmg always starts with a valid value */
> @@ -614,6 +759,12 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
> mutex_unlock(&mpam_list_lock);
> if (IS_ERR(ris))
> return PTR_ERR(ris);
> + ris->idr = idr;
> +
> + mutex_lock(&msc->part_sel_lock);
> + __mpam_part_sel(ris_idx, 0, msc);
> + mpam_ris_hw_probe(ris);
> + mutex_unlock(&msc->part_sel_lock);
> }
>
> spin_lock(&partid_max_lock);
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 4cc44d4e21c4..5ae5d4eee8ec 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
> raw_spin_lock_init(&msc->_mon_sel_lock);
> }
>
> +/*
> + * When we compact the supported features, we don't care what they are.
> + * Storing them as a bitmap makes life easy.
> + */
> +typedef u16 mpam_features_t;
Maybe use a bitmap type and avoid the need to be careful on sizing etc?
> +
> +/* Bits for mpam_features_t */
> +enum mpam_device_features {
> + mpam_feat_ccap_part = 0,
> + mpam_feat_cpor_part,
> + mpam_feat_mbw_part,
> + mpam_feat_mbw_min,
> + mpam_feat_mbw_max,
> + mpam_feat_mbw_prop,
> + mpam_feat_msmon,
> + mpam_feat_msmon_csu,
> + mpam_feat_msmon_csu_capture,
> + mpam_feat_msmon_csu_hw_nrdy,
> + mpam_feat_msmon_mbwu,
> + mpam_feat_msmon_mbwu_capture,
> + mpam_feat_msmon_mbwu_rwbw,
> + mpam_feat_msmon_mbwu_hw_nrdy,
> + mpam_feat_msmon_capt,
> + MPAM_FEATURE_LAST,
If it's always meant to be LAST, I'd drop the trailing comma.
> +};
> +static_assert(BITS_PER_TYPE(mpam_features_t) >= MPAM_FEATURE_LAST);
Hi Jonathan,
On 11/09/2025 16:29, Jonathan Cameron wrote:
> On Wed, 10 Sep 2025 20:42:53 +0000
> James Morse <james.morse@arm.com> wrote:
>
>> Expand the probing support with the control and monitor types
>> we can use with resctrl.
>>
>> CC: Dave Martin <Dave.Martin@arm.com>
>> Signed-off-by: James Morse <james.morse@arm.com>
>
> A few trivial things inline.
> LGTM
> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Thanks!
>> @@ -592,6 +736,7 @@ static int mpam_msc_hw_probe(struct mpam_msc *msc)
>> mutex_lock(&msc->part_sel_lock);
>> idr = mpam_msc_read_idr(msc);
>> mutex_unlock(&msc->part_sel_lock);
>> +
> Stray change - push it to earlier patch.
Fixed,
>> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
>> index 4cc44d4e21c4..5ae5d4eee8ec 100644
>> --- a/drivers/resctrl/mpam_internal.h
>> +++ b/drivers/resctrl/mpam_internal.h
>> @@ -112,6 +112,55 @@ static inline void mpam_mon_sel_lock_init(struct mpam_msc *msc)
>> raw_spin_lock_init(&msc->_mon_sel_lock);
>> }
>>
>> +/*
>> + * When we compact the supported features, we don't care what they are.
>> + * Storing them as a bitmap makes life easy.
>> + */
>> +typedef u16 mpam_features_t;
>
> Maybe use a bitmap type and avoid the need to be careful on sizing etc?
That would be unsigned long at a minimum, which is four times larger than needed.
As there is a build-time check, I'm not worried about this ever being wrong...
>> +
>> +/* Bits for mpam_features_t */
>> +enum mpam_device_features {
>> + mpam_feat_ccap_part = 0,
>> + mpam_feat_cpor_part,
>> + mpam_feat_mbw_part,
>> + mpam_feat_mbw_min,
>> + mpam_feat_mbw_max,
>> + mpam_feat_mbw_prop,
>> + mpam_feat_msmon,
>> + mpam_feat_msmon_csu,
>> + mpam_feat_msmon_csu_capture,
>> + mpam_feat_msmon_csu_hw_nrdy,
>> + mpam_feat_msmon_mbwu,
>> + mpam_feat_msmon_mbwu_capture,
>> + mpam_feat_msmon_mbwu_rwbw,
>> + mpam_feat_msmon_mbwu_hw_nrdy,
>> + mpam_feat_msmon_capt,
>> + MPAM_FEATURE_LAST,
>
> If it's always meant to be LAST, I'd drop the trailing comma.
Sure. Full-stops for enums!
Thanks,
James
© 2016 - 2026 Red Hat, Inc.