From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796335676; b=FpFzPEKZnY1UOeCGqIssbsXu9NfLWijpGxJgq8Z/0YCQewjpkzZGatwGRAeeucfXRWRp x1SJmGfN0VU1SxoelY/31coK6E9huBhivAwuHXjAy20I/tuSBV2voybsk0sYU6kiHl0zA HvU5Z5X0mvDaJdChlq8YWecI7XOOi4uxMqQ4U03UxEAh+xbTqZoPaiKn/3qKlBCnGBTfA 5YbS3SDqq6akG7kAbd91/NqFVM0WAe872yq0oYV9VTppLoCDupmYZrPnsUim7v5BrHIL9 Kz2G23CtVKEg/Ee20dNLgZqSjPrXXNjEFl02O8gwogaRlCQstZHUmODTUgrdIrh/6Lg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796335676; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=mkBdGcWw3sJrI/F+x+RGtxJVqfXbnrG8zb83QMSQBu0=; b=vyLomr/ngO4dFdXG6q3k5EsUqmceBWrjyXAYhHSe5Ae5i/KSFkW7z/VNBPpWe+U39Qwa NV2dKBqh4J74PLLZGwxDLtlPFtUufceEBTjvtua2vNcHWFAyaLuh4qR/yWD8Rw1WcAbXy 9bTxlqAQrCotNdkP+5MofhuUBX627iVKkEis/rFgWN9FaMN51bWi4061BphoCuudXDfbI +xBiT2Xx/Qd/dXSfueRCR9lC0R41UOr0+AXap1d/9iuI27d7pbFI+aL7bNWfAGogc494q haPWxtynxoEPVfZSwNRRM1YKaPkaz/kCnh/lrvt1IwOhVdDvDCG7I4sBUigsofRqk6g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="CW/ywfIG"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13870606A322; Thu, 3 Dec 2026 22:07:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CW/ywfIG Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4B481F000C2; Thu, 3 Dec 2026 22:07:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796335675; bh=mkBdGcWw3sJrI/F+x+RGtxJVqfXbnrG8zb83QMSQBu0=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=CW/ywfIGPtnek7rPq/a+KV4SZsFFR6PmDe0pEmGAOyz7tErC7UvMVYIJ9xCgmtg5L 6aIAcf+ykXWkorlflvmyxPvF+2MwcCTU4U7R+Pth8n+WA5MVXF3Th2FBHPRgu0yBxX ayetPJDWVtqn+RJCdI85fmXuN8cvH/3qFJ/zCgnfZvYn5awAIISjeFCZhoeQDEoJPU Eq1+2VU5eM9M4/Vc7LlHFeBHTPdAmthRPaC3Ao4nIZ94s2Ymh45xccWqhHi9rs9KAn 6jTCE9caV3+mzw5adDeSQxLhfs3fgKrygJ9sxDYdK6m7DQf2y7uOxcVpa0rgbQws8X lxWaD+lSPa6dQ== Date: Thu, 3 Dec 2026 14:07:54 -0800 From: Drew Fustini 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 Message-ID: References: <20261203-dfustini-atl-sc-cbqri-dt-v13-0-eaa688b1624c@kernel.org> <20261203-dfustini-atl-sc-cbqri-dt-v13-5-eaa688b1624c@kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 > > 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