Re: [PATCH v12 5/5] riscv_cbqri: Add CBQRI capacity allocation platform driver
From: Drew Fustini
Date: Thu Nov 19 2026 - 19:30:08 EST
On Thu, Nov 19, 2026 at 12:00:00AM +0000, Jonathan Cameron wrote:
> On Sat, 14 Nov 2026 14:06:25 -0800
> Drew Fustini <fustini@xxxxxxxxxx> wrote:
>
> > Add a platform driver for CBQRI capacity controllers described in
> > device tree with the riscv,cbqri-capacity-controller compatible.
> >
> > The controller node points at the cache it governs with a
> > riscv,cbqri-cache phandle. The driver maps the register block, looks
> > that cache up in cacheinfo and uses its cache id as the resctrl domain
> > id, so the binding does not need to carry a CPU mask. The controller is
> > then handed to the CBQRI core, which probes its capabilities and decides
> > whether to expose it through resctrl. Only an L2 or L3 cache is
> > accepted, since those are the cache levels resctrl has resources for.
> >
> > Nothing is vendor-specific and reg is the CBQRI register block itself,
> > so any SoC that describes a CBQRI capacity controller in device tree can
> > use the driver unchanged.
> >
> > Tested-by: Chen Pei <cp0613@xxxxxxxxxxxxxxxxx>
> > Tested-by: Zeng Heng <zengheng@xxxxxxxxxxxxx>
> > Reviewed-by: Zeng Heng <zengheng@xxxxxxxxxxxxx>
> > Signed-off-by: Drew Fustini <fustini@xxxxxxxxxx>
>
> Sorry, late to the game and pretty much a drive by review.
>
> Still a few things below that will leave you with more readable
> and probably less fragile code.
>
> Jonathan
Thanks!
>
> > diff --git a/drivers/resctrl/cbqri_capacity.c b/drivers/resctrl/cbqri_capacity.c
> > new file mode 100644
> > index 000000000000..6f3d06c4f74b
> > --- /dev/null
> > +++ b/drivers/resctrl/cbqri_capacity.c
>
> > +static int cbqri_capacity_probe(struct platform_device *pdev)
> > +{
>
> Noted in the ACPI patch that you can save some effort there
> by a few tweaks that probably make sense here anyway.
Yeah, I'll make the changes in this patch so there is less churn in the
RQSC series.
> > + struct device *dev = &pdev->dev;
> > + struct cbqri_controller_info info = {};
> > + struct device_node *cache_np;
> > + struct resource *res;
> > + void __iomem *base;
> > + u32 rcid_count, cache_level, cache_id;
> > + bool found = false;
> > + int cpu, ret;
> > +
> > + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> > + if (IS_ERR(base))
> > + return PTR_ERR(base);
> > +
> > + ret = of_property_read_u32(dev->of_node, "riscv,cbqri-rcid", &rcid_count);
> > + if (ret) {
> > + dev_err(dev, "missing riscv,cbqri-rcid\n");
> It's a probe, use
> return dev_err_probe(dev, ret, "missing riscv,cbqri-rcid\n);
> same for all these paths. Sure we won't defer but it does nice formatting
> and tends to save a couple of lines every time!
>
> With the __free() magic, you can do this for all the returns in this
> function.
Sure, will do.
> > + cache_np = of_parse_phandle(dev->of_node, "riscv,cbqri-cache", 0);
> Follow on from glancing at the acpi and then finding this elsewhere in my
> inbox.
> struct device_node *cache_np __free(device_node) =
> of_parse_phandle(dev->of_node, "riscv,cbqri-cache", 0);
> and drop all the goto iritiations.
Will do.
> > + info.type = CBQRI_CONTROLLER_TYPE_CAPACITY;
> > + info.base = base;
> > + info.addr = res->start;
> > + info.size = resource_size(res);
> > + info.rcid_count = rcid_count;
> > + info.cache_id = cache_id;
> > + info.cache_level = cache_level;
> info = (struct cbqri_controller_info) {
> .type = CBQRI_CONTROLLER_TYPE_CAPACITY,
> .base = base,
> .addr = res->start,
> .size = resource_size,
> ...
>
> Might as well as you nicely set everything here.
> It's more readable and also makes it clear anything not set
> is zeroed without anyone having to go check the = { }; above.
Good idea, will do.
Thanks,
Drew