* [PATCH 1/3] ACPI: RISC-V: Add RQSC table definitions
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 ` Drew Fustini (Tenstorrent)
2026-11-18 20:37 ` Jonathan Cameron
2026-11-17 22:11 ` [PATCH 2/3] ACPI: RISC-V: Enumerate CBQRI controllers from the RQSC table Drew Fustini (Tenstorrent)
2026-11-17 22:11 ` [PATCH 3/3] riscv_cbqri: Bind to RQSC platform devices Drew Fustini (Tenstorrent)
2 siblings, 1 reply; 8+ messages in thread
From: Drew Fustini (Tenstorrent) @ 2026-11-17 22:11 UTC (permalink / raw)
To: Sunil V L
Cc: Rafael J. Wysocki, Len Brown, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Atish Patra, Anup Patel, Chen Pei,
yunhui cui, Reinette Chatre, Radim Krčmář,
Zeng Heng, Conor Dooley, Ben Horgan, James Morse, Tony Luck,
Adrien Ricciardi, Zhanpeng Zhang, Gong Shuai, Gong Shuai,
Weiwei Li, Liu Zhiwei, Kornel Dulęba, Samuel Holland,
guo.wenjia23, liu.qingtao2, Dave Martin, Babu Moger, Fenghua Yu,
Peter Newman, Shaopeng Tan, Jonathan Cameron, Catalin Marinas,
linux-acpi, linux-riscv, linux-kernel, Drew Fustini (Tenstorrent)
The RISC-V Quality of Service Controllers (RQSC) table describes the
CBQRI capacity and bandwidth controllers in a system. RQSC v1.0 was
ratified in June 2026. Add structure definitions for RQSC.
The definitions stay in drivers/acpi/riscv until ACPICA carries them
in actbl2.h.
Link: https://github.com/open-acpica/acpica/pull/1262
Signed-off-by: Drew Fustini (Tenstorrent) <fustini@kernel.org>
---
drivers/acpi/riscv/rqsc.h | 67 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/drivers/acpi/riscv/rqsc.h b/drivers/acpi/riscv/rqsc.h
new file mode 100644
index 000000000000..d9a4ce0f1c10
--- /dev/null
+++ b/drivers/acpi/riscv/rqsc.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Definitions for the RISC-V Quality of Service Controllers (RQSC) ACPI
+ * table, kept here until ACPICA carries them in actbl2.h.
+ */
+#ifndef _DRIVERS_ACPI_RISCV_RQSC_H
+#define _DRIVERS_ACPI_RISCV_RQSC_H
+
+#include <linux/acpi.h>
+#include <linux/types.h>
+
+#define ACPI_SIG_RQSC "RQSC" /* RISC-V Quality of Service Controllers Table */
+
+#define ACPI_RQSC_REVISION 1
+
+/* QoS Controller Type */
+#define ACPI_RQSC_CONTROLLER_TYPE_CAPACITY 0
+#define ACPI_RQSC_CONTROLLER_TYPE_BANDWIDTH 1
+
+/* Resource Type */
+#define ACPI_RQSC_RESOURCE_TYPE_CACHE 0
+#define ACPI_RQSC_RESOURCE_TYPE_MEMORY 1
+
+/* Resource ID Type */
+#define ACPI_RQSC_RESOURCE_ID_TYPE_PROCESSOR_CACHE 0
+#define ACPI_RQSC_RESOURCE_ID_TYPE_MEMORY_RANGE 1
+#define ACPI_RQSC_RESOURCE_ID_TYPE_MEMORY_SIDE_CACHE 2
+#define ACPI_RQSC_RESOURCE_ID_TYPE_ACPI_DEVICE 3
+#define ACPI_RQSC_RESOURCE_ID_TYPE_PCI_DEVICE 4
+
+/* Controller Flags */
+#define ACPI_RQSC_CONTROLLER_ZERO_BLOCKS (1) /* Zero blocks can be allocated to an RCID */
+
+struct acpi_rqsc_resource {
+ u8 type;
+ u8 reserved;
+ u16 length;
+ u16 flags;
+ u8 reserved2;
+ u8 id_type;
+ u64 id1;
+ u32 id2;
+} __packed;
+
+/* Resource Specific Data that follows a memory resource */
+struct acpi_rqsc_memory_data {
+ u64 bandwidth_per_block; /* In bytes per second, 0 if not provided */
+} __packed;
+
+struct acpi_rqsc_controller {
+ u8 type;
+ u8 reserved;
+ u16 length;
+ struct acpi_generic_address address;
+ u16 rcid_count;
+ u16 mcid_count;
+ u16 flags;
+ u16 num_resources;
+ /* Followed by num_resources struct acpi_rqsc_resource */
+} __packed;
+
+struct acpi_table_rqsc {
+ struct acpi_table_header header; /* Common ACPI table header */
+ u32 num_controllers;
+} __packed;
+
+#endif /* _DRIVERS_ACPI_RISCV_RQSC_H */
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 1/3] ACPI: RISC-V: Add RQSC table definitions
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
0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2026-11-18 20:37 UTC (permalink / raw)
To: Drew Fustini (Tenstorrent)
Cc: Sunil V L, Rafael J. Wysocki, Len Brown, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Atish Patra,
Anup Patel, Chen Pei, yunhui cui, Reinette Chatre,
Radim Krčmář, Zeng Heng, Conor Dooley, Ben Horgan,
James Morse, Tony Luck, Adrien Ricciardi, Zhanpeng Zhang,
Gong Shuai, Gong Shuai, Weiwei Li, Liu Zhiwei, Kornel Dulęba,
Samuel Holland, guo.wenjia23, liu.qingtao2, Dave Martin,
Babu Moger, Fenghua Yu, Peter Newman, Shaopeng Tan,
Catalin Marinas, linux-acpi, linux-riscv, linux-kernel
On Tue, 17 Nov 2026 14:11:27 -0800
"Drew Fustini (Tenstorrent)" <fustini@kernel.org> wrote:
> The RISC-V Quality of Service Controllers (RQSC) table describes the
> CBQRI capacity and bandwidth controllers in a system. RQSC v1.0 was
> ratified in June 2026. Add structure definitions for RQSC.
>
> The definitions stay in drivers/acpi/riscv until ACPICA carries them
> in actbl2.h.
Hi Drew,
This seems unusual. Normal path for this has been to
put them in the right place and just flag the pull request as
you have done. Then no one merges the series until acpica
pick them up and Rafael pulls that in. That way it 'should'
not require a change, Rafael just ignores that patch and
picks up the rest.
I haven't been paying attention so maybe this is being
done differently here for some reason.
Has added benefit that no one reads the patch as it is another
projects problem :)
J
>
> Link: https://github.com/open-acpica/acpica/pull/1262
> Signed-off-by: Drew Fustini (Tenstorrent) <fustini@kernel.org>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] ACPI: RISC-V: Add RQSC table definitions
2026-11-18 20:37 ` Jonathan Cameron
@ 2026-11-18 21:31 ` Drew Fustini
0 siblings, 0 replies; 8+ messages in thread
From: Drew Fustini @ 2026-11-18 21:31 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Sunil V L, Rafael J. Wysocki, Len Brown, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Atish Patra,
Anup Patel, Chen Pei, yunhui cui, Reinette Chatre,
Radim Krčmář, Zeng Heng, Conor Dooley, Ben Horgan,
James Morse, Tony Luck, Adrien Ricciardi, Zhanpeng Zhang,
Gong Shuai, Gong Shuai, Weiwei Li, Liu Zhiwei, Kornel Dulęba,
Samuel Holland, guo.wenjia23, liu.qingtao2, Dave Martin,
Babu Moger, Fenghua Yu, Peter Newman, Shaopeng Tan,
Catalin Marinas, linux-acpi, linux-riscv, linux-kernel
On Wed, Nov 18, 2026 at 08:37:44PM +0000, Jonathan Cameron wrote:
> On Tue, 17 Nov 2026 14:11:27 -0800
> "Drew Fustini (Tenstorrent)" <fustini@kernel.org> wrote:
>
> > The RISC-V Quality of Service Controllers (RQSC) table describes the
> > CBQRI capacity and bandwidth controllers in a system. RQSC v1.0 was
> > ratified in June 2026. Add structure definitions for RQSC.
> >
> > The definitions stay in drivers/acpi/riscv until ACPICA carries them
> > in actbl2.h.
> Hi Drew,
>
> This seems unusual. Normal path for this has been to
> put them in the right place and just flag the pull request as
> you have done. Then no one merges the series until acpica
> pick them up and Rafael pulls that in. That way it 'should'
> not require a change, Rafael just ignores that patch and
> picks up the rest.
>
> I haven't been paying attention so maybe this is being
> done differently here for some reason.
>
> Has added benefit that no one reads the patch as it is another
> projects problem :)
Thanks for taking a look at this series. There is no special reason,
just my lack of experience with ACPI. I will switch to the actbl2.h
patch generated by the ACPICA linuxize process.
Drew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] ACPI: RISC-V: Enumerate CBQRI controllers from the RQSC table
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-17 22:11 ` 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)
2 siblings, 1 reply; 8+ messages in thread
From: Drew Fustini (Tenstorrent) @ 2026-11-17 22:11 UTC (permalink / raw)
To: Sunil V L
Cc: Rafael J. Wysocki, Len Brown, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Atish Patra, Anup Patel, Chen Pei,
yunhui cui, Reinette Chatre, Radim Krčmář,
Zeng Heng, Conor Dooley, Ben Horgan, James Morse, Tony Luck,
Adrien Ricciardi, Zhanpeng Zhang, Gong Shuai, Gong Shuai,
Weiwei Li, Liu Zhiwei, Kornel Dulęba, Samuel Holland,
guo.wenjia23, liu.qingtao2, Dave Martin, Babu Moger, Fenghua Yu,
Peter Newman, Shaopeng Tan, Jonathan Cameron, Catalin Marinas,
linux-acpi, linux-riscv, linux-kernel, Drew Fustini (Tenstorrent)
Walk the RQSC table at ACPI init and create a platform device for each
CBQRI controller, so one platform driver can serve device tree and ACPI
systems. Nothing selects ACPI_RQSC until the CBQRI driver can bind to
these devices.
Signed-off-by: Drew Fustini (Tenstorrent) <fustini@kernel.org>
---
drivers/acpi/riscv/Kconfig | 3 +
drivers/acpi/riscv/Makefile | 1 +
drivers/acpi/riscv/init.c | 2 +
drivers/acpi/riscv/init.h | 1 +
drivers/acpi/riscv/rqsc.c | 210 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 217 insertions(+)
diff --git a/drivers/acpi/riscv/Kconfig b/drivers/acpi/riscv/Kconfig
index 046296a18d00..2f2304bf0681 100644
--- a/drivers/acpi/riscv/Kconfig
+++ b/drivers/acpi/riscv/Kconfig
@@ -5,3 +5,6 @@
config ACPI_RIMT
bool
+
+config ACPI_RQSC
+ bool
diff --git a/drivers/acpi/riscv/Makefile b/drivers/acpi/riscv/Makefile
index 1284a076fa88..b4bcfa4826d8 100644
--- a/drivers/acpi/riscv/Makefile
+++ b/drivers/acpi/riscv/Makefile
@@ -3,3 +3,4 @@ obj-y += rhct.o init.o irq.o
obj-$(CONFIG_ACPI_PROCESSOR_IDLE) += cpuidle.o
obj-$(CONFIG_ACPI_CPPC_LIB) += cppc.o
obj-$(CONFIG_ACPI_RIMT) += rimt.o
+obj-$(CONFIG_ACPI_RQSC) += rqsc.o
diff --git a/drivers/acpi/riscv/init.c b/drivers/acpi/riscv/init.c
index 7c00f7995e86..9fdd5f1bcc5f 100644
--- a/drivers/acpi/riscv/init.c
+++ b/drivers/acpi/riscv/init.c
@@ -12,4 +12,6 @@ void __init acpi_arch_init(void)
riscv_acpi_init_gsi_mapping();
if (IS_ENABLED(CONFIG_ACPI_RIMT))
riscv_acpi_rimt_init();
+ if (IS_ENABLED(CONFIG_ACPI_RQSC))
+ riscv_acpi_rqsc_init();
}
diff --git a/drivers/acpi/riscv/init.h b/drivers/acpi/riscv/init.h
index 1680aa2aaf23..176459e356b7 100644
--- a/drivers/acpi/riscv/init.h
+++ b/drivers/acpi/riscv/init.h
@@ -3,3 +3,4 @@
void __init riscv_acpi_init_gsi_mapping(void);
void __init riscv_acpi_rimt_init(void);
+void __init riscv_acpi_rqsc_init(void);
diff --git a/drivers/acpi/riscv/rqsc.c b/drivers/acpi/riscv/rqsc.c
new file mode 100644
index 000000000000..262fd5755d29
--- /dev/null
+++ b/drivers/acpi/riscv/rqsc.c
@@ -0,0 +1,210 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Create a platform device for each CBQRI controller described by the ACPI
+ * RISC-V Quality of Service Controllers (RQSC) table.
+ */
+
+#define pr_fmt(fmt) "ACPI: RQSC: " fmt
+
+#include <linux/acpi.h>
+#include <linux/bug.h>
+#include <linux/cleanup.h>
+#include <linux/err.h>
+#include <linux/ioport.h>
+#include <linux/mm.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/wordpart.h>
+
+#include "init.h"
+#include "rqsc.h"
+
+static struct platform_device * __init
+rqsc_add_device(unsigned int idx, const struct acpi_rqsc_controller *ctrl,
+ const struct acpi_rqsc_resource *res)
+{
+ bool is_cc = ctrl->type == ACPI_RQSC_CONTROLLER_TYPE_CAPACITY;
+ struct platform_device *pdev __free(platform_device_put) =
+ platform_device_alloc(is_cc ? "cbqri-capacity" : "cbqri-bandwidth",
+ idx);
+ phys_addr_t addr = ctrl->address.address;
+ /* The GAS carries no length, so claim up to the end of the page. */
+ struct resource mem = DEFINE_RES_MEM(addr, PAGE_SIZE - offset_in_page(addr));
+ /* rcid, mcid, cache id and a sentinel */
+ struct property_entry props[4] = {};
+ unsigned int n = 0;
+ int ret;
+
+ if (!pdev)
+ return ERR_PTR(-ENOMEM);
+
+ ret = platform_device_add_resources(pdev, &mem, 1);
+ if (ret)
+ return ERR_PTR(ret);
+
+ props[n++] = PROPERTY_ENTRY_U32("riscv,cbqri-rcid", ctrl->rcid_count);
+ props[n++] = PROPERTY_ENTRY_U32("riscv,cbqri-mcid", ctrl->mcid_count);
+ if (is_cc)
+ props[n++] = PROPERTY_ENTRY_U32("riscv,cbqri-cache-id",
+ lower_32_bits(res->id1));
+ else
+ set_dev_node(&pdev->dev, pxm_to_node(lower_32_bits(res->id1)));
+
+ ret = device_create_managed_software_node(&pdev->dev, props, NULL);
+ if (ret)
+ return ERR_PTR(ret);
+
+ ret = platform_device_add(pdev);
+ if (ret)
+ return ERR_PTR(ret);
+
+ return_ptr(pdev);
+}
+
+/*
+ * Check the one resource the controller is described with. A capacity
+ * controller names a processor cache by PPTT Cache ID, a bandwidth
+ * controller a memory range by SRAT proximity domain. Both IDs are
+ * the low 32 bits of Resource ID 1, the upper half is reserved.
+ */
+static bool __init rqsc_resource_ok(const struct acpi_rqsc_controller *ctrl,
+ const struct acpi_rqsc_resource *res,
+ phys_addr_t addr)
+{
+ u8 want_type, want_id_type;
+
+ if (ctrl->type == ACPI_RQSC_CONTROLLER_TYPE_CAPACITY) {
+ want_type = ACPI_RQSC_RESOURCE_TYPE_CACHE;
+ want_id_type = ACPI_RQSC_RESOURCE_ID_TYPE_PROCESSOR_CACHE;
+ } else {
+ want_type = ACPI_RQSC_RESOURCE_TYPE_MEMORY;
+ want_id_type = ACPI_RQSC_RESOURCE_ID_TYPE_MEMORY_RANGE;
+ }
+
+ if (res->type != want_type || res->id_type != want_id_type) {
+ pr_warn("controller at %pa: resource type %u id type %u does not match controller type %u, skipping\n",
+ &addr, res->type, res->id_type, ctrl->type);
+ return false;
+ }
+
+ return true;
+}
+
+static void __init rqsc_parse(const struct acpi_table_rqsc *rqsc)
+{
+ const void *end = (const void *)rqsc + rqsc->header.length;
+ const struct acpi_rqsc_controller *ctrl = (const void *)(rqsc + 1);
+ unsigned int idx = 0, added = 0;
+
+ while ((const void *)ctrl < end) {
+ const struct acpi_rqsc_resource *res = (const void *)(ctrl + 1);
+ struct platform_device *pdev;
+ phys_addr_t addr;
+
+ /*
+ * The controller structure must fit and stay inside the
+ * table. Anything else is corruption and the remaining
+ * entries cannot be trusted.
+ */
+ if ((const void *)ctrl + sizeof(*ctrl) > end ||
+ ctrl->length < sizeof(*ctrl) ||
+ (const void *)ctrl + ctrl->length > end) {
+ pr_err("entry %u is malformed, stopping\n", idx);
+ break;
+ }
+
+ addr = ctrl->address.address;
+
+ if (ctrl->type != ACPI_RQSC_CONTROLLER_TYPE_CAPACITY &&
+ ctrl->type != ACPI_RQSC_CONTROLLER_TYPE_BANDWIDTH) {
+ pr_warn("controller at %pa: unknown type %u, skipping\n",
+ &addr, ctrl->type);
+ goto next;
+ }
+
+ if (ctrl->address.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY || !addr) {
+ pr_warn("entry %u: no usable register interface address, skipping\n",
+ idx);
+ goto next;
+ }
+
+ if (!ctrl->rcid_count && !ctrl->mcid_count) {
+ pr_warn("controller at %pa: no RCIDs and no MCIDs, skipping\n",
+ &addr);
+ goto next;
+ }
+
+ if (!ctrl->num_resources ||
+ ctrl->length < sizeof(*ctrl) + sizeof(*res) ||
+ res->length < sizeof(*res)) {
+ pr_warn("controller at %pa: no usable resource, skipping\n",
+ &addr);
+ goto next;
+ }
+
+ if (ctrl->num_resources > 1)
+ pr_warn("controller at %pa: %u resources, using the first\n",
+ &addr, ctrl->num_resources);
+
+ if (!rqsc_resource_ok(ctrl, res, addr))
+ goto next;
+
+ pdev = rqsc_add_device(idx, ctrl, res);
+ if (IS_ERR(pdev)) {
+ pr_warn("controller at %pa: failed to add device: %pe\n",
+ &addr, pdev);
+ goto next;
+ }
+
+ added++;
+next:
+ ctrl = (const void *)ctrl + ctrl->length;
+ idx++;
+ }
+
+ if (idx != rqsc->num_controllers)
+ pr_warn("table announces %u controllers, found %u\n",
+ rqsc->num_controllers, idx);
+
+ if (added)
+ pr_info("%u CBQRI controllers\n", added);
+ else
+ pr_warn("no usable CBQRI controller\n");
+}
+
+void __init riscv_acpi_rqsc_init(void)
+{
+ struct acpi_table_header *table __free(acpi_put_table) = NULL;
+ acpi_status status;
+
+ BUILD_BUG_ON(sizeof(struct acpi_rqsc_resource) != 20);
+ BUILD_BUG_ON(sizeof(struct acpi_rqsc_controller) != 24);
+ BUILD_BUG_ON(sizeof(struct acpi_table_rqsc) != 40);
+
+ status = acpi_get_table(ACPI_SIG_RQSC, 0, &table);
+ if (status == AE_NOT_FOUND)
+ return;
+
+ if (ACPI_FAILURE(status)) {
+ pr_err("failed to get table: %s\n",
+ acpi_format_exception(status));
+ return;
+ }
+
+ /*
+ * A later revision could extend the fixed header, which would
+ * shift the first controller structure. Stop rather than guess.
+ */
+ if (table->revision != ACPI_RQSC_REVISION) {
+ pr_err("table revision %u, expected %u\n",
+ table->revision, ACPI_RQSC_REVISION);
+ return;
+ }
+
+ if (table->length < sizeof(struct acpi_table_rqsc)) {
+ pr_err("table truncated: length %u\n", table->length);
+ return;
+ }
+
+ rqsc_parse((const struct acpi_table_rqsc *)table);
+}
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 2/3] ACPI: RISC-V: Enumerate CBQRI controllers from the RQSC table
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
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-11-18 23:42 UTC (permalink / raw)
To: Drew Fustini (Tenstorrent)
Cc: Sunil V L, Rafael J. Wysocki, Len Brown, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Atish Patra,
Anup Patel, Chen Pei, yunhui cui, Reinette Chatre,
Radim Krčmář, Zeng Heng, Conor Dooley, Ben Horgan,
James Morse, Tony Luck, Adrien Ricciardi, Zhanpeng Zhang,
Gong Shuai, Gong Shuai, Weiwei Li, Liu Zhiwei, Kornel Dulęba,
Samuel Holland, guo.wenjia23, liu.qingtao2, Dave Martin,
Babu Moger, Fenghua Yu, Peter Newman, Shaopeng Tan,
Catalin Marinas, linux-acpi, linux-riscv, linux-kernel
On Tue, 17 Nov 2026 14:11:28 -0800
"Drew Fustini (Tenstorrent)" <fustini@kernel.org> wrote:
> Walk the RQSC table at ACPI init and create a platform device for each
> CBQRI controller, so one platform driver can serve device tree and ACPI
> systems. Nothing selects ACPI_RQSC until the CBQRI driver can bind to
> these devices.
>
> Signed-off-by: Drew Fustini (Tenstorrent) <fustini@kernel.org>
Hi Drew
Very much a drive by review as I haven't even opened the spec yet ;)
Anyhow, various comments inline. Most code readability suggestions.
Thanks,
Jonathan
> diff --git a/drivers/acpi/riscv/rqsc.c b/drivers/acpi/riscv/rqsc.c
> new file mode 100644
> index 000000000000..262fd5755d29
> --- /dev/null
> +++ b/drivers/acpi/riscv/rqsc.c
> @@ -0,0 +1,210 @@
"
> +
> +static struct platform_device * __init
> +rqsc_add_device(unsigned int idx, const struct acpi_rqsc_controller *ctrl,
> + const struct acpi_rqsc_resource *res)
> +{
> + bool is_cc = ctrl->type == ACPI_RQSC_CONTROLLER_TYPE_CAPACITY;
Not a fan of a bool when we might get more types at some point.
If you want to do something like this have a trivial helper
bool rqsc_ctrl_is_cc() and use it inline.
> + struct platform_device *pdev __free(platform_device_put) =
> + platform_device_alloc(is_cc ? "cbqri-capacity" : "cbqri-bandwidth",
> + idx);
Not particularly readable or extensible if more types show up.
I'd use a switch that sets the string. Declare the pdev and __free after that.
> + phys_addr_t addr = ctrl->address.address;
> + /* The GAS carries no length, so claim up to the end of the page. */
> + struct resource mem = DEFINE_RES_MEM(addr, PAGE_SIZE - offset_in_page(addr));
> + /* rcid, mcid, cache id and a sentinel */
> + struct property_entry props[4] = {};
> + unsigned int n = 0;
> + int ret;
> +
> + if (!pdev)
Drag the pdev alloc down to just above this. Having it burried
in allocations is not easy to read when you only check for
success all the way down here.
> + return ERR_PTR(-ENOMEM);
> +
> + ret = platform_device_add_resources(pdev, &mem, 1);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + props[n++] = PROPERTY_ENTRY_U32("riscv,cbqri-rcid", ctrl->rcid_count);
> + props[n++] = PROPERTY_ENTRY_U32("riscv,cbqri-mcid", ctrl->mcid_count);
> + if (is_cc)
> + props[n++] = PROPERTY_ENTRY_U32("riscv,cbqri-cache-id",
> + lower_32_bits(res->id1));
> + else
> + set_dev_node(&pdev->dev, pxm_to_node(lower_32_bits(res->id1)));
> +
> + ret = device_create_managed_software_node(&pdev->dev, props, NULL);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + ret = platform_device_add(pdev);
> + if (ret)
> + return ERR_PTR(ret);
> +
> + return_ptr(pdev);
> +}
> +
> +static void __init rqsc_parse(const struct acpi_table_rqsc *rqsc)
> +{
> + const void *end = (const void *)rqsc + rqsc->header.length;
> + const struct acpi_rqsc_controller *ctrl = (const void *)(rqsc + 1);
> + unsigned int idx = 0, added = 0;
> +
> + while ((const void *)ctrl < end) {
> + const struct acpi_rqsc_resource *res = (const void *)(ctrl + 1);
> + struct platform_device *pdev;
> + phys_addr_t addr;
> +
> + /*
> + * The controller structure must fit and stay inside the
> + * table. Anything else is corruption and the remaining
> + * entries cannot be trusted.
> + */
> + if ((const void *)ctrl + sizeof(*ctrl) > end ||
if ((const void *)(ctrl + 1) > end ?
Which looks familiar. Isn't that
if ((const void *)res > end)
Maybe that is a little confusing as res might be zero size.
For that matter I'd not set res until after this check because it
might take an invalid value. Doesn't matter as such but is confusing
to read.
> + ctrl->length < sizeof(*ctrl) ||
> + (const void *)ctrl + ctrl->length > end) {
> + pr_err("entry %u is malformed, stopping\n", idx);
> + break;
> + }
> +
> + addr = ctrl->address.address;
> +
> + if (ctrl->type != ACPI_RQSC_CONTROLLER_TYPE_CAPACITY &&
> + ctrl->type != ACPI_RQSC_CONTROLLER_TYPE_BANDWIDTH) {
> + pr_warn("controller at %pa: unknown type %u, skipping\n",
> + &addr, ctrl->type);
> + goto next;
> + }
> +
> + if (ctrl->address.space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY || !addr) {
> + pr_warn("entry %u: no usable register interface address, skipping\n",
> + idx);
> + goto next;
> + }
> +
> + if (!ctrl->rcid_count && !ctrl->mcid_count) {
> + pr_warn("controller at %pa: no RCIDs and no MCIDs, skipping\n",
> + &addr);
> + goto next;
> + }
> +
> + if (!ctrl->num_resources ||
Little fiddly but I'd split this. The reason being that the next
check if kind of checking for only one resource, but you only confirm
that is ok with pr_warn() path that follows. So maybe
if (!ctrl->num_resources) {
pr_warn("controller at %pa: no resource, skipping\n",
&addr);
I'd go a bit long on lines - not sure ACPI is that fussy as subsystem go.
goto next;
}
if (ctrl->num_resources > 1)
pr_warn("controller at %pa: %u resources, using the first\n",
&addr, ctrl->num_resources);
//now we have clarity that we only care about first resource.
if (ctrl->length < sizeof(*ctrl) + sizeof(*res) ||
res->length < sizeof(*res)) {
pr_warn("controller at %pa: no usable resource, skipping\n",
&addr);
goto next;
}
> + ctrl->length < sizeof(*ctrl) + sizeof(*res) ||
> + res->length < sizeof(*res)) {
> + pr_warn("controller at %pa: no usable resource, skipping\n",
> + &addr);
> + goto next;
> + }
> +
> + if (ctrl->num_resources > 1)
> + pr_warn("controller at %pa: %u resources, using the first\n",
> + &addr, ctrl->num_resources);
> +
> + if (!rqsc_resource_ok(ctrl, res, addr))
> + goto next;
> +
> + pdev = rqsc_add_device(idx, ctrl, res);
> + if (IS_ERR(pdev)) {
> + pr_warn("controller at %pa: failed to add device: %pe\n",
> + &addr, pdev);
This feels like the sort of thing you should just fail init on.
Papering over bits of the table that don't like you expect
might be dealing with changes that have been made. Failing to add
a device is something much worse.
> + goto next;
> + }
> +
> + added++;
> +next:
> + ctrl = (const void *)ctrl + ctrl->length;
> + idx++;
Could you turn this whole thing into a do { } while() and
update these conditions in the while bit? Then the various
gotos become continues.
> + }
> +
> + if (idx != rqsc->num_controllers)
> + pr_warn("table announces %u controllers, found %u\n",
> + rqsc->num_controllers, idx);
> +
> + if (added)
> + pr_info("%u CBQRI controllers\n", added);
> + else
> + pr_warn("no usable CBQRI controller\n");
> +}
> +
> +void __init riscv_acpi_rqsc_init(void)
> +{
> + struct acpi_table_header *table __free(acpi_put_table) = NULL;
See cleanup.h That needs to move to next to the constructor.
> + acpi_status status;
> +
> + BUILD_BUG_ON(sizeof(struct acpi_rqsc_resource) != 20);
> + BUILD_BUG_ON(sizeof(struct acpi_rqsc_controller) != 24);
> + BUILD_BUG_ON(sizeof(struct acpi_table_rqsc) != 40);
It's an ACPI table. You should be updating it only in a safe
forwards compatible way. Hence I'd not normally expect hard checks
that will fail if it changes in acpica.
> +
Declare the struct .. * table _free() down here.
> + status = acpi_get_table(ACPI_SIG_RQSC, 0, &table);
> + if (status == AE_NOT_FOUND)
> + return;
> +
> + if (ACPI_FAILURE(status)) {
> + pr_err("failed to get table: %s\n",
> + acpi_format_exception(status));
> + return;
> + }
> +
> + /*
> + * A later revision could extend the fixed header, which would
> + * shift the first controller structure. Stop rather than guess.
That would be an ACPI spec bug. Sure they have happened a few times
(usually when assumption was no one had implemented something that needed
a fix) but the rules for ACPI are very strict that any change even with
a version tick should not make incompatible changes. You add stuff
and sometime reserve things that previously had values, but you don't
move fields around unless there is an offset indicator or size value
in the structure to allow you to do that.
If riscv isn't keeping to that, I'd suggest working to make sure
people understand this. We can't have a regression because someone
put that sort of change in the spec.
> + */
> + if (table->revision != ACPI_RQSC_REVISION) {
> + pr_err("table revision %u, expected %u\n",
> + table->revision, ACPI_RQSC_REVISION);
Likewise, that rings alarm bells about the spec process if there
is any likelihood of that being needed. The only similar
instances that I've seen were where things accidentally broke
and we had to deal with that - and HMAT where this happened
we at least landed support for v1 and v2 at the same time.
> + return;
> + }
> +
> + if (table->length < sizeof(struct acpi_table_rqsc)) {
> + pr_err("table truncated: length %u\n", table->length);
> + return;
> + }
> +
> + rqsc_parse((const struct acpi_table_rqsc *)table);
> +}
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] riscv_cbqri: Bind to RQSC platform devices
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-17 22:11 ` [PATCH 2/3] ACPI: RISC-V: Enumerate CBQRI controllers from the RQSC table Drew Fustini (Tenstorrent)
@ 2026-11-17 22:11 ` Drew Fustini (Tenstorrent)
2026-11-18 23:49 ` Jonathan Cameron
2 siblings, 1 reply; 8+ messages in thread
From: Drew Fustini (Tenstorrent) @ 2026-11-17 22:11 UTC (permalink / raw)
To: Sunil V L
Cc: Rafael J. Wysocki, Len Brown, Paul Walmsley, Palmer Dabbelt,
Albert Ou, Alexandre Ghiti, Atish Patra, Anup Patel, Chen Pei,
yunhui cui, Reinette Chatre, Radim Krčmář,
Zeng Heng, Conor Dooley, Ben Horgan, James Morse, Tony Luck,
Adrien Ricciardi, Zhanpeng Zhang, Gong Shuai, Gong Shuai,
Weiwei Li, Liu Zhiwei, Kornel Dulęba, Samuel Holland,
guo.wenjia23, liu.qingtao2, Dave Martin, Babu Moger, Fenghua Yu,
Peter Newman, Shaopeng Tan, Jonathan Cameron, Catalin Marinas,
linux-acpi, linux-riscv, linux-kernel, Drew Fustini (Tenstorrent)
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>
---
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
@@ -3,11 +3,14 @@
* Platform driver for a RISC-V CBQRI capacity controller that backs a CPU
* cache. The controller is described in device tree by the generic
* "riscv,cbqri-capacity-controller" compatible together with a phandle to the
- * cache node it governs. The driver hands it to the CBQRI core, which probes
- * the capabilities register and exposes a controller that supports allocation
- * as the resctrl cache allocation resource for that cache.
+ * cache node it governs, or in ACPI by the RQSC table, whose parser creates a
+ * "cbqri-capacity" platform device that carries the PPTT Cache ID of the
+ * cache. The driver hands it to the CBQRI core, which probes the capabilities
+ * register and exposes a controller that supports allocation as the resctrl
+ * cache allocation resource for that cache.
*/
+#include <linux/acpi.h>
#include <linux/cacheinfo.h>
#include <linux/cpu.h>
#include <linux/device-id/of.h>
@@ -15,45 +18,32 @@
#include <linux/ioport.h>
#include <linux/of.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <linux/riscv_cbqri.h>
#include <linux/types.h>
-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);
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;
+}
+
+/*
+ * The RQSC table names the cache by its PPTT Cache ID, which the table parser
+ * passes on in the riscv,cbqri-cache-id property. cacheinfo takes the cache
+ * id from the same PPTT field, and the PPTT gives the level of the cache.
+ */
+static int cbqri_capacity_acpi_cache(struct device *dev, u32 *cache_level,
+ u32 *cache_id)
+{
+ int level, ret;
+
+ ret = device_property_read_u32(dev, "riscv,cbqri-cache-id", cache_id);
+ if (ret) {
+ dev_err(dev, "missing riscv,cbqri-cache-id\n");
+ return ret;
+ }
+
+ level = find_acpi_cache_level_from_id(*cache_id);
+ if (level < 0) {
+ dev_err(dev, "no PPTT cache with Cache ID %u\n", *cache_id);
+ return level;
+ }
+
+ if (level != 2 && level != 3) {
+ dev_err(dev, "unsupported cache level %d for Cache ID %u\n",
+ level, *cache_id);
+ return -EINVAL;
+ }
+
+ *cache_level = level;
+
+ return 0;
+}
+
+static int cbqri_capacity_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct cbqri_controller_info info = {};
+ struct resource *res;
+ void __iomem *base;
+ u32 rcid_count, cache_level, cache_id;
+ int ret;
+
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+ if (IS_ERR(base))
+ return PTR_ERR(base);
+
+ ret = device_property_read_u32(dev, "riscv,cbqri-rcid", &rcid_count);
+ if (ret) {
+ dev_err(dev, "missing riscv,cbqri-rcid\n");
+ return ret;
+ }
+
+ if (dev->of_node)
+ ret = cbqri_capacity_of_cache(dev, &cache_level, &cache_id);
+ else
+ ret = cbqri_capacity_acpi_cache(dev, &cache_level, &cache_id);
+ if (ret)
+ return ret;
+
info.type = CBQRI_CONTROLLER_TYPE_CAPACITY;
info.base = base;
info.addr = res->start;
@@ -101,15 +154,13 @@ static int cbqri_capacity_probe(struct platform_device *pdev)
ret = riscv_cbqri_register_cc(&info);
if (ret) {
dev_err(dev, "failed to register capacity controller: %d\n", ret);
- goto out_put;
+ return ret;
}
dev_info(dev, "registered L%u capacity controller at %pa (cache_id=%u, rcid=%u)\n",
cache_level, &info.addr, cache_id, rcid_count);
-out_put:
- of_node_put(cache_np);
- return ret;
+ return 0;
}
static const struct of_device_id cbqri_capacity_of_match[] = {
--
2.43.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 3/3] riscv_cbqri: Bind to RQSC platform devices
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
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-11-18 23:49 UTC (permalink / raw)
To: Drew Fustini (Tenstorrent)
Cc: Sunil V L, Rafael J. Wysocki, Len Brown, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Alexandre Ghiti, Atish Patra,
Anup Patel, Chen Pei, yunhui cui, Reinette Chatre,
Radim Krčmář, Zeng Heng, Conor Dooley, Ben Horgan,
James Morse, Tony Luck, Adrien Ricciardi, Zhanpeng Zhang,
Gong Shuai, Gong Shuai, Weiwei Li, Liu Zhiwei, Kornel Dulęba,
Samuel Holland, guo.wenjia23, liu.qingtao2, Dave Martin,
Babu Moger, Fenghua Yu, Peter Newman, Shaopeng Tan,
Catalin Marinas, linux-acpi, linux-riscv, linux-kernel
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;
> +}
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 8+ messages in thread