From: Sunil V L <sunilvl@oss.qualcomm.com>
To: linux-acpi@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Len Brown <lenb@kernel.org>,
Mayuresh Chitale <mchitale@gmail.com>,
Anup Patel <anup@brainfault.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@kernel.org>,
Sunil V L <sunilvl@oss.qualcomm.com>
Subject: [RFC PATCH 5/5] hwtracing: rvtrace: Add ACPI support
Date: Tue, 29 Sep 2026 14:25:24 +0530 [thread overview]
Message-ID: <20260929085524.1554507-6-sunilvl@oss.qualcomm.com> (raw)
In-Reply-To: <20260929085524.1554507-1-sunilvl@oss.qualcomm.com>
From: Sunil V L <sunilvl@oss.qualcomm.com>
Add ACPI device IDs and ACPI-based CPU binding lookup for rvtrace
platform devices.
Signed-off-by: Sunil V L <sunilvl@oss.qualcomm.com>
---
drivers/hwtracing/gtrace/rvtrace-platform.c | 60 +++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/drivers/hwtracing/gtrace/rvtrace-platform.c b/drivers/hwtracing/gtrace/rvtrace-platform.c
index 12330d9dcddd..44422d429ccf 100644
--- a/drivers/hwtracing/gtrace/rvtrace-platform.c
+++ b/drivers/hwtracing/gtrace/rvtrace-platform.c
@@ -3,6 +3,7 @@
* Copyright (c) 2026 Qualcomm Technologies, Inc.
*/
+#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/gtrace.h>
#include <linux/io.h>
@@ -174,6 +175,62 @@ static int rvtrace_parse_inconns(struct gtrace_platform_data *pdata)
return ret;
}
+#ifdef CONFIG_ACPI
+#include <acpi/processor.h>
+
+static const struct acpi_device_id rvtrace_platform_acpi_match[] = {
+ { "RSCV0007", 0 },
+ {}
+};
+MODULE_DEVICE_TABLE(acpi, rvtrace_platform_acpi_match);
+
+/*
+ * acpi_handle_to_logical_cpuid - Map a given acpi_handle to the
+ * logical CPU id of the corresponding CPU device.
+ *
+ * Returns the logical CPU id when found. Otherwise returns >= nr_cpus_id.
+ */
+static int acpi_handle_to_logical_cpuid(acpi_handle handle)
+{
+ struct acpi_processor *pr;
+ int i;
+
+ for_each_possible_cpu(i) {
+ pr = per_cpu(processors, i);
+ if (pr && pr->handle == handle)
+ break;
+ }
+
+ return i;
+}
+
+static int acpi_rvtrace_get_cpu(struct device *dev)
+{
+ struct acpi_device *adev = ACPI_COMPANION(dev);
+ acpi_handle cpu_handle;
+ acpi_status status;
+ int cpu;
+
+ if (!adev)
+ return -1;
+
+ status = acpi_get_parent(adev->handle, &cpu_handle);
+ if (ACPI_FAILURE(status))
+ return -1;
+
+ cpu = acpi_handle_to_logical_cpuid(cpu_handle);
+ if (cpu >= nr_cpu_ids)
+ return -1;
+
+ return cpu;
+}
+#else
+static int acpi_rvtrace_get_cpu(struct device *dev)
+{
+ return -1;
+}
+#endif
+
#ifdef CONFIG_OF
static int of_rvtrace_get_cpu(struct device *dev)
{
@@ -209,6 +266,8 @@ static int rvtrace_get_cpu(struct device *dev)
{
if (is_of_node(dev_fwnode(dev)))
return of_rvtrace_get_cpu(dev);
+ else if (is_acpi_device_node(dev_fwnode(dev)))
+ return acpi_rvtrace_get_cpu(dev);
return -1;
}
@@ -308,6 +367,7 @@ static struct platform_driver rvtrace_platform_driver = {
.driver = {
.name = "rvtrace",
.of_match_table = rvtrace_platform_match,
+ .acpi_match_table = ACPI_PTR(rvtrace_platform_acpi_match),
},
.probe = rvtrace_platform_probe,
.remove = rvtrace_platform_remove,
--
2.43.0
prev parent reply other threads:[~2026-09-29 8:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 8:55 [RFC PATCH 0/5] " Sunil V L
2026-09-29 8:55 ` [RFC PATCH 1/5] of: property: Add in-ports/out-ports support to of_fwnode_graph_get_port_parent() Sunil V L
2026-09-29 8:55 ` [RFC PATCH 2/5] ACPI: property: Add ports/in-ports/out-ports support to acpi_fwnode_get_parent() Sunil V L
2026-09-29 8:55 ` [RFC PATCH 3/5] ACPI: property: Add device graph support Sunil V L
2026-09-29 8:55 ` [RFC PATCH 4/5] hwtracing: rvtrace: Move to fwnode_* APIs Sunil V L
2026-09-29 8:55 ` Sunil V L [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=20260929085524.1554507-6-sunilvl@oss.qualcomm.com \
--to=sunilvl@oss.qualcomm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=anup@brainfault.org \
--cc=devicetree@vger.kernel.org \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mchitale@gmail.com \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@kernel.org \
/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®