Re: [PATCH v4 02/11] coresight-tpda: Add DSB dataset support

From: Tao Zhang
Date: Thu May 25 2023 - 03:21:29 EST



On 5/23/2023 10:48 PM, Suzuki K Poulose wrote:
On 23/05/2023 11:07, Suzuki K Poulose wrote:
On 27/04/2023 10:00, Tao Zhang wrote:
Read the DSB element size from the device tree. Set the register
bit that controls the DSB element size of the corresponding port.

Signed-off-by: Tao Zhang <quic_taozha@xxxxxxxxxxx>
---
  drivers/hwtracing/coresight/coresight-core.c |  1 +
  drivers/hwtracing/coresight/coresight-tpda.c | 92 +++++++++++++++++++++++++---
  drivers/hwtracing/coresight/coresight-tpda.h |  4 ++
  drivers/hwtracing/coresight/coresight-tpdm.c |  2 +-
  include/linux/coresight.h                    |  1 +
  5 files changed, 90 insertions(+), 10 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index 2af416b..f1eacbb 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1092,6 +1092,7 @@ static int coresight_validate_source(struct coresight_device *csdev,
      if (subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_PROC &&
          subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE &&
+        subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM &&
          subtype != CORESIGHT_DEV_SUBTYPE_SOURCE_OTHERS) {
          dev_err(&csdev->dev, "wrong device subtype in %s\n", function);
          return -EINVAL;

Please see the comment at the bottom.

diff --git a/drivers/hwtracing/coresight/coresight-tpda.c b/drivers/hwtracing/coresight/coresight-tpda.c
index 8d2b9d2..af9c72f 100644
--- a/drivers/hwtracing/coresight/coresight-tpda.c
+++ b/drivers/hwtracing/coresight/coresight-tpda.c
@@ -21,6 +21,56 @@
  DEFINE_CORESIGHT_DEVLIST(tpda_devs, "tpda");
+/* Search and read element data size from the TPDM node in
+ * the devicetree. Each input port of TPDA is connected to
+ * a TPDM. Different TPDM supports different types of dataset,
+ * and some may support more than one type of dataset.
+ * Parameter "inport" is used to pass in the input port number
+ * of TPDA, and it is set to 0 in the recursize call.
+ * Parameter "parent" is used to pass in the original call.
+ */
+static int tpda_set_element_size(struct tpda_drvdata *drvdata,
+               struct coresight_device *csdev, int inport, bool parent)

The name parent is a bit confusing. It could imply parent device ? That
is kind of inverse ? because, parent = true, indicates the parent device
of tpda, which is not true. Could we simply say

bool match_inport => When true, the dest_port of the connection from the
csdev must match the inport ? And ...

Sure, I will update this in the next patch series.
+{
+    static int nr_inport;
+    int i;
+    static bool tpdm_found;
+    struct coresight_device *in_csdev;
+
+    if (inport > (TPDA_MAX_INPORTS - 1))
+        return -EINVAL;
+
+    if (parent) {
+        nr_inport = inport;
+        tpdm_found = false;
+    }
+
+    for (i = 0; i < csdev->pdata->nr_inconns; i++) {
+        in_csdev = csdev->pdata->in_conns[i]->src_dev;
+        if (!in_csdev)
+            break;
+
+        if (parent)
+            if (csdev->pdata->in_conns[i]->dest_port != inport)
+                continue;

The above can become :

        if (match_inport &&
        csdev->pdata->in_conns[i]->dest_port != inport)
        continue;

Sure, I will update this in the next patch series.


Best,

Tao


Suzuki