public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH RFC 08/19] RISC-V: QoS: add resctrl interface for CBQRI controllers
       [not found] <20260119-ssqosid-cbqri-v1-8-aa2a75153832@kernel.org>
@ 2026-03-26 11:05 ` guo.wenjia23
  2026-03-31  5:57   ` Drew Fustini
  0 siblings, 1 reply; 3+ messages in thread
From: guo.wenjia23 @ 2026-03-26 11:05 UTC (permalink / raw)
  To: fustini
  Cc: dave.martin, acpica-devel, alex, aou, aricciardi, atish.patra,
	atishp, babu.moger, ben.horgan, conor+dt, cp0613, cuiyunhui,
	devicetree, fenghua.yu, guo.wenjia23, james.morse, krzk+dt, lenb,
	linux-acpi, linux-kernel, linux-riscv, liu.qingtao2, liwei1518,
	mindal, npitre, palmer, paul.walmsley, peternewman, pjw, rafael,
	reinette.chatre, rkrcmar, robert.moore, robh, samuel.holland,
	sunilvl, tony.luck, vasu, ved, x86, zhiwei_liu

Hi Drew,

On Thu, Jan 29, 2026 at 4:28 AM Drew Fustini <fustini@kernel.org> wrote:>
> Add interface for CBQRI controller drivers to make use of the resctrl
> filesystem.
>
> Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com>
> Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
> Signed-off-by: Drew Fustini <fustini@kernel.org>
> ---
>  arch/riscv/kernel/qos/qos_resctrl.c | 1192 +++++++++++++++++++++++++++++++++++
>  1 file changed, 1192 insertions(+)
>
> ...
>
> +
> +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:
> +               /* covert from percentage to bandwidth blocks */
> +               cfg.rbwb = cfg_val * ctrl->bc.nbwblks / 100;

Should use bc.mrbwb to calculate rbwb? 
I think bc.nbwblks represent the available bw blks in the controller. It should should decrease as they are allocated.

> +               err = cbqri_apply_bw_config(dom, closid, t, &cfg);
> +               break;
> +       default:
> +               return -EINVAL;
> +       }
> +
> +       return err;
> +}
>
> ...
>
> +u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
> +                           u32 closid, enum resctrl_conf_type type)
> +{
> +       struct cbqri_resctrl_dom *hw_dom;
> +       struct cbqri_controller *ctrl;
> +       int reg_offset;
> +       u32 percent;
> +       u32 rbwb;
> +       u64 reg;
> +       int err;
> +
> +       hw_dom = container_of(d, struct cbqri_resctrl_dom, resctrl_ctrl_dom);
> +
> +       ctrl = hw_dom->hw_ctrl;
> +
> +       if (!r->alloc_capable)
> +               return resctrl_get_default_ctrl(r);
> +
> +       switch (r->rid) {
> +       case RDT_RESOURCE_L2:
> +       case RDT_RESOURCE_L3:
> +               /* Clear cc_block_mask before read limit operation */
> +               cbqri_set_cbm(ctrl, 0);
> +
> +               /* Capacity read limit operation for RCID (closid) */
> +               err = cbqri_cc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, type, closid);
> +               if (err < 0) {
> +                       pr_err("%s(): operation failed: err = %d", __func__, err);
> +                       return resctrl_get_default_ctrl(r);
> +               }
> +
> +               /* Read capacity block mask for RCID (closid) */
> +               reg_offset = CBQRI_CC_BLOCK_MASK_OFF;
> +               reg = ioread64(ctrl->base + reg_offset);
> +
> +               /* Update the config value for the closid in this domain */
> +               hw_dom->ctrl_val[closid] = reg;
> +               return hw_dom->ctrl_val[closid];
> +
> +       case RDT_RESOURCE_MBA:
> +               /* Capacity read limit operation for RCID (closid) */
> +               err = cbqri_bc_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, closid);
> +               if (err < 0) {
> +                       pr_err("%s(): operation failed: err = %d", __func__, err);
> +                       return resctrl_get_default_ctrl(r);
> +               }
> +
> +               hw_dom->ctrl_val[closid] = cbqri_get_rbwb(ctrl);
> +
> +               /* Convert from bandwidth blocks to percent */
> +               rbwb = hw_dom->ctrl_val[closid];
> +               rbwb *= 100;
> +               percent = rbwb / ctrl->bc.nbwblks;
> +               if (rbwb % ctrl->bc.nbwblks)

Same problem.

> +                       percent++;
> +               return percent;
> +
> +       default:
> +               return resctrl_get_default_ctrl(r);
> +       }
> +}


Thank,
Wenjia

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

* Re: [PATCH RFC 08/19] RISC-V: QoS: add resctrl interface for CBQRI controllers
  2026-03-26 11:05 ` [PATCH RFC 08/19] RISC-V: QoS: add resctrl interface for CBQRI controllers guo.wenjia23
@ 2026-03-31  5:57   ` Drew Fustini
  2026-03-31  8:14     ` guo.wenjia23
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Fustini @ 2026-03-31  5:57 UTC (permalink / raw)
  To: guo.wenjia23
  Cc: dave.martin, acpica-devel, alex, aou, aricciardi, atish.patra,
	atishp, babu.moger, ben.horgan, conor+dt, cp0613, cuiyunhui,
	devicetree, fenghua.yu, james.morse, krzk+dt, lenb, linux-acpi,
	linux-kernel, linux-riscv, liu.qingtao2, liwei1518, mindal,
	npitre, palmer, paul.walmsley, peternewman, pjw, rafael,
	reinette.chatre, rkrcmar, robert.moore, robh, samuel.holland,
	sunilvl, tony.luck, vasu, ved, x86, zhiwei_liu

On Thu, Mar 26, 2026 at 07:05:48PM +0800, guo.wenjia23@zte.com.cn wrote:
> Hi Drew,
> 
> On Thu, Jan 29, 2026 at 4:28 AM Drew Fustini <fustini@kernel.org> wrote:>
> > Add interface for CBQRI controller drivers to make use of the resctrl
> > filesystem.
> >
> > Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > Signed-off-by: Drew Fustini <fustini@kernel.org>
> > ---
> >  arch/riscv/kernel/qos/qos_resctrl.c | 1192 +++++++++++++++++++++++++++++++++++
> >  1 file changed, 1192 insertions(+)
> >
> > ...
> >
> > +
> > +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:
> > +               /* covert from percentage to bandwidth blocks */
> > +               cfg.rbwb = cfg_val * ctrl->bc.nbwblks / 100;
> 
> Should use bc.mrbwb to calculate rbwb? 
> I think bc.nbwblks represent the available bw blks in the controller.
> It should should decrease as they are allocated.

The resctrl MBA resource is supposed to be the percentage of total
memory bandwidth. nbwblks is the total number of bandwidth blocks, so I
think the existing calucation is correct.

From the example SoC configuration, the number of bandwidth blocks is
1024, and mrbwb is meant to be 80% of nbwblks which is 819.

Setting MB to 80% in schemata would yield: 80 * 1024 / 100 = 819

Thanks,
Drew

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

* Re: [PATCH RFC 08/19] RISC-V: QoS: add resctrl interface for CBQRI controllers
  2026-03-31  5:57   ` Drew Fustini
@ 2026-03-31  8:14     ` guo.wenjia23
  0 siblings, 0 replies; 3+ messages in thread
From: guo.wenjia23 @ 2026-03-31  8:14 UTC (permalink / raw)
  To: fustini
  Cc: dave.martin, acpica-devel, alex, aou, aricciardi, atish.patra,
	atishp, babu.moger, ben.horgan, conor+dt, cp0613, cuiyunhui,
	devicetree, fenghua.yu, james.morse, krzk+dt, lenb, linux-acpi,
	linux-kernel, linux-riscv, liu.qingtao2, liwei1518, mindal,
	npitre, palmer, paul.walmsley, peternewman, pjw, rafael,
	reinette.chatre, rkrcmar, robert.moore, robh, samuel.holland,
	sunilvl, tony.luck, vasu, ved, x86, zhiwei_liu

Hi Drew,

> On Thu, Mar 26, 2026 at 07:05:48PM +0800, guo.wenjia23@zte.com.cn wrote:
> > Hi Drew,
> > 
> > On Thu, Jan 29, 2026 at 4:28 AM Drew Fustini <fustini@kernel.org> wrote:>
> > > Add interface for CBQRI controller drivers to make use of the resctrl
> > > filesystem.
> > >
> > > Co-developed-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > > Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
> > > Signed-off-by: Drew Fustini <fustini@kernel.org>
> > > ---
> > >  arch/riscv/kernel/qos/qos_resctrl.c | 1192 +++++++++++++++++++++++++++++++++++
> > >  1 file changed, 1192 insertions(+)
> > >
> > > ...
> > >
> > > +
> > > +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:
> > > +               /* covert from percentage to bandwidth blocks */
> > > +               cfg.rbwb = cfg_val * ctrl->bc.nbwblks / 100;
> > 
> > Should use bc.mrbwb to calculate rbwb? 
> > I think bc.nbwblks represent the available bw blks in the controller.
> It should should decrease as they are allocated.
> 
> The resctrl MBA resource is supposed to be the percentage of total
> memory bandwidth. nbwblks is the total number of bandwidth blocks, so I
> think the existing calucation is correct.
> 
> From the example SoC configuration, the number of bandwidth blocks is
> 1024, and mrbwb is meant to be 80% of nbwblks which is 819.
> 
> Setting MB to 80% in schemata would yield: 80 * 1024 / 100 = 819
> 

According to the specification
1. The MRBWB field reports the maximum number of bandwidth blocks that can be reserved.
2. The sum of Rbwb allocated across all rcids must not exceed MRBWB value.

Based on the specification and the example you mentioned, can this be understood as follows:

MRBWB is a fixed value determined by the SoC configuration, representing the effective bandwidth capacity of the bandwidth controller. 
And the MRBWB value itself should remain constant and must not vary after the bandwidth allocations assigned to RCIDs.


Thanks,
Wenjia

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

end of thread, other threads:[~2026-03-31  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260119-ssqosid-cbqri-v1-8-aa2a75153832@kernel.org>
2026-03-26 11:05 ` [PATCH RFC 08/19] RISC-V: QoS: add resctrl interface for CBQRI controllers guo.wenjia23
2026-03-31  5:57   ` Drew Fustini
2026-03-31  8:14     ` guo.wenjia23

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