[PATCH v3 25/29] arm_mpam: Probe for long/lwd mbwu counters
Ben Horgan
ben.horgan at arm.com
Wed Oct 22 04:23:15 PDT 2025
Hi James,
On 10/17/25 19:56, James Morse wrote:
> From: Rohit Mathew <rohit.mathew at arm.com>
>
> mpam v0.1 and versions above v1.0 support optional long counter for
> memory bandwidth monitoring. The MPAMF_MBWUMON_IDR register has fields
> indicating support for long counters.
>
> Probe these feature bits.
>
> The mpam_feat_msmon_mbwu feature is used to indicate that bandwidth
> monitors are supported, instead of muddling this with which size of
> bandwidth monitors, add an explicit 31 bit counter feature.
>
> Signed-off-by: Rohit Mathew <rohit.mathew at arm.com>
> [ morse: Added 31bit counter feature to simplify later logic ]
> Signed-off-by: James Morse <james.morse at arm.com>
> Reviewed-by: Ben Horgan <ben.horgan at arm.com>
> Tested-by: Fenghua Yu <fenghuay at nvidia.com>
> ---
> Changes since v2:
> * Added 31 bit counter type feature.
> * Altered commit message.
> ---
> drivers/resctrl/mpam_devices.c | 13 +++++++++++--
> drivers/resctrl/mpam_internal.h | 3 +++
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index deb1dcc6f6b1..f4d07234ce10 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
> @@ -777,16 +777,25 @@ static void mpam_ris_hw_probe(struct mpam_msc_ris *ris)
> 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;
> + bool has_long, 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)
> + if (props->num_mbwu_mon) {
> mpam_set_feature(mpam_feat_msmon_mbwu, props);
> + mpam_set_feature(mpam_feat_msmon_mbwu_31counter, props);
> + }
>
> if (FIELD_GET(MPAMF_MBWUMON_IDR_HAS_RWBW, mbwumon_idr))
> mpam_set_feature(mpam_feat_msmon_mbwu_rwbw, props);
>
> + has_long = FIELD_GET(MPAMF_MBWUMON_IDR_HAS_LONG, mbwumon_idr);
> + if (props->num_mbwu_mon && has_long) {
> + mpam_set_feature(mpam_feat_msmon_mbwu_44counter, props);
> + if (FIELD_GET(MPAMF_MBWUMON_IDR_LWD, mbwumon_idr))
> + mpam_set_feature(mpam_feat_msmon_mbwu_63counter, props);
> + }
> +
I think it's clearer to set each mpam_feat_msmon_mbwu_XXcounter for just
the size of counter the hardware supports rather than all XX up to that
size.
> /* Is NRDY hardware managed? */
> hw_managed = mpam_ris_hw_probe_hw_nrdy(ris, MBWU);
> if (hw_managed)
> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index 28c475d18d86..ff38b4bbfc2b 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -158,6 +158,9 @@ enum mpam_device_features {
> mpam_feat_msmon_csu_xcl,
> mpam_feat_msmon_csu_hw_nrdy,
> mpam_feat_msmon_mbwu,
> + mpam_feat_msmon_mbwu_31counter,
> + mpam_feat_msmon_mbwu_44counter,
> + mpam_feat_msmon_mbwu_63counter,
> mpam_feat_msmon_mbwu_capture,
> mpam_feat_msmon_mbwu_rwbw,
> mpam_feat_msmon_mbwu_hw_nrdy,
--
Thanks,
Ben
More information about the linux-arm-kernel
mailing list