aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwtracing
diff options
context:
space:
mode:
authorSuzuki K Poulose <suzuki.poulose@arm.com>2018-09-20 15:17:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-25 14:09:17 -0400
commitc71369de02b285d9da526a526d8f2affc7b17c59 (patch)
treec5fd51e797dd22acb0836b10c422b5bc67e2b299 /drivers/hwtracing
parentbbd35ba6fab5419e58e96f35f1431f13bdc14f98 (diff)
coresight: Fix handling of sinks
The coresight components could be operated either in sysfs mode or in perf mode. For some of the components, the mode of operation doesn't matter as they simply relay the data to the next component in the trace path. But for sinks, they need to be able to provide the trace data back to the user. Thus we need to make sure that "mode" is handled appropriately. e.g, the sysfs mode could have multiple sources driving the trace data, while perf mode doesn't allow sharing the sink. The coresight_enable_sink() however doesn't really allow this check to trigger as it skips the "enable_sink" callback if the component is already enabled, irrespective of the mode. This could cause mixing of data from different modes or even same mode (in perf), if the sources are different. Also, if we fail to enable the sink while enabling a path (where sink is the first component enabled), we could end up in disabling the components in the "entire" path which were not enabled in this trial, causing disruptions in the existing trace paths. Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwtracing')
-rw-r--r--drivers/hwtracing/coresight/coresight.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index 5e8880ca8078..07382c55b31d 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -132,12 +132,14 @@ static int coresight_enable_sink(struct coresight_device *csdev, u32 mode)
132{ 132{
133 int ret; 133 int ret;
134 134
135 if (!csdev->enable) { 135 /*
136 if (sink_ops(csdev)->enable) { 136 * We need to make sure the "new" session is compatible with the
137 ret = sink_ops(csdev)->enable(csdev, mode); 137 * existing "mode" of operation.
138 if (ret) 138 */
139 return ret; 139 if (sink_ops(csdev)->enable) {
140 } 140 ret = sink_ops(csdev)->enable(csdev, mode);
141 if (ret)
142 return ret;
141 csdev->enable = true; 143 csdev->enable = true;
142 } 144 }
143 145
@@ -339,8 +341,14 @@ int coresight_enable_path(struct list_head *path, u32 mode)
339 switch (type) { 341 switch (type) {
340 case CORESIGHT_DEV_TYPE_SINK: 342 case CORESIGHT_DEV_TYPE_SINK:
341 ret = coresight_enable_sink(csdev, mode); 343 ret = coresight_enable_sink(csdev, mode);
344 /*
345 * Sink is the first component turned on. If we
346 * failed to enable the sink, there are no components
347 * that need disabling. Disabling the path here
348 * would mean we could disrupt an existing session.
349 */
342 if (ret) 350 if (ret)
343 goto err; 351 goto out;
344 break; 352 break;
345 case CORESIGHT_DEV_TYPE_SOURCE: 353 case CORESIGHT_DEV_TYPE_SOURCE:
346 /* sources are enabled from either sysFS or Perf */ 354 /* sources are enabled from either sysFS or Perf */