Skip to content

Added CoreSight TPDM automated Scripts#363

Open
Rohan-in-Qualcomm wants to merge 1 commit intoqualcomm-linux:mainfrom
Rohan-in-Qualcomm:debug-tpdm
Open

Added CoreSight TPDM automated Scripts#363
Rohan-in-Qualcomm wants to merge 1 commit intoqualcomm-linux:mainfrom
Rohan-in-Qualcomm:debug-tpdm

Conversation

@Rohan-in-Qualcomm
Copy link

@Rohan-in-Qualcomm Rohan-in-Qualcomm commented Mar 23, 2026

This patch adds/updates a suite of automated scripts to validate the functionality and stability of CoreSight TPDM Hardware:

  • TPDM-Interface-Access: Validates sysfs read/write accessibility for various TPDM dataset modes (DSB, CMB, TC, BC, GPR) to ensure the driver exposes and handles attributes correctly.
  • TPDM-Enable-Disable: Stress-tests the hardware and driver state machine by repeatedly toggling the TPDM source nodes on and off.

@Rohan-in-Qualcomm Rohan-in-Qualcomm force-pushed the debug-tpdm branch 2 times, most recently from ead3bd1 to 6ca0019 Compare March 25, 2026 06:58
@smuppand smuppand requested a review from vnarapar March 25, 2026 17:07
@smuppand
Copy link
Contributor

This is 1 commit covering 4 separate new testcases. I would recommend splitting it. These are related thematically, but they are still independent runners/docs/YAMLs and will be much easier to review/fix separately.

exit 1
fi

if [ -z "$__INIT_ENV_LOADED" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the unset-safe/idempotent repo pattern here:

if [ -z "${__INIT_ENV_LOADED:-}" ]; then
    . "$INIT_ENV"
    __INIT_ENV_LOADED=1
fi

The current form expands "$__INIT_ENV_LOADED" directly and does not set the marker after sourcing.


if [ "$tpdm_found" -eq 0 ]; then
log_fail "Result: $TESTNAME FAIL (No TPDM devices found)"
echo "$TESTNAME FAIL" >> "$res_file"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result file write should not append here:

echo "$TESTNAME FAIL" >> "$res_file"

Please use > instead of >>, otherwise repeated or earlier writes can leave inconsistent result-file contents.

continue
fi

mode_atrr "$mode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a real bug:

mode_atrr "$mode"
if mycmd; then

mycmd is undefined, so the return status of mode_atrr is never actually used. This should directly test mode_atrr "$mode" (or $?) instead of calling a non-existent command. As written, this test cannot correctly report attribute-read success/failure.

echo 0 > "$tpdm_path/enable_source" 2>/dev/null
done

if [ "$tpdm_found" -eq 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a failure-to-pass bug here. When no TPDM device is found, the script writes FAIL:

if [ "$tpdm_found" -eq 0 ]; then
...
echo "$TESTNAME FAIL" > "$res_file"
fi

but retval is not updated and the code immediately below can still enter the PASS branch and overwrite the result with PASS. Please set retval=1 here or exit immediately after writing FAIL.

# shellcheck disable=SC2329
cleanup() {
reset_devices
if [ -f "$NPU_CLK" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup() references NPU_CLK, but this variable is never defined anywhere in this script. So this cleanup path is currently dead/misleading. Please either define NPU_CLK like the integration runner does, or remove this branch.

sleep 1

if [ -c "/dev/$sink_dev" ]; then
cat "/dev/$sink_dev" > "/tmp/$sink_dev.bin" 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script claims to validate trace data reaching the sink, but here it only does:

cat "/dev/$sink_dev" > "/tmp/$sink_dev.bin" 2>/dev/null

and never checks whether the read succeeded or whether the output file is non-empty. Please validate the capture result (for example, file created and non-zero size) before treating the pair as successful. Otherwise this is only a best-effort dump, not a sink validation.

## Script Location

```
Runner/suites/Kernel/FunctionalArea/coresight/TPDM-Trace-Sink/run.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented script location is wrong:

Runner/suites/Kernel/FunctionalArea/coresight/TPDM-Trace-Sink/run.sh

but this PR adds the testcase under: Runner/suites/Kernel/DEBUG/TPDM-Trace-Sink/

Please update the README so the path matches the actual repo location.


- Evaluate the enabling and disabling sequence of Coresight TPDM sources against TMC sinks.
- Verify that `enable_source` sysfs nodes accurately reflect read/write state transitions.
- Ensure raw binary trace data can be successfully read from the sink's character device node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README currently says the test ensures raw binary trace data can be successfully read from the sink device node, but the implementation only dumps /dev/$sink_dev to /tmp without checking success or output size. Please either strengthen the implementation or tone down the README claim so they match.

for node in "$CS_BASE"/*; do
[ -d "$node" ] || continue
[ -f "$node/enable_source" ] && echo 0 > "$node/enable_source" 2>/dev/null
[ -f "$node/enable_sink" ] && echo 0 > "$node/enable_sink" 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find_path() and reset_devices() logic is duplicated across multiple new TPDM runners. There does not appear to be an existing CoreSight/TPDM helper in the common libs today, but the duplication is already visible across this PR. Please consider moving the shared CoreSight helpers (sink discovery, source/sink reset, optional NPU clock control) into functestlib.sh or a dedicated shared helper file rather than open-coding them four times.

for node in "$CS_BASE"/*; do
[ -d "$node" ] || continue
[ -f "$node/enable_source" ] && echo 0 > "$node/enable_source" 2>/dev/null
[ -f "$node/enable_sink" ] && echo 0 > "$node/enable_sink" 2>/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same shared-helper point here: the ETF discovery/reset/NPU clock scaffolding is duplicated across the new TPDM runners. Factoring the common CoreSight plumbing into shared helpers would improve orchestration consistency and reduce drift between these scripts.

@Rohan-in-Qualcomm
Copy link
Author

This is 1 commit covering 4 separate new testcases. I would recommend splitting it. These are related thematically, but they are still independent runners/docs/YAMLs and will be much easier to review/fix separately.

Ok I will separate them

This patch adds a suite of automated scripts to validate the functionality
and stability of CoreSight TPDM hardware:

* TPDM-Interface-Access: Validates sysfs read/write accessibility for various TPDM
  dataset modes (DSB, CMB, TC, BC, GPR) to ensure the driver exposes and handles
  attributes correctly.
* TPDM-Enable-Disable: Stress-tests the hardware and driver state machine by
  repeatedly toggling the TPDM source nodes on and off.

Signed-off-by: Rohan Dutta <rohadutt@qti.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.

2 participants