* [PATCH v4 0/2] coresight: Add remote etm support
@ 2025-01-21 6:38 Mao Jinlong
2025-01-21 6:38 ` [PATCH v4 1/2] dt-bindings: arm: Update compatible for remote etm Mao Jinlong
2025-01-21 6:39 ` [PATCH v4 2/2] coresight: Add remote etm support Mao Jinlong
0 siblings, 2 replies; 5+ messages in thread
From: Mao Jinlong @ 2025-01-21 6:38 UTC (permalink / raw)
To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alexander Shishkin
Cc: Mao Jinlong, linux-kernel, coresight, linux-arm-kernel,
linux-arm-msm, devicetree
The system on chip (SoC) consists of main APSS(Applications processor
subsytem) and additional processors like modem, lpass. There is
coresight-etm driver for etm trace of APSS. Coresight remote etm driver
is for enabling and disabling the etm trace of remote processors.
It uses QMI interface to communicate with remote processors' software
and uses coresight framework to configure the connection from remote
etm source to TMC sinks.
Example to capture the remote etm trace:
Enable source:
echo 1 > /sys/bus/coresight/devices/tmc_etf0/enable_sink
echo 1 > /sys/bus/coresight/devices/remote_etm0/enable_source
Capture the trace:
cat /dev/tmc_etf0 > /data/remote_etm.bin
Disable source:
echo 0 > /sys/bus/coresight/devices/remote_etm0/enable_source
Changes since V3:
1. Use different compatible for different remote etms in dt.
2. Get qmi instance id from the match table data in driver.
Change since V2:
1. Change qcom,inst-id to qcom,qmi-id
2. Fix the error in code for type of remote_etm_remove
3. Depend on QMI helper in Kconfig
Changes since V1:
1. Remove unused content
2. Use CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS as remote etm source type.
3. Use enabled instead of enable in driver data.
4. Validate instance id value where it's read from the DT.
Mao Jinlong (2):
dt-bindings: arm: Update compatible for remote etm
coresight: Add remote etm support
.../arm/qcom,coresight-remote-etm.yaml | 11 +-
drivers/hwtracing/coresight/Kconfig | 13 +
drivers/hwtracing/coresight/Makefile | 1 +
drivers/hwtracing/coresight/coresight-qmi.h | 89 +++++
.../coresight/coresight-remote-etm.c | 316 ++++++++++++++++++
5 files changed, 428 insertions(+), 2 deletions(-)
create mode 100644 drivers/hwtracing/coresight/coresight-qmi.h
create mode 100644 drivers/hwtracing/coresight/coresight-remote-etm.c
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 1/2] dt-bindings: arm: Update compatible for remote etm
2025-01-21 6:38 [PATCH v4 0/2] coresight: Add remote etm support Mao Jinlong
@ 2025-01-21 6:38 ` Mao Jinlong
2025-01-21 8:56 ` Krzysztof Kozlowski
2025-01-21 6:39 ` [PATCH v4 2/2] coresight: Add remote etm support Mao Jinlong
1 sibling, 1 reply; 5+ messages in thread
From: Mao Jinlong @ 2025-01-21 6:38 UTC (permalink / raw)
To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alexander Shishkin
Cc: Mao Jinlong, linux-kernel, coresight, linux-arm-kernel,
linux-arm-msm, devicetree
Use different compatible to distinguish between different remote
etms.
Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
---
.../bindings/arm/qcom,coresight-remote-etm.yaml | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml b/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
index 4fd5752978cd..199f2ca4b8a9 100644
--- a/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
@@ -18,7 +18,14 @@ description:
properties:
compatible:
- const: qcom,coresight-remote-etm
+ contains:
+ enum:
+ - qcom,coresight-modem-etm
+ - qcom,coresight-wcn-etm
+ - qcom,coresight-adsp-etm
+ - qcom,coresight-sensor-etm
+ - qcom,coresight-modem2-etm
+ - qcom,coresight-cdsp-etm
out-ports:
$ref: /schemas/graph.yaml#/properties/ports
@@ -38,7 +45,7 @@ additionalProperties: false
examples:
- |
etm {
- compatible = "qcom,coresight-remote-etm";
+ compatible = "qcom,coresight-modem-etm";
out-ports {
port {
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/2] coresight: Add remote etm support
2025-01-21 6:38 [PATCH v4 0/2] coresight: Add remote etm support Mao Jinlong
2025-01-21 6:38 ` [PATCH v4 1/2] dt-bindings: arm: Update compatible for remote etm Mao Jinlong
@ 2025-01-21 6:39 ` Mao Jinlong
2025-01-21 9:00 ` Krzysztof Kozlowski
1 sibling, 1 reply; 5+ messages in thread
From: Mao Jinlong @ 2025-01-21 6:39 UTC (permalink / raw)
To: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alexander Shishkin
Cc: Mao Jinlong, linux-kernel, coresight, linux-arm-kernel,
linux-arm-msm, devicetree
The system on chip (SoC) consists of main APSS(Applications
processor subsytem) and additional processors like modem, lpass.
Coresight remote etm(Embedded Trace Macrocell) driver is for
enabling and disabling the etm trace of remote processors. It
uses QMI interface to communicate with remote processors' software
and uses coresight framework to configure the connection from
remote etm source to TMC sinks.
Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
---
drivers/hwtracing/coresight/Kconfig | 13 +
drivers/hwtracing/coresight/Makefile | 1 +
drivers/hwtracing/coresight/coresight-qmi.h | 89 +++++
.../coresight/coresight-remote-etm.c | 316 ++++++++++++++++++
4 files changed, 419 insertions(+)
create mode 100644 drivers/hwtracing/coresight/coresight-qmi.h
create mode 100644 drivers/hwtracing/coresight/coresight-remote-etm.c
diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig
index 06f0a7594169..871dd83649ea 100644
--- a/drivers/hwtracing/coresight/Kconfig
+++ b/drivers/hwtracing/coresight/Kconfig
@@ -247,4 +247,17 @@ config CORESIGHT_DUMMY
To compile this driver as a module, choose M here: the module will be
called coresight-dummy.
+
+config CORESIGHT_REMOTE_ETM
+ tristate "Remote processor ETM trace support"
+ depends on QCOM_QMI_HELPERS
+ help
+ Enables support for ETM trace collection on remote processor using
+ CoreSight framework. Enabling this will allow turning on ETM
+ tracing on remote processor via sysfs by configuring the required
+ CoreSight components.
+
+ To compile this driver as a module, choose M here: the module will be
+ called coresight-remote-etm.
+
endif
diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile
index 4ba478211b31..e0781d729eb3 100644
--- a/drivers/hwtracing/coresight/Makefile
+++ b/drivers/hwtracing/coresight/Makefile
@@ -51,3 +51,4 @@ coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \
coresight-cti-sysfs.o
obj-$(CONFIG_ULTRASOC_SMB) += ultrasoc-smb.o
obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
+obj-$(CONFIG_CORESIGHT_REMOTE_ETM) += coresight-remote-etm.o
diff --git a/drivers/hwtracing/coresight/coresight-qmi.h b/drivers/hwtracing/coresight/coresight-qmi.h
new file mode 100644
index 000000000000..c9b49500d11c
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-qmi.h
@@ -0,0 +1,89 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#ifndef _CORESIGHT_QMI_H
+#define _CORESIGHT_QMI_H
+
+#include <linux/soc/qcom/qmi.h>
+
+#define CORESIGHT_QMI_SVC_ID (0x33)
+#define CORESIGHT_QMI_VERSION (1)
+
+#define CORESIGHT_QMI_GET_ETM_REQ_V01 (0x002B)
+#define CORESIGHT_QMI_GET_ETM_RESP_V01 (0x002B)
+#define CORESIGHT_QMI_SET_ETM_REQ_V01 (0x002C)
+#define CORESIGHT_QMI_SET_ETM_RESP_V01 (0x002C)
+
+#define CORESIGHT_QMI_GET_ETM_REQ_MAX_LEN (0)
+#define CORESIGHT_QMI_GET_ETM_RESP_MAX_LEN (14)
+#define CORESIGHT_QMI_SET_ETM_REQ_MAX_LEN (7)
+#define CORESIGHT_QMI_SET_ETM_RESP_MAX_LEN (7)
+
+#define TIMEOUT_MS (10000)
+
+enum coresight_etm_state_enum_type_v01 {
+ /* To force a 32 bit signed enum. Do not change or use */
+ CORESIGHT_ETM_STATE_ENUM_TYPE_MIN_ENUM_VAL_V01 = INT_MIN,
+ CORESIGHT_ETM_STATE_DISABLED_V01 = 0,
+ CORESIGHT_ETM_STATE_ENABLED_V01 = 1,
+ CORESIGHT_ETM_STATE_ENUM_TYPE_MAX_ENUM_VAL_01 = INT_MAX,
+};
+
+struct coresight_set_etm_req_msg_v01 {
+ /* Mandatory */
+ /* ETM output state */
+ enum coresight_etm_state_enum_type_v01 state;
+};
+
+struct coresight_set_etm_resp_msg_v01 {
+ /* Mandatory */
+ struct qmi_response_type_v01 resp;
+};
+
+static struct qmi_elem_info coresight_set_etm_req_msg_v01_ei[] = {
+ {
+ .data_type = QMI_UNSIGNED_4_BYTE,
+ .elem_len = 1,
+ .elem_size = sizeof(enum coresight_etm_state_enum_type_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x01,
+ .offset = offsetof(struct coresight_set_etm_req_msg_v01,
+ state),
+ .ei_array = NULL,
+ },
+ {
+ .data_type = QMI_EOTI,
+ .elem_len = 0,
+ .elem_size = 0,
+ .array_type = NO_ARRAY,
+ .tlv_type = 0,
+ .offset = 0,
+ .ei_array = NULL,
+ },
+};
+
+static struct qmi_elem_info coresight_set_etm_resp_msg_v01_ei[] = {
+ {
+ .data_type = QMI_STRUCT,
+ .elem_len = 1,
+ .elem_size = sizeof(struct qmi_response_type_v01),
+ .array_type = NO_ARRAY,
+ .tlv_type = 0x02,
+ .offset = offsetof(struct coresight_set_etm_resp_msg_v01,
+ resp),
+ .ei_array = qmi_response_type_v01_ei,
+ },
+ {
+ .data_type = QMI_EOTI,
+ .elem_len = 0,
+ .elem_size = 0,
+ .array_type = NO_ARRAY,
+ .tlv_type = 0,
+ .offset = 0,
+ .ei_array = NULL,
+ },
+};
+
+#endif
diff --git a/drivers/hwtracing/coresight/coresight-remote-etm.c b/drivers/hwtracing/coresight/coresight-remote-etm.c
new file mode 100644
index 000000000000..e302837756c9
--- /dev/null
+++ b/drivers/hwtracing/coresight/coresight-remote-etm.c
@@ -0,0 +1,316 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/io.h>
+#include <linux/err.h>
+#include <linux/sysfs.h>
+#include <linux/mutex.h>
+#include <linux/of.h>
+#include <linux/coresight.h>
+#include "coresight-qmi.h"
+#include "coresight-priv.h"
+
+DEFINE_CORESIGHT_DEVLIST(remote_etm_devs, "remote-etm");
+
+/* Instance id of modem processor */
+#define MODEM_INSTANCE_ID 0x2
+/* Instance id of Wireless Communication Network (WCN) */
+#define WCN_INSTANCE_ID 0x3
+/* Instance id of Audio Digital Signal Processor */
+#define ADSP_INSTANCE_ID 0x5
+/* Instance id of Sensor processor */
+#define SENSOR_INSTANCE_ID 0x8
+/* Instance id of modem2 processor */
+#define MODEM2_INSTANCE_ID 0xB
+/* Instance id of Compute Digital Signal Processor */
+#define CDSP_INSTANCE_ID 0xD
+
+struct remote_etm_drvdata {
+ struct device *dev;
+ struct coresight_device *csdev;
+ struct mutex mutex;
+ struct qmi_handle handle;
+ u32 qmi_id;
+ bool enabled;
+ bool service_connected;
+ struct sockaddr_qrtr s_addr;
+};
+
+static int service_remote_etm_new_server(struct qmi_handle *qmi,
+ struct qmi_service *svc)
+{
+ struct remote_etm_drvdata *drvdata = container_of(qmi,
+ struct remote_etm_drvdata, handle);
+
+ drvdata->s_addr.sq_family = AF_QIPCRTR;
+ drvdata->s_addr.sq_node = svc->node;
+ drvdata->s_addr.sq_port = svc->port;
+ drvdata->service_connected = true;
+ dev_info(drvdata->dev,
+ "Connection established between QMI handle and %d service\n",
+ drvdata->qmi_id);
+
+ return 0;
+}
+
+static void service_remote_etm_del_server(struct qmi_handle *qmi,
+ struct qmi_service *svc)
+{
+ struct remote_etm_drvdata *drvdata = container_of(qmi,
+ struct remote_etm_drvdata, handle);
+ drvdata->service_connected = false;
+ dev_info(drvdata->dev,
+ "Connection disconnected between QMI handle and %d service\n",
+ drvdata->qmi_id);
+}
+
+static struct qmi_ops server_ops = {
+ .new_server = service_remote_etm_new_server,
+ .del_server = service_remote_etm_del_server,
+};
+
+static int remote_etm_enable(struct coresight_device *csdev,
+ struct perf_event *event, enum cs_mode mode,
+ __maybe_unused struct coresight_trace_id_map *id_map)
+{
+ struct remote_etm_drvdata *drvdata =
+ dev_get_drvdata(csdev->dev.parent);
+ struct coresight_set_etm_req_msg_v01 req;
+ struct coresight_set_etm_resp_msg_v01 resp = { { 0, 0 } };
+ struct qmi_txn txn;
+ int ret;
+
+ mutex_lock(&drvdata->mutex);
+
+ if (!drvdata->service_connected) {
+ dev_err(drvdata->dev, "QMI service not connected!\n");
+ ret = -EINVAL;
+ goto err;
+ }
+ /*
+ * The QMI handle may be NULL in the following scenarios:
+ * 1. QMI service is not present
+ * 2. QMI service is present but attempt to enable remote ETM is earlier
+ * than service is ready to handle request
+ * 3. Connection between QMI client and QMI service failed
+ *
+ * Enable CoreSight without processing further QMI commands which
+ * provides the option to enable remote ETM by other means.
+ */
+ req.state = CORESIGHT_ETM_STATE_ENABLED_V01;
+
+ ret = qmi_txn_init(&drvdata->handle, &txn,
+ coresight_set_etm_resp_msg_v01_ei,
+ &resp);
+
+ if (ret < 0) {
+ dev_err(drvdata->dev, "QMI tx init failed , ret:%d\n",
+ ret);
+ goto err;
+ }
+
+ ret = qmi_send_request(&drvdata->handle, &drvdata->s_addr,
+ &txn, CORESIGHT_QMI_SET_ETM_REQ_V01,
+ CORESIGHT_QMI_SET_ETM_REQ_MAX_LEN,
+ coresight_set_etm_req_msg_v01_ei,
+ &req);
+ if (ret < 0) {
+ dev_err(drvdata->dev, "QMI send ACK failed, ret:%d\n",
+ ret);
+ qmi_txn_cancel(&txn);
+ goto err;
+ }
+
+ ret = qmi_txn_wait(&txn, msecs_to_jiffies(TIMEOUT_MS));
+ if (ret < 0) {
+ dev_err(drvdata->dev, "QMI qmi txn wait failed, ret:%d\n",
+ ret);
+ goto err;
+ }
+
+ /* Check the response */
+ if (resp.resp.result != QMI_RESULT_SUCCESS_V01)
+ dev_err(drvdata->dev, "QMI request failed 0x%x\n",
+ resp.resp.error);
+
+ drvdata->enabled = true;
+ mutex_unlock(&drvdata->mutex);
+
+ dev_dbg(drvdata->dev, "Remote ETM tracing enabled for instance %d\n",
+ drvdata->qmi_id);
+ return 0;
+err:
+ mutex_unlock(&drvdata->mutex);
+ return ret;
+}
+
+static void remote_etm_disable(struct coresight_device *csdev,
+ struct perf_event *event)
+{
+ struct remote_etm_drvdata *drvdata =
+ dev_get_drvdata(csdev->dev.parent);
+ struct coresight_set_etm_req_msg_v01 req;
+ struct coresight_set_etm_resp_msg_v01 resp = { { 0, 0 } };
+ struct qmi_txn txn;
+ int ret;
+
+ mutex_lock(&drvdata->mutex);
+ if (!drvdata->service_connected) {
+ dev_err(drvdata->dev, "QMI service not connected!\n");
+ goto err;
+ }
+
+ req.state = CORESIGHT_ETM_STATE_DISABLED_V01;
+
+ ret = qmi_txn_init(&drvdata->handle, &txn,
+ coresight_set_etm_resp_msg_v01_ei,
+ &resp);
+
+ if (ret < 0) {
+ dev_err(drvdata->dev, "QMI tx init failed , ret:%d\n",
+ ret);
+ goto err;
+ }
+
+ ret = qmi_send_request(&drvdata->handle, &drvdata->s_addr,
+ &txn, CORESIGHT_QMI_SET_ETM_REQ_V01,
+ CORESIGHT_QMI_SET_ETM_REQ_MAX_LEN,
+ coresight_set_etm_req_msg_v01_ei,
+ &req);
+ if (ret < 0) {
+ dev_err(drvdata->dev, "QMI send req failed, ret:%d\n",
+ ret);
+ qmi_txn_cancel(&txn);
+ goto err;
+ }
+
+ ret = qmi_txn_wait(&txn, msecs_to_jiffies(TIMEOUT_MS));
+ if (ret < 0) {
+ dev_err(drvdata->dev, "QMI qmi txn wait failed, ret:%d\n",
+ ret);
+ goto err;
+ }
+
+ /* Check the response */
+ if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
+ dev_err(drvdata->dev, "QMI request failed 0x%x\n",
+ resp.resp.error);
+ goto err;
+ }
+
+ drvdata->enabled = false;
+ dev_info(drvdata->dev, "Remote ETM tracing disabled for instance %d\n",
+ drvdata->qmi_id);
+err:
+ mutex_unlock(&drvdata->mutex);
+}
+
+static const struct coresight_ops_source remote_etm_source_ops = {
+ .enable = remote_etm_enable,
+ .disable = remote_etm_disable,
+};
+
+static const struct coresight_ops remote_cs_ops = {
+ .source_ops = &remote_etm_source_ops,
+};
+
+static int remote_etm_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct coresight_platform_data *pdata;
+ struct remote_etm_drvdata *drvdata;
+ struct coresight_desc desc = {0 };
+ int ret;
+
+ desc.name = coresight_alloc_device_name(&remote_etm_devs, dev);
+ if (!desc.name)
+ return -ENOMEM;
+ pdata = coresight_get_platform_data(dev);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ pdev->dev.platform_data = pdata;
+
+ pm_runtime_enable(dev);
+ drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
+ if (!drvdata)
+ return -ENOMEM;
+
+ drvdata->dev = &pdev->dev;
+ platform_set_drvdata(pdev, drvdata);
+
+ drvdata->qmi_id = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);
+
+ mutex_init(&drvdata->mutex);
+
+ ret = qmi_handle_init(&drvdata->handle,
+ CORESIGHT_QMI_SET_ETM_REQ_MAX_LEN,
+ &server_ops, NULL);
+ if (ret < 0) {
+ dev_err_probe(dev, ret, "Remote ETM client init failed.\n");
+ return ret;
+ }
+
+ qmi_add_lookup(&drvdata->handle,
+ CORESIGHT_QMI_SVC_ID,
+ CORESIGHT_QMI_VERSION,
+ drvdata->qmi_id);
+
+ desc.type = CORESIGHT_DEV_TYPE_SOURCE;
+ desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS;
+ desc.ops = &remote_cs_ops;
+ desc.pdata = pdev->dev.platform_data;
+ desc.dev = &pdev->dev;
+ drvdata->csdev = coresight_register(&desc);
+ if (IS_ERR(drvdata->csdev)) {
+ ret = PTR_ERR(drvdata->csdev);
+ goto err;
+ }
+
+ return 0;
+err:
+ qmi_handle_release(&drvdata->handle);
+ return ret;
+}
+
+static void remote_etm_remove(struct platform_device *pdev)
+{
+ struct remote_etm_drvdata *drvdata = platform_get_drvdata(pdev);
+ struct device *dev = &pdev->dev;
+
+ pm_runtime_disable(dev);
+ qmi_handle_release(&drvdata->handle);
+ coresight_unregister(drvdata->csdev);
+}
+
+static const struct of_device_id remote_etm_match[] = {
+ {.compatible = "qcom,coresight-modem-etm", .data = (void *)MODEM_INSTANCE_ID},
+ {.compatible = "qcom,coresight-wcn-etm", .data = (void *)WCN_INSTANCE_ID},
+ {.compatible = "qcom,coresight-adsp-etm", .data = (void *)ADSP_INSTANCE_ID},
+ {.compatible = "qcom,coresight-sensor-etm", .data = (void *)SENSOR_INSTANCE_ID},
+ {.compatible = "qcom,coresight-modem2-etm", .data = (void *)MODEM2_INSTANCE_ID},
+ {.compatible = "qcom,coresight-cdsp-etm", .data = (void *)CDSP_INSTANCE_ID},
+ {},
+};
+
+static struct platform_driver remote_etm_driver = {
+ .probe = remote_etm_probe,
+ .remove = remote_etm_remove,
+ .driver = {
+ .name = "coresight-remote-etm",
+ .of_match_table = remote_etm_match,
+ },
+};
+
+module_platform_driver(remote_etm_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("CoreSight Remote ETM driver");
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/2] dt-bindings: arm: Update compatible for remote etm
2025-01-21 6:38 ` [PATCH v4 1/2] dt-bindings: arm: Update compatible for remote etm Mao Jinlong
@ 2025-01-21 8:56 ` Krzysztof Kozlowski
0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-21 8:56 UTC (permalink / raw)
To: Mao Jinlong
Cc: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alexander Shishkin,
linux-kernel, coresight, linux-arm-kernel, linux-arm-msm,
devicetree
On Tue, Jan 21, 2025 at 02:38:59PM +0800, Mao Jinlong wrote:
> Use different compatible to distinguish between different remote
> etms.
Why?
Every second time for qcom. Don't say what, we see that easily.
>
> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
> ---
> .../bindings/arm/qcom,coresight-remote-etm.yaml | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml b/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
> index 4fd5752978cd..199f2ca4b8a9 100644
> --- a/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
> +++ b/Documentation/devicetree/bindings/arm/qcom,coresight-remote-etm.yaml
> @@ -18,7 +18,14 @@ description:
>
> properties:
> compatible:
> - const: qcom,coresight-remote-etm
> + contains:
No, you are now saying this is "qcom,pink-pony" as well...
Sorry, this change is neither explained, nor correct.
> + enum:
> + - qcom,coresight-modem-etm
> + - qcom,coresight-wcn-etm
> + - qcom,coresight-adsp-etm
> + - qcom,coresight-sensor-etm
> + - qcom,coresight-modem2-etma
And how anyone can understand the difference between modem and modem2?
NAK for entire patch in this form.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] coresight: Add remote etm support
2025-01-21 6:39 ` [PATCH v4 2/2] coresight: Add remote etm support Mao Jinlong
@ 2025-01-21 9:00 ` Krzysztof Kozlowski
0 siblings, 0 replies; 5+ messages in thread
From: Krzysztof Kozlowski @ 2025-01-21 9:00 UTC (permalink / raw)
To: Mao Jinlong
Cc: Suzuki K Poulose, Mike Leach, James Clark, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Alexander Shishkin,
linux-kernel, coresight, linux-arm-kernel, linux-arm-msm,
devicetree
On Tue, Jan 21, 2025 at 02:39:00PM +0800, Mao Jinlong wrote:
> The system on chip (SoC) consists of main APSS(Applications
> processor subsytem) and additional processors like modem, lpass.
> Coresight remote etm(Embedded Trace Macrocell) driver is for
> enabling and disabling the etm trace of remote processors. It
> uses QMI interface to communicate with remote processors' software
> and uses coresight framework to configure the connection from
> remote etm source to TMC sinks.
>
> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
> ---
> drivers/hwtracing/coresight/Kconfig | 13 +
> drivers/hwtracing/coresight/Makefile | 1 +
> drivers/hwtracing/coresight/coresight-qmi.h | 89 +++++
> .../coresight/coresight-remote-etm.c | 316 ++++++++++++++++++
> 4 files changed, 419 insertions(+)
> create mode 100644 drivers/hwtracing/coresight/coresight-qmi.h
> create mode 100644 drivers/hwtracing/coresight/coresight-remote-etm.c
>
> diff --git a/drivers/hwtracing/coresight/Kconfig b/drivers/hwtracing/coresight/Kconfig
> index 06f0a7594169..871dd83649ea 100644
> --- a/drivers/hwtracing/coresight/Kconfig
> +++ b/drivers/hwtracing/coresight/Kconfig
> @@ -247,4 +247,17 @@ config CORESIGHT_DUMMY
>
> To compile this driver as a module, choose M here: the module will be
> called coresight-dummy.
> +
> +config CORESIGHT_REMOTE_ETM
> + tristate "Remote processor ETM trace support"
> + depends on QCOM_QMI_HELPERS
> + help
> + Enables support for ETM trace collection on remote processor using
> + CoreSight framework. Enabling this will allow turning on ETM
> + tracing on remote processor via sysfs by configuring the required
> + CoreSight components.
> +
> + To compile this driver as a module, choose M here: the module will be
> + called coresight-remote-etm.
> +
> endif
> diff --git a/drivers/hwtracing/coresight/Makefile b/drivers/hwtracing/coresight/Makefile
> index 4ba478211b31..e0781d729eb3 100644
> --- a/drivers/hwtracing/coresight/Makefile
> +++ b/drivers/hwtracing/coresight/Makefile
> @@ -51,3 +51,4 @@ coresight-cti-y := coresight-cti-core.o coresight-cti-platform.o \
> coresight-cti-sysfs.o
> obj-$(CONFIG_ULTRASOC_SMB) += ultrasoc-smb.o
> obj-$(CONFIG_CORESIGHT_DUMMY) += coresight-dummy.o
> +obj-$(CONFIG_CORESIGHT_REMOTE_ETM) += coresight-remote-etm.o
> diff --git a/drivers/hwtracing/coresight/coresight-qmi.h b/drivers/hwtracing/coresight/coresight-qmi.h
> new file mode 100644
> index 000000000000..c9b49500d11c
> --- /dev/null
> +++ b/drivers/hwtracing/coresight/coresight-qmi.h
> @@ -0,0 +1,89 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
> + */
> +
> +#ifndef _CORESIGHT_QMI_H
> +#define _CORESIGHT_QMI_H
> +
> +#include <linux/soc/qcom/qmi.h>
> +
> +#define CORESIGHT_QMI_SVC_ID (0x33)
> +#define CORESIGHT_QMI_VERSION (1)
> +
> +#define CORESIGHT_QMI_GET_ETM_REQ_V01 (0x002B)
> +#define CORESIGHT_QMI_GET_ETM_RESP_V01 (0x002B)
> +#define CORESIGHT_QMI_SET_ETM_REQ_V01 (0x002C)
> +#define CORESIGHT_QMI_SET_ETM_RESP_V01 (0x002C)
> +
> +#define CORESIGHT_QMI_GET_ETM_REQ_MAX_LEN (0)
> +#define CORESIGHT_QMI_GET_ETM_RESP_MAX_LEN (14)
> +#define CORESIGHT_QMI_SET_ETM_REQ_MAX_LEN (7)
> +#define CORESIGHT_QMI_SET_ETM_RESP_MAX_LEN (7)
> +
> +#define TIMEOUT_MS (10000)
> +
> +enum coresight_etm_state_enum_type_v01 {
> + /* To force a 32 bit signed enum. Do not change or use */
> + CORESIGHT_ETM_STATE_ENUM_TYPE_MIN_ENUM_VAL_V01 = INT_MIN,
> + CORESIGHT_ETM_STATE_DISABLED_V01 = 0,
> + CORESIGHT_ETM_STATE_ENABLED_V01 = 1,
> + CORESIGHT_ETM_STATE_ENUM_TYPE_MAX_ENUM_VAL_01 = INT_MAX,
> +};
> +
> +struct coresight_set_etm_req_msg_v01 {
> + /* Mandatory */
> + /* ETM output state */
> + enum coresight_etm_state_enum_type_v01 state;
> +};
> +
> +struct coresight_set_etm_resp_msg_v01 {
> + /* Mandatory */
> + struct qmi_response_type_v01 resp;
> +};
> +
> +static struct qmi_elem_info coresight_set_etm_req_msg_v01_ei[] = {
Why, unlike every other instance, this cannot be const?
Anyway, you cannot have DATA in the header. This makes little sense.
There is no such patterns so I don't understand from where did you get
this.
...
> + {
> + .data_type = QMI_UNSIGNED_4_BYTE,
> + .elem_len = 1,
> + .elem_size = sizeof(enum coresight_etm_state_enum_type_v01),
> + .array_type = NO_ARRAY,
> + .tlv_type = 0x01,
> + .offset = offsetof(struct coresight_set_etm_req_msg_v01,
> + state),
> + .ei_array = NULL,
> + },
> +static int remote_etm_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct coresight_platform_data *pdata;
> + struct remote_etm_drvdata *drvdata;
> + struct coresight_desc desc = {0 };
> + int ret;
> +
> + desc.name = coresight_alloc_device_name(&remote_etm_devs, dev);
> + if (!desc.name)
> + return -ENOMEM;
> + pdata = coresight_get_platform_data(dev);
> + if (IS_ERR(pdata))
> + return PTR_ERR(pdata);
> + pdev->dev.platform_data = pdata;
> +
> + pm_runtime_enable(dev);
> + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> + if (!drvdata)
> + return -ENOMEM;
> +
> + drvdata->dev = &pdev->dev;
Use the cached value, if you cache it.
= dev
> + platform_set_drvdata(pdev, drvdata);
> +
> + drvdata->qmi_id = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);
Ditto, everywhere...
> +
> + mutex_init(&drvdata->mutex);
> +
> + ret = qmi_handle_init(&drvdata->handle,
> + CORESIGHT_QMI_SET_ETM_REQ_MAX_LEN,
> + &server_ops, NULL);
> + if (ret < 0) {
> + dev_err_probe(dev, ret, "Remote ETM client init failed.\n");
Syntax is always: return dev_err_probe. I am pretty sure you got this
feedback before.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-01-21 9:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-21 6:38 [PATCH v4 0/2] coresight: Add remote etm support Mao Jinlong
2025-01-21 6:38 ` [PATCH v4 1/2] dt-bindings: arm: Update compatible for remote etm Mao Jinlong
2025-01-21 8:56 ` Krzysztof Kozlowski
2025-01-21 6:39 ` [PATCH v4 2/2] coresight: Add remote etm support Mao Jinlong
2025-01-21 9:00 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox