]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Disable source helpers in coresight_disable_path()
authorLeo Yan <leo.yan@arm.com>
Fri, 15 May 2026 20:08:22 +0000 (21:08 +0100)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Mon, 18 May 2026 09:18:46 +0000 (10:18 +0100)
coresight_enable_path() enables helpers attached to every device in
the path, including those bound to the source. However,
coresight_disable_path() skips the source node, so source helpers had
to be disabled separately in coresight_disable_source().

Move source helper disabling into coresight_disable_path() instead.
Make coresight_disable_path_from() start from the passed node nd, so
it can also disable helpers on the source. Update the comments
accordingly.

As coresight_disable_path_from() now changes its semantics from
"start beyond nd" to "start from nd", update the failure handling in
coresight_enable_path(). If enabling a node fails, iterate to the
previous node (the last successfully enabled one) and pass it to
coresight_disable_path_from() for rollback.

Tested-by: Jie Gan <jie.gan@oss.qualcomm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260515-arm_coresight_path_power_management_improvement-v14-15-f88c4a3ecfe9@arm.com
drivers/hwtracing/coresight/coresight-core.c

index 309f3a844e8fc653771fb0bf19aeb43efc998dd7..d65cdce1dfef9bb1df40eb7df67274d2f6b30750 100644 (file)
@@ -456,19 +456,12 @@ static void coresight_disable_helpers(struct coresight_device *csdev,
 }
 
 /*
- * Helper function to call source_ops(csdev)->disable and also disable the
- * helpers.
- *
- * There is an imbalance between coresight_enable_path() and
- * coresight_disable_path(). Enabling also enables the source's helpers as part
- * of the path, but disabling always skips the first item in the path (which is
- * the source), so sources and their helpers don't get disabled as part of that
- * function and we need the extra step here.
+ * coresight_disable_source() only disables the source, but do nothing for
+ * the associated helpers, which are controlled as part of the path.
  */
 void coresight_disable_source(struct coresight_device *csdev, void *data)
 {
        source_ops(csdev)->disable(csdev, data);
-       coresight_disable_helpers(csdev, NULL);
 }
 EXPORT_SYMBOL_GPL(coresight_disable_source);
 
@@ -495,9 +488,9 @@ int coresight_resume_source(struct coresight_device *csdev)
 EXPORT_SYMBOL_GPL(coresight_resume_source);
 
 /*
- * coresight_disable_path_from : Disable components in the given path beyond
- * @nd in the list. If @nd is NULL, all the components, except the SOURCE are
- * disabled.
+ * coresight_disable_path_from : Disable components in the given path starting
+ * from @nd in the list. If @nd is NULL, all the components, except the SOURCE
+ * are disabled.
  */
 static void coresight_disable_path_from(struct coresight_path *path,
                                        struct coresight_node *nd)
@@ -508,7 +501,7 @@ static void coresight_disable_path_from(struct coresight_path *path,
        if (!nd)
                nd = list_first_entry(&path->path_list, struct coresight_node, link);
 
-       list_for_each_entry_continue(nd, &path->path_list, link) {
+       list_for_each_entry_from(nd, &path->path_list, link) {
                csdev = nd->csdev;
                type = csdev->type;
 
@@ -528,12 +521,6 @@ static void coresight_disable_path_from(struct coresight_path *path,
                        coresight_disable_sink(csdev);
                        break;
                case CORESIGHT_DEV_TYPE_SOURCE:
-                       /*
-                        * We skip the first node in the path assuming that it
-                        * is the source. So we don't expect a source device in
-                        * the middle of a path.
-                        */
-                       WARN_ON(1);
                        break;
                case CORESIGHT_DEV_TYPE_LINK:
                        parent = list_prev_entry(nd, link)->csdev;
@@ -648,6 +635,8 @@ out:
 err_disable_helpers:
        coresight_disable_helpers(csdev, path);
 err_disable_path:
+       /* Fetch the previous node, the last successfully enabled one */
+       nd = list_next_entry(nd, link);
        coresight_disable_path_from(path, nd);
        goto out;
 }