Re: [PATCH RFC v3 05/11] RISC-V: QoS: add resctrl arch callbacks for CBQRI controllers

Reinette Chatre <[email protected]> Thu, 30 Apr 2026 16:17:22 -0700
Newsgroups dev.linux.lists.acpica-devel,org.infradead.lists.linux-riscv,org.kernel.vger.linux-acpi,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi Drew,

On 4/14/26 6:53 PM, Drew Fustini wrote:

> +int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
> +			    u32 closid, enum resctrl_conf_type t, u32 cfg_val)
> +{
> +	struct cbqri_controller *ctrl;
> +	struct cbqri_resctrl_dom *dom;
> +	struct cbqri_config cfg;
> +	int err = 0;
> +
> +	dom = container_of(d, struct cbqri_resctrl_dom, resctrl_ctrl_dom);
> +	ctrl = dom->hw_ctrl;
> +
> +	if (!r->alloc_capable)
> +		return -EINVAL;
> +
> +	switch (r->rid) {
> +	case RDT_RESOURCE_L2:
> +	case RDT_RESOURCE_L3:
> +		cfg.cbm = cfg_val;
> +		err = cbqri_apply_cache_config(dom, closid, t, &cfg);
> +		break;
> +	case RDT_RESOURCE_MBA:
> +		/* convert from percentage to bandwidth blocks */
> +		cfg.rbwb = cfg_val * ctrl->bc.nbwblks / 100;
> +		cfg.rbwb = min_t(u64, cfg.rbwb, ctrl->bc.mrbwb);
> +		err = cbqri_apply_bw_config(dom, closid, t, &cfg);

(Earlier comment wondered about whether rbwb cannot just be provided
directly to cbqri_apply_bw_config().)

Apart from that it looks like this can benefit from "emulated controls"
that we mused about at https://lore.kernel.org/lkml/[email protected]/

At this time this MBA resource is constrained by the 1% steps that the
default MB control supports and clearly it is emulated with a control that
can support finer granularities. I am currently working on a PoC of the
base schema descriptions on which the support for emulated controls can
be built that should be able to expose full hardware capability.

Reinette