Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v13 5/5] riscv_cbqri: Add CBQRI capacity allocation platform driver
Date: Thu, 3 Dec 2026 14:07:54 -0800	[thread overview]
Message-ID: <axHoOowxGkJ-NYUN@thelio> (raw)
In-Reply-To: <sashiko-outbox-247562@kernel.org>

On Thu, Dec 03, 2026 at 10:18:44AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Medium] riscv_cbqri: async probe in cbqri_capacity_driver can race
>   late_initcall
> - [Medium] riscv_cbqri: cbqri_capacity_of_cache() misses offline
>   clusters at boot
> --
> 
> commit f9a576951d9d7e095fba9697627996ee2c9c8612
> Author: Drew Fustini <fustini@kernel.org>
> 
> riscv_cbqri: Add CBQRI capacity allocation platform driver
> 
> This commit adds a platform driver for RISC-V CBQRI capacity controllers
> described in device tree.  It maps the controller's register block, resolves
> its cache level and id from cacheinfo via the riscv,cbqri-cache phandle, and
> registers it with the CBQRI core.
> 
> > diff --git a/drivers/resctrl/cbqri_capacity.c b/drivers/resctrl/cbqri_capacity.c
> > new file mode 100644
> > index 0000000000000..9e3920b97d6c3
> > --- /dev/null
> > +++ b/drivers/resctrl/cbqri_capacity.c
> > @@ -0,0 +1,148 @@
> 
> [ ... ]
> 
> > +	cpus_read_lock();
> > +	for_each_online_cpu(cpu) {
> > +		struct cacheinfo *ci = get_cpu_cacheinfo_level(cpu, *cache_level);
> > +
> > +		if (ci && ci->fw_token == cache_np) {
> > +			*cache_id = ci->id;
> > +			found = true;
> > +			break;
> > +		}
> > +	}
> > +	cpus_read_unlock();
> > +
> > +	if (!found)
> > +		return dev_err_probe(dev, -ENODEV,
> > +				     "%pOF: no online hart reports an L%u cache with a cache id for this node\n",
> > +				     cache_np, *cache_level);
> 
> [Severity: Medium]
> Can this permanently miss capacity controllers for caches whose harts are
> offline at boot?
> 
> If a multi-cluster system boots with secondary clusters offline (such as
> with maxcpus=1), for_each_online_cpu() skips them and probe fails with
> -ENODEV.
> 
> When those harts are later brought online via CPU hotplug,
> cbqri_attach_cpu_to_all_ctrls() finds no registered controller for their
> cache id and leaves them permanently outside resctrl control.
> 
> Since cache_of_set_id() in drivers/base/cacheinfo.c derives DT cache IDs
> directly from CPU device-tree nodes, sharing an OF cache-id helper would
> avoid depending on online harts at probe time.

This is a known limit of the initial support. A cache that has no online
hart when the driver probes does not get a resctrl domain

> > +static struct platform_driver cbqri_capacity_driver = {
> > +	.probe	= cbqri_capacity_probe,
> > +	.driver = {
> > +		.name		= "cbqri-capacity",
> > +		.of_match_table	= cbqri_capacity_of_match,
> > +		/*
> > +		 * The controller is registered permanently into the
> > +		 * CBQRI core for the life of the system. Block unbind
> > +		 * so userspace cannot leave a dangling controller.
> > +		 */
> > +		.suppress_bind_attrs = true,
> > +	},
> > +};
> > +
> > +/*
> > + * Register at device_initcall so probe runs before the resctrl glue's
> > + * late_initcall, which copies the cbqri_controllers list.
> > + */
> > +builtin_platform_driver(cbqri_capacity_driver);
> 
> [Severity: Medium]
> Can asynchronous probing cause cbqri_capacity_probe() to race with
> cbqri_arch_late_init()?
> 
> Because .probe_type is left unset (PROBE_DEFAULT_STRATEGY), booting with
> driver_async_probe=* makes __driver_attach() schedule cbqri_capacity_probe()
> asynchronously and return immediately.  do_initcalls() then advances to
> late_initcall without waiting for async probes:
> 
> init thread                       async kworker
> do_initcalls() (device_initcall)
>   __driver_attach()
>     async_schedule_dev(...)
>                                   __driver_attach_async_helper()
>                                     cbqri_capacity_probe()
> do_initcalls() (late_initcall)
>   cbqri_arch_late_init()
>     cbqri_resctrl_pick_caches()   <-- misses unregistered controller
>                                       riscv_cbqri_register_cc()
> 
> Any controller that finishes probing after cbqri_resctrl_pick_caches() is
> permanently ignored by resctrl, causing resctrl setup to either fail with
> -ENODEV or come up missing cache domains while leaving the late controller
> and its MMIO mapping unused.
> 
> Setting .probe_type = PROBE_FORCE_SYNCHRONOUS on cbqri_capacity_driver.driver
> would prevent this race.

I don' think cmdline with driver_async_probe= is very likely, but I will
set probe_type to PROBE_FORCE_SYNCHRONOUS in the next revision.

Drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      parent reply	other threads:[~2026-12-03 22:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  9:57 [PATCH v13 0/5] riscv: Add initial CBQRI resctrl support Drew Fustini
2026-12-03  9:57 ` [PATCH v13 1/5] riscv_cbqri: Add capacity controller core Drew Fustini
     [not found]   ` <sashiko-outbox-247531@kernel.org>
2026-12-03 19:38     ` Drew Fustini
2026-12-03  9:57 ` [PATCH v13 2/5] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
     [not found]   ` <sashiko-outbox-247572@kernel.org>
2026-12-03 21:48     ` Drew Fustini
2026-12-03  9:57 ` [PATCH v13 3/5] riscv_cbqri: Make RESCTRL_FS available on RISC-V Drew Fustini
2026-12-03  9:57 ` [PATCH v13 4/5] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-12-03 14:58   ` Rob Herring
2026-12-03 22:04     ` Drew Fustini
     [not found]   ` <sashiko-outbox-247533@kernel.org>
2026-12-03 21:57     ` Drew Fustini
2026-12-03  9:57 ` [PATCH v13 5/5] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
     [not found]   ` <sashiko-outbox-247562@kernel.org>
2026-12-03 22:07     ` Drew Fustini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axHoOowxGkJ-NYUN@thelio \
    --to=fustini@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox