Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions drivers/hwtracing/coresight/coresight-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,8 +792,8 @@ static int coresight_get_trace_id(struct coresight_device *csdev,
* Call this after creating the path and before enabling it. This leaves
* the trace ID set on the path, or it remains 0 if it couldn't be assigned.
*/
void coresight_path_assign_trace_id(struct coresight_path *path,
enum cs_mode mode)
int coresight_path_assign_trace_id(struct coresight_path *path,
enum cs_mode mode)
{
struct coresight_device *sink = coresight_get_sink(path);
struct coresight_node *nd;
Expand All @@ -804,14 +804,21 @@ void coresight_path_assign_trace_id(struct coresight_path *path,
trace_id = coresight_get_trace_id(nd->csdev, mode, sink);

/*
* 0 in this context is that it didn't want to assign so keep searching.
* Non 0 is either success or fail.
* 0 means the device has no ID assignment, and -EOPNOTSUPP
* means the device explicitly declines to assign one (e.g. a
* pass-through NoC) - in both cases keep searching downstream.
*/
if (trace_id != 0) {
path->trace_id = trace_id;
return;
}
if (trace_id == 0 || trace_id == -EOPNOTSUPP)
continue;

if (!IS_VALID_CS_TRACE_ID(trace_id))
return -EINVAL;

path->trace_id = trace_id;
return 0;
}

return -EINVAL;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions drivers/hwtracing/coresight/coresight-etm-perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
struct coresight_device *sink = NULL;
struct coresight_device *user_sink = NULL, *last_sink = NULL;
struct etm_event_data *event_data = NULL;
int ret;

event_data = alloc_event_data(cpu);
if (!event_data)
Expand Down Expand Up @@ -418,8 +419,8 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
}

/* ensure we can allocate a trace ID for this CPU */
coresight_path_assign_trace_id(path, CS_MODE_PERF);
if (!IS_VALID_CS_TRACE_ID(path->trace_id)) {
ret = coresight_path_assign_trace_id(path, CS_MODE_PERF);
if (ret) {
cpumask_clear_cpu(cpu, mask);
coresight_release_path(path);
continue;
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwtracing/coresight/coresight-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ int coresight_make_links(struct coresight_device *orig,
void coresight_remove_links(struct coresight_device *orig,
struct coresight_connection *conn);
u32 coresight_get_sink_id(struct coresight_device *csdev);
void coresight_path_assign_trace_id(struct coresight_path *path,
int coresight_path_assign_trace_id(struct coresight_path *path,
enum cs_mode mode);
int coresight_get_in_port_dest(struct coresight_device *src,
struct coresight_device *dest);
Expand Down
4 changes: 2 additions & 2 deletions drivers/hwtracing/coresight/coresight-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
goto out;
}

coresight_path_assign_trace_id(path, CS_MODE_SYSFS);
if (!IS_VALID_CS_TRACE_ID(path->trace_id))
ret = coresight_path_assign_trace_id(path, CS_MODE_SYSFS);
if (ret)
goto err_path;

ret = coresight_enable_path(path, CS_MODE_SYSFS, NULL);
Expand Down
Loading