From: Wasim Nazir <[email protected]>
Add test to validate end-to-end start/stop sequence for
each remoteproc instances available on target.
Add first test sequence to validated each instance sequencially
to identify any issue while booting each instance.
Add second test sequence to validate all instances concurrently
to identify any race scenario within instances doing bootup.
Additional user argument (--seqdelay) is available to add
delay is seconds, between start/stop sequence. This is added
as different target might have different threshold to start
any instance (default is 5 secs).
Running tests:
./remoteproc_test.sh --seqdelay 10
Signed-off-by: Wasim Nazir <[email protected]>
---
This test validates the core start/stop lifecycle of remoteproc instances
via the sysfs interface (/sys/class/remoteproc/remoteprocN/state).
Two test scenarios are exercised:
1. Sequential: each remoteproc instance is started and stopped one at a
time to isolate per-instance boot failures.
2. Concurrent: all instances are started together then stopped together,
to expose race conditions between instances during simultaneous bootup.
The test is target-agnostic and works wherever CONFIG_REMOTEPROC is
enabled and remoteproc instances are present. It skips automatically
when neither condition is met. A --seqdelay argument allows callers to
tune the wait between start/stop operations for targets with slower boot
times (default: 5s).
Signed-off-by: Bibek Kumar Patro <[email protected]>
---
Changes in v3:
- Drop SSR/recovery handling; not needed for the start/stop path
- Remove Qualcomm-specific "ss"/"SSR" terminology; use "instance"
- Add --seqdelay argument for configurable start/stop delay
- Expand commit message to describe test rationale
- Link to v2:
https://patch.msgid.link/[email protected]
Changes in v2:
- Update commit message to better describe the test purpose
- Rework start/stop flow: stop all instances first for a clean
baseline, then test sequential and concurrent start/stop
- Link to v1:
https://patch.msgid.link/[email protected]
---
MAINTAINERS | 1 +
tools/testing/selftests/Makefile | 1 +
tools/testing/selftests/remoteproc/Makefile | 4 +
tools/testing/selftests/remoteproc/config | 1 +
.../selftests/remoteproc/remoteproc_test.sh | 157 +++++++++++++++++++++
5 files changed, 164 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index a112ce9f0fa0..88103c326008 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22949,6 +22949,7 @@ F: Documentation/staging/remoteproc.rst
F: drivers/remoteproc/
F: include/linux/remoteproc.h
F: include/linux/remoteproc/
+F: tools/testing/selftests/remoteproc/
REMOTE PROCESSOR MESSAGING (RPMSG) SUBSYSTEM
M: Bjorn Andersson <[email protected]>
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 74183c27f6e3..f69eb544a72e 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -103,6 +103,7 @@ TARGETS += pstore
TARGETS += ptrace
TARGETS += openat2
TARGETS += rdma
+TARGETS += remoteproc
TARGETS += resctrl
TARGETS += riscv
TARGETS += rlimits
diff --git a/tools/testing/selftests/remoteproc/Makefile
b/tools/testing/selftests/remoteproc/Makefile
new file mode 100644
index 000000000000..a84b3934fd36
--- /dev/null
+++ b/tools/testing/selftests/remoteproc/Makefile
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+TEST_PROGS := remoteproc_test.sh
+
+include ../lib.mk
diff --git a/tools/testing/selftests/remoteproc/config
b/tools/testing/selftests/remoteproc/config
new file mode 100644
index 000000000000..a5c237d2f3b4
--- /dev/null
+++ b/tools/testing/selftests/remoteproc/config
@@ -0,0 +1 @@
+CONFIG_REMOTEPROC=y
diff --git a/tools/testing/selftests/remoteproc/remoteproc_test.sh
b/tools/testing/selftests/remoteproc/remoteproc_test.sh
new file mode 100644
index 000000000000..d58c1e10005c
--- /dev/null
+++ b/tools/testing/selftests/remoteproc/remoteproc_test.sh
@@ -0,0 +1,157 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
+#
+
+DIR="$(dirname $(readlink -f "$0"))"
+
+KTAP_HELPERS="${DIR}/../kselftest/ktap_helpers.sh"
+if [ -e "$KTAP_HELPERS" ]; then
+ . "$KTAP_HELPERS"
+else
+ echo -n "1..0 # SKIP $KTAP_HELPERS file not found"
+ exit 4
+fi
+
+RPROC_SYS=/sys/class/remoteproc
+RPROC_SEQ_SLEEP=5
+
+rproc_instances=
+num_tests=0
+test_err=0
+
+check_error() {
+ if [ $? -ne 0 ]; then
+ test_err=$((test_err+1))
+ ktap_print_msg "$@"
+ fi
+}
+
+parse_args() {
+ script=${0##*/}
+
+ if [ $# -eq 2 ] && [ "$1" = "--seqdelay" ]; then
+ shift || true
+ RPROC_SEQ_SLEEP=$1
+ else
+ ktap_print_msg "Usage: ${script} --seqdelay <time in secs>"
+ ktap_print_msg "Proceed with default sequence delay =
$RPROC_SEQ_SLEEP"
+ fi
+}
+
+rproc_stop_instances() {
+ for instance in ${rproc_instances}; do
+ rproc=${RPROC_SYS}/$instance
+ rproc_name=$(cat $rproc/name)
+ rproc_state=$(cat $rproc/state)
+
+ echo stop > "$rproc/state"
+ check_error "$rproc_name state-stop failed at state
$rproc_state"
+ done
+ sleep ${RPROC_SEQ_SLEEP}
+}
+
+rproc_start_instances() {
+ for instance in ${rproc_instances}; do
+ rproc=${RPROC_SYS}/$instance
+ rproc_name=$(cat $rproc/name)
+ rproc_state=$(cat $rproc/state)
+
+ echo start > "$rproc/state"
+ check_error "$rproc_name state-start failed at state
$rproc_state"
+ done
+ sleep ${RPROC_SEQ_SLEEP}
+}
+
+rproc_seq_test_instance_one() {
+ instance=$1
+ rproc=${RPROC_SYS}/$instance
+ rproc_name=$(cat $rproc/name)
+ rproc_state=$(cat $rproc/state)
+ ktap_print_msg "Testing rproc sequence for $rproc_name"
+
+ # Reset test_err value
+ test_err=0
+
+ # Begin start/stop sequence
+ echo start > "$rproc/state"
+ check_error "$rproc_name state-start failed at state $rproc_state"
+
+ sleep ${RPROC_SEQ_SLEEP}
+
+ echo stop > "$rproc/state"
+ check_error "$rproc_name state-stop failed at state $rproc_state"
+
+ if [ $test_err -ne 0 ]; then
+ ktap_test_fail "$rproc_name"
+ else
+ ktap_test_pass "$rproc_name"
+ fi
+}
+
+rproc_seq_test_instances_concurrently() {
+ # Reset test_err value
+ test_err=0
+
+ rproc_start_instances
+
+ rproc_stop_instances
+
+ if [ $test_err -ne 0 ]; then
+ ktap_test_fail "for any of $rproc_instances"
+ else
+ ktap_test_pass "for all $rproc_instances"
+ fi
+}
+
+#################################
+### Test starts here
+#################################
+
+ktap_print_header
+
+# Parse user arguments
+parse_args $@
+
+# Check for required sysfs entries
+if [ ! -d "${RPROC_SYS}" ]; then
+ ktap_skip_all "${RPROC_SYS} doesn't exist."
+ exit "${KSFT_SKIP}"
+fi
+
+rproc_instances=$(find ${RPROC_SYS}/remoteproc* -maxdepth 1 -exec basename {}
\;)
+num_tests=$(echo ${rproc_instances} | wc -w)
+if [ "${num_tests}" -eq 0 ]; then
+ ktap_skip_all "${RPROC_SYS}/remoteproc* doesn't exist."
+ exit "${KSFT_SKIP}"
+fi
+
+# Total tests will be:
+# 1) Seq tests for each instance sequencially
+# 2) Seq tests for all instances concurrently
+num_tests=$((num_tests+1))
+
+ktap_set_plan "${num_tests}"
+
+### Stop all instances
+#
+# Intention is to stop all running instances. If any instances are not yet
+# started it will be don't care case as test_err is not checked.
+# NOTE: Assuming no instances are in crashed state
+rproc_stop_instances
+
+### Test 1
+ktap_print_msg "Testing rproc start/stop sequence for each instance
sequencially"
+for instance in ${rproc_instances}; do
+ rproc_seq_test_instance_one $instance
+done
+
+### Test 2
+ktap_print_msg "Testing rproc start/stop sequence for all instances
concurrently"
+rproc_seq_test_instances_concurrently
+
+### Restore all instances
+rproc_start_instances
+
+ktap_finished
---
base-commit: b4515cf4156356e8f4fe6e0fdc17f59adab9772f
change-id: 20260724-b4-remoteproc_selftest-7d3ab51583f2
Best regards,
--
Bibek Kumar Patro <[email protected]>