[RFC PATCH 34/38] arm_mpam: Add quirk framework

Jonathan Cameron jonathan.cameron at huawei.com
Thu Dec 18 06:04:01 PST 2025


On Fri, 5 Dec 2025 21:58:57 +0000
James Morse <james.morse at arm.com> wrote:

> From: Shanker Donthineni <sdonthineni at nvidia.com>
> 
> The MPAM specification includes the MPAMF_IIDR, which serves to
> uniquely identify the MSC implementation through a combination of
> implementer details, product ID, variant, and revision. Certain
> hardware issues/errata can be resolved using software workarounds.
> 
> Introduce a quirk framework to allow workarounds to be enabled based
> on the MPAMF_IIDR value.
> 
> Signed-off-by: Shanker Donthineni <sdonthineni at nvidia.com>
> [ morse: Stash the IIDR so this doesn't need an IPI, enable quirks only
>   once, move the description to the callback so it can be pr_once()d, add
>   an enum of workarounds for popular errata. Add macros for making lists
>   of product/revision/vendor half readable ]
> Signed-off-by: James Morse <james.morse at arm.com>
> ---
>  drivers/resctrl/mpam_devices.c  | 27 +++++++++++++++++++++++++++
>  drivers/resctrl/mpam_internal.h | 26 ++++++++++++++++++++++++++
>  2 files changed, 53 insertions(+)
> 
> diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
> index 741e14e1e6cf..f0f6f9b55ad4 100644
> --- a/drivers/resctrl/mpam_devices.c
> +++ b/drivers/resctrl/mpam_devices.c
> @@ -630,6 +630,25 @@ static struct mpam_msc_ris *mpam_get_or_create_ris(struct mpam_msc *msc,
>  	return ERR_PTR(-ENOENT);
>  }
>  
> +static const struct mpam_quirk mpam_quirks[] = {
> +	{ NULL }, /* Sentinel */

Drop the trailing , given I assume whole point is nothing after this?

> +};
> +
> +static void mpam_enable_quirks(struct mpam_msc *msc)
> +{
> +	const struct mpam_quirk *quirk;
> +
> +	for (quirk = &mpam_quirks[0]; quirk->iidr_mask; quirk++) {
> +		if (quirk->iidr != (msc->iidr & quirk->iidr_mask))
> +			continue;
> +
> +		if (quirk->init)
> +			quirk->init(msc, quirk);

I'm curious why you don't return a bool from this and call
mpam_set_quirk() if that's not indicating it should not be set.
Seems a bit odd to push the tracking that is relevant to the generic
framework (mpam_set_quirk) down into the particular quirk inits.

> +		else
> +			mpam_set_quirk(quirk->workaround, msc);
> +	}
> +}

> diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h
> index d381906545ed..de3e5faa12b2 100644
> --- a/drivers/resctrl/mpam_internal.h
> +++ b/drivers/resctrl/mpam_internal.h
> @@ -88,6 +88,8 @@ struct mpam_msc {
>  	u8			pmg_max;
>  	unsigned long		ris_idxs;
>  	u32			ris_max;
> +	u32			iidr;
> +	u16			quirks;
>  
>  	/*
>  	 * error_irq_lock is taken when registering/unregistering the error
> @@ -215,6 +217,29 @@ struct mpam_props {
>  #define mpam_set_feature(_feat, x)	set_bit(_feat, (x)->features)
>  #define mpam_clear_feature(_feat, x)	clear_bit(_feat, (x)->features)
>  
> +/* Workaround bits for msc->quirks */
> +enum mpam_device_quirks {
> +	MPAM_QUIRK_LAST,

Dropping this comma should make it harder for anyone to stick an entry
after this.



More information about the linux-arm-kernel mailing list