From: Jonathan Cameron <jic23@kernel.org>
To: "Drew Fustini (Tenstorrent)" <fustini@kernel.org>
Cc: "Sunil V L" <sunilvl@oss.qualcomm.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Len Brown" <lenb@kernel.org>, "Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Atish Patra" <atish.patra@linux.dev>,
"Anup Patel" <anup.patel@oss.qualcomm.com>,
"Chen Pei" <cp0613@linux.alibaba.com>,
"yunhui cui" <cuiyunhui@bytedance.com>,
"Reinette Chatre" <reinette.chatre@intel.com>,
"Radim Krčmář" <radim.krcmar@oss.qualcomm.com>,
"Zeng Heng" <zengheng@picoheart.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Ben Horgan" <ben.horgan@arm.com>,
"James Morse" <james.morse@arm.com>,
"Tony Luck" <tony.luck@intel.com>,
"Adrien Ricciardi" <aricciardi@baylibre.com>,
"Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>,
"Gong Shuai" <gong.shuai@sanechips.com.cn>,
"Gong Shuai" <gsh517@gmail.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Kornel Dulęba" <mindal@semihalf.com>,
"Samuel Holland" <samuel.holland@sifive.com>,
guo.wenjia23@zte.com.cn, liu.qingtao2@zte.com.cn,
"Dave Martin" <Dave.Martin@arm.com>,
"Babu Moger" <babu.moger@amd.com>,
"Fenghua Yu" <fenghuay@nvidia.com>,
"Peter Newman" <peternewman@google.com>,
"Shaopeng Tan" <tan.shaopeng@jp.fujitsu.com>,
"Catalin Marinas" <catalin.marinas@arm.com>,
linux-acpi@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] riscv_cbqri: Bind to RQSC platform devices
Date: Wed, 18 Nov 2026 23:49:04 +0000 [thread overview]
Message-ID: <20261118234904.0f6a0f17@jic23-hlaptop> (raw)
In-Reply-To: <20261117-acpi-rqsc-v1-3-381ce645751e@kernel.org>
On Tue, 17 Nov 2026 14:11:29 -0800
"Drew Fustini (Tenstorrent)" <fustini@kernel.org> wrote:
> Let the capacity controller driver probe the "cbqri-capacity" platform
> devices created from the RQSC table. The cache is named by its PPTT
> Cache ID and the PPTT gives its level. Select ACPI_RQSC so the table is
> parsed and drop the OF dependency.
>
> No change for device tree systems.
>
> Signed-off-by: Drew Fustini (Tenstorrent) <fustini@kernel.org>
Has the DT support landed? If not feels like a few tweaks in that
would make this less noisy.
If not, see below for one tidy up I'd make here if you can't push
it back to that series.
You almost never want to do manual device_node puts these days!
It's one of the nicest places to use the cleanup.h magic.
> ---
> drivers/resctrl/Kconfig | 11 ++--
> drivers/resctrl/cbqri_capacity.c | 111 ++++++++++++++++++++++++++++-----------
> 2 files changed, 87 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/resctrl/Kconfig b/drivers/resctrl/Kconfig
> index 844dfd75e2aa..491c867f8c5c 100644
> --- a/drivers/resctrl/Kconfig
> +++ b/drivers/resctrl/Kconfig
> @@ -35,6 +35,7 @@ config ARM64_MPAM_RESCTRL_FS
> menuconfig RISCV_CBQRI
> bool "RISC-V CBQRI support"
> depends on RISCV && RISCV_ISA_SSQOSID
> + select ACPI_RQSC if ACPI
> select ARCH_HAS_CPU_RESCTRL
> default y
> help
> @@ -47,14 +48,14 @@ if RISCV_CBQRI
>
> config RISCV_CBQRI_CAPACITY
> bool "RISC-V CBQRI cache capacity-allocation controller"
> - depends on OF
> help
> Enable driver for a RISC-V CBQRI capacity controller that
> - governs a CPU cache, matching the "riscv,cbqri-capacity-controller"
> - compatible. The controller's cache phandle gives the cache level and
> - id, which the driver registers as a resctrl cache-allocation resource.
> + governs a CPU cache, described in device tree by the
> + "riscv,cbqri-capacity-controller" compatible or in ACPI by the RQSC
> + table. The firmware description gives the cache level and id, which
> + the driver registers as a resctrl cache-allocation resource.
>
> - Say N unless your device tree describes a CBQRI capacity controller.
> + Say N unless your firmware describes a CBQRI capacity controller.
>
> endif
>
> diff --git a/drivers/resctrl/cbqri_capacity.c b/drivers/resctrl/cbqri_capacity.c
> index 6f3d06c4f74b..7013f1a50ffd 100644
> --- a/drivers/resctrl/cbqri_capacity.c
> +++ b/drivers/resctrl/cbqri_capacity.c
> -static int cbqri_capacity_probe(struct platform_device *pdev)
> +static int cbqri_capacity_of_cache(struct device *dev, u32 *cache_level,
> + u32 *cache_id)
> {
> - 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");
> - return ret;
> - }
> -
> cache_np = of_parse_phandle(dev->of_node, "riscv,cbqri-cache", 0);
Whilst you are here.
struct device_node *cache_np __free(device_node) =
of_parse_phandle();
and drop all the gotos. I haven't checked but if there is
a path where you want to hang on to it, no_free_ptr() that.
> if (!cache_np) {
> dev_err(dev, "missing riscv,cbqri-cache phandle\n");
> return -EINVAL;
> }
>
> - ret = of_property_read_u32(cache_np, "cache-level", &cache_level);
> + ret = of_property_read_u32(cache_np, "cache-level", cache_level);
> if (ret) {
> dev_err(dev, "%pOF: missing cache-level\n", cache_np);
> goto out_put;
> }
>
> - if (cache_level != 2 && cache_level != 3) {
> + if (*cache_level != 2 && *cache_level != 3) {
> dev_err(dev, "%pOF: unsupported cache-level %u\n",
> - cache_np, cache_level);
> + cache_np, *cache_level);
> ret = -EINVAL;
> goto out_put;
> }
> @@ -73,10 +63,10 @@ static int cbqri_capacity_probe(struct platform_device *pdev)
> */
> cpus_read_lock();
> for_each_online_cpu(cpu) {
> - struct cacheinfo *ci = get_cpu_cacheinfo_level(cpu, cache_level);
> + struct cacheinfo *ci = get_cpu_cacheinfo_level(cpu, *cache_level);
>
> if (ci && ci->fw_token == cache_np) {
> - cache_id = ci->id;
> + *cache_id = ci->id;
> found = true;
> break;
> }
> @@ -85,11 +75,74 @@ static int cbqri_capacity_probe(struct platform_device *pdev)
>
> if (!found) {
> dev_err(dev, "%pOF: no online hart reports an L%u cache with a cache id for this node\n",
> - cache_np, cache_level);
> + cache_np, *cache_level);
> ret = -ENODEV;
> - goto out_put;
> }
>
> +out_put:
> + of_node_put(cache_np);
> + return ret;
> +}
>
prev parent reply other threads:[~2026-11-18 23:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 22:11 [PATCH 0/3] ACPI: RISC-V: Add support for the RQSC table Drew Fustini (Tenstorrent)
2026-11-17 22:11 ` [PATCH 1/3] ACPI: RISC-V: Add RQSC table definitions Drew Fustini (Tenstorrent)
2026-11-18 20:37 ` Jonathan Cameron
2026-11-18 21:31 ` Drew Fustini
2026-11-17 22:11 ` [PATCH 2/3] ACPI: RISC-V: Enumerate CBQRI controllers from the RQSC table Drew Fustini (Tenstorrent)
2026-11-18 23:42 ` Jonathan Cameron
2026-11-17 22:11 ` [PATCH 3/3] riscv_cbqri: Bind to RQSC platform devices Drew Fustini (Tenstorrent)
2026-11-18 23:49 ` Jonathan Cameron [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=20261118234904.0f6a0f17@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=Dave.Martin@arm.com \
--cc=alex@ghiti.fr \
--cc=anup.patel@oss.qualcomm.com \
--cc=aou@eecs.berkeley.edu \
--cc=aricciardi@baylibre.com \
--cc=atish.patra@linux.dev \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=catalin.marinas@arm.com \
--cc=conor.dooley@microchip.com \
--cc=cp0613@linux.alibaba.com \
--cc=cuiyunhui@bytedance.com \
--cc=fenghuay@nvidia.com \
--cc=fustini@kernel.org \
--cc=gong.shuai@sanechips.com.cn \
--cc=gsh517@gmail.com \
--cc=guo.wenjia23@zte.com.cn \
--cc=james.morse@arm.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=liu.qingtao2@zte.com.cn \
--cc=liwei1518@gmail.com \
--cc=mindal@semihalf.com \
--cc=palmer@dabbelt.com \
--cc=peternewman@google.com \
--cc=pjw@kernel.org \
--cc=radim.krcmar@oss.qualcomm.com \
--cc=rafael@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=samuel.holland@sifive.com \
--cc=sunilvl@oss.qualcomm.com \
--cc=tan.shaopeng@jp.fujitsu.com \
--cc=tony.luck@intel.com \
--cc=zengheng@picoheart.com \
--cc=zhangzhanpeng.jasper@bytedance.com \
--cc=zhiwei_liu@linux.alibaba.com \
/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
all inboxes | Powered by JetHome®