Skip to content

Optimize the Coresight Trace id allocation logic - #1032

Open
Jie Gan (jiegan0107) wants to merge 2 commits into
qualcomm-linux:qcom-6.18.yfrom
jiegan0107:qcom-6.18.y
Open

Optimize the Coresight Trace id allocation logic#1032
Jie Gan (jiegan0107) wants to merge 2 commits into
qualcomm-linux:qcom-6.18.yfrom
jiegan0107:qcom-6.18.y

Conversation

@jiegan0107

Copy link
Copy Markdown

Optimize the Coresight Trace id allocation logic

CRs-Fixed: 4661884

When coresight_path_assign_trace_id() cannot assign a valid trace ID,
coresight_enable_sysfs() takes the err_path goto with ret still 0,
returning success to the caller despite no trace session being started.

Change coresight_path_assign_trace_id() to return int, moving the
IS_VALID_CS_TRACE_ID() check inside it so it returns -EINVAL on failure
and 0 on success. Update both callers to propagate this return value
directly instead of inspecting path->trace_id after the call.

Fixes: d87d76d ("Coresight: Allocate trace ID after building the path")
Reviewed-by: James Clark <james.clark@linaro.org>
Reviewed-by: Richard Cheng <icheng@nvidia.com>
Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
Reviewed-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260512-fix-trace-id-error-v4-1-eb3de789767a@oss.qualcomm.com
…vices

coresight_path_assign_trace_id() only treats a trace_id of 0 as "this
device has no ID assignment, keep searching downstream". Pass-through
NoC links such as itnoc (qcom,coresight-itnoc) intentionally return
-EOPNOTSUPP from their .trace_id callback since they have no ATID
register to program, but that negative value falls through to the
IS_VALID_CS_TRACE_ID() check and is rejected, aborting the whole path
with -EINVAL before the real trace ID owner further downstream is
ever reached.

This breaks enabling any source whose path traverses an itnoc, e.g.
writing 1 to tpdm/enable_source for a TPDM fails with:

  sh: write error: Invalid argument

Skip devices that return -EOPNOTSUPP the same way as devices that
return 0, so the search continues to the next device on the path.

Fixes: f4526ff ("coresight: fix missing error code when trace ID is invalid")
Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
Link: https://lore.kernel.org/all/20260817-fix-trace-id-assign-issue-v1-1-b2164e33f9fa@oss.qualcomm.com/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant