* [PATCH v2 2/2] selftests: ptp: treat unsupported PHC operations as skip
2026-01-26 6:15 [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios Junjie Cao
@ 2026-01-26 6:15 ` Junjie Cao
2026-01-27 17:04 ` Simon Horman
2026-01-26 6:32 ` [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios Junjie Cao
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Junjie Cao @ 2026-01-26 6:15 UTC (permalink / raw)
To: Shuah Khan, Richard Cochran, linux-kselftest, netdev; +Cc: linux-kernel
Some PTP hardware clock (PHC) devices may return -EOPNOTSUPP for
operations like settime, adjtime, or adjfreq. This commonly occurs
with timestamp-only PHC implementations that don't support full clock
control.
For background, syzbot previously exposed a crash risk when PTP clock
drivers lacked required callbacks[1]. Subsequent work[2] made callback
presence a registration requirement. As a result, some drivers (like
iwlwifi MVM/MLD[3]) now provide stub callbacks that return -EOPNOTSUPP
for unsupported operations.
When phc_ctl encounters such devices, the "Operation not supported"
error should be treated as a skip (device limitation) rather than a
test failure. This patch:
- Adds [SKIP] output handling in log_test()
- Detects "Operation not supported" from phc_ctl and returns ksft_skip
- Returns ksft_skip if all tests are skipped, preventing false-positive
results when testing timestamp-only PHC implementations
Link: https://lore.kernel.org/netdev/20251028043216.1971292-1-junjie.cao@intel.com/ [1]
Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dfb073d32cac [2]
Link: https://lore.kernel.org/netdev/20251204123204.9316-1-ziyao@disroot.org/ [3]
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
---
tools/testing/selftests/ptp/phc.sh | 49 ++++++++++++++++++++++--------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/tools/testing/selftests/ptp/phc.sh b/tools/testing/selftests/ptp/phc.sh
index 51aad466d989..9f61c1579edf 100755
--- a/tools/testing/selftests/ptp/phc.sh
+++ b/tools/testing/selftests/ptp/phc.sh
@@ -52,6 +52,7 @@ phc_sanity
# Exit status to return at the end. Set in case one of the tests fails.
EXIT_STATUS=0
+PASS_COUNT=0
# Per-test return value. Clear at the beginning of each test.
RET=0
@@ -68,12 +69,18 @@ log_test()
{
local test_name=$1
+ if [[ $RET -eq $ksft_skip ]]; then
+ printf "TEST: %-60s [SKIP]\n" "$test_name"
+ return 0
+ fi
+
if [[ $RET -ne 0 ]]; then
EXIT_STATUS=1
printf "TEST: %-60s [FAIL]\n" "$test_name"
return 1
fi
+ ((PASS_COUNT++))
printf "TEST: %-60s [ OK ]\n" "$test_name"
return 0
}
@@ -92,34 +99,49 @@ tests_run()
settime_do()
{
- local res
+ local res out
- res=$(phc_ctl $DEV set 0 wait 120.5 get 2> /dev/null \
- | awk '/clock time is/{print $5}' \
- | awk -F. '{print $1}')
+ out=$(LC_ALL=C phc_ctl $DEV set 0 wait 120.5 get 2>&1)
+ if [[ $? -ne 0 ]]; then
+ if echo "$out" | grep -qi "Operation not supported"; then
+ return $ksft_skip
+ fi
+ return 1
+ fi
+ res=$(echo "$out" | awk '/clock time is/{print $5}' | awk -F. '{print $1}')
(( res == 120 ))
}
adjtime_do()
{
- local res
+ local res out
- res=$(phc_ctl $DEV set 0 adj 10 get 2> /dev/null \
- | awk '/clock time is/{print $5}' \
- | awk -F. '{print $1}')
+ out=$(LC_ALL=C phc_ctl $DEV set 0 adj 10 get 2>&1)
+ if [[ $? -ne 0 ]]; then
+ if echo "$out" | grep -qi "Operation not supported"; then
+ return $ksft_skip
+ fi
+ return 1
+ fi
+ res=$(echo "$out" | awk '/clock time is/{print $5}' | awk -F. '{print $1}')
(( res == 10 ))
}
adjfreq_do()
{
- local res
+ local res out
# Set the clock to be 1% faster
- res=$(phc_ctl $DEV freq 10000000 set 0 wait 100.5 get 2> /dev/null \
- | awk '/clock time is/{print $5}' \
- | awk -F. '{print $1}')
+ out=$(LC_ALL=C phc_ctl $DEV freq 10000000 set 0 wait 100.5 get 2>&1)
+ if [[ $? -ne 0 ]]; then
+ if echo "$out" | grep -qi "Operation not supported"; then
+ return $ksft_skip
+ fi
+ return 1
+ fi
+ res=$(echo "$out" | awk '/clock time is/{print $5}' | awk -F. '{print $1}')
(( res == 101 ))
}
@@ -166,4 +188,7 @@ trap cleanup EXIT
tests_run
+if [[ $EXIT_STATUS -eq 0 && $PASS_COUNT -eq 0 ]]; then
+ exit $ksft_skip
+fi
exit $EXIT_STATUS
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/2] selftests: ptp: treat unsupported PHC operations as skip
2026-01-26 6:15 ` [PATCH v2 2/2] selftests: ptp: treat unsupported PHC operations as skip Junjie Cao
@ 2026-01-27 17:04 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2026-01-27 17:04 UTC (permalink / raw)
To: Junjie Cao
Cc: Shuah Khan, Richard Cochran, linux-kselftest, netdev,
linux-kernel
On Mon, Jan 26, 2026 at 02:15:32PM +0800, Junjie Cao wrote:
> Some PTP hardware clock (PHC) devices may return -EOPNOTSUPP for
> operations like settime, adjtime, or adjfreq. This commonly occurs
> with timestamp-only PHC implementations that don't support full clock
> control.
>
> For background, syzbot previously exposed a crash risk when PTP clock
> drivers lacked required callbacks[1]. Subsequent work[2] made callback
> presence a registration requirement. As a result, some drivers (like
> iwlwifi MVM/MLD[3]) now provide stub callbacks that return -EOPNOTSUPP
> for unsupported operations.
>
> When phc_ctl encounters such devices, the "Operation not supported"
> error should be treated as a skip (device limitation) rather than a
> test failure. This patch:
> - Adds [SKIP] output handling in log_test()
> - Detects "Operation not supported" from phc_ctl and returns ksft_skip
> - Returns ksft_skip if all tests are skipped, preventing false-positive
> results when testing timestamp-only PHC implementations
>
> Link: https://lore.kernel.org/netdev/20251028043216.1971292-1-junjie.cao@intel.com/ [1]
> Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dfb073d32cac [2]
> Link: https://lore.kernel.org/netdev/20251204123204.9316-1-ziyao@disroot.org/ [3]
> Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios
2026-01-26 6:15 [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios Junjie Cao
2026-01-26 6:15 ` [PATCH v2 2/2] selftests: ptp: treat unsupported PHC operations as skip Junjie Cao
@ 2026-01-26 6:32 ` Junjie Cao
2026-01-27 17:04 ` Simon Horman
2026-01-28 2:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Junjie Cao @ 2026-01-26 6:32 UTC (permalink / raw)
To: Shuah Khan, Richard Cochran, linux-kselftest, netdev; +Cc: linux-kernel
Apologies - this is actually v1, not v2. The version was set incorrectly during local work. Let me know if you'd prefer a resend.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios
2026-01-26 6:15 [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios Junjie Cao
2026-01-26 6:15 ` [PATCH v2 2/2] selftests: ptp: treat unsupported PHC operations as skip Junjie Cao
2026-01-26 6:32 ` [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios Junjie Cao
@ 2026-01-27 17:04 ` Simon Horman
2026-01-28 2:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2026-01-27 17:04 UTC (permalink / raw)
To: Junjie Cao
Cc: Shuah Khan, Richard Cochran, linux-kselftest, netdev,
linux-kernel
On Mon, Jan 26, 2026 at 02:15:31PM +0800, Junjie Cao wrote:
> The kselftest framework defines KSFT_SKIP=4 as the standard exit code
> for skipped tests. However, phc.sh currently uses a mix of 'exit 0' and
> 'exit 1' to indicate skip conditions, which can confuse test harnesses
> and CI systems.
>
> This patch introduces ksft_skip=4 variable and unifies all skip exit
> paths to use 'exit $ksft_skip', consistent with other selftests like
> net/lib.sh and net/fib_nexthops.sh.
>
> Signed-off-by: Junjie Cao <junjie.cao@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios
2026-01-26 6:15 [PATCH v2 1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios Junjie Cao
` (2 preceding siblings ...)
2026-01-27 17:04 ` Simon Horman
@ 2026-01-28 2:10 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-28 2:10 UTC (permalink / raw)
To: Junjie Cao; +Cc: shuah, richardcochran, linux-kselftest, netdev, linux-kernel
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 26 Jan 2026 14:15:31 +0800 you wrote:
> The kselftest framework defines KSFT_SKIP=4 as the standard exit code
> for skipped tests. However, phc.sh currently uses a mix of 'exit 0' and
> 'exit 1' to indicate skip conditions, which can confuse test harnesses
> and CI systems.
>
> This patch introduces ksft_skip=4 variable and unifies all skip exit
> paths to use 'exit $ksft_skip', consistent with other selftests like
> net/lib.sh and net/fib_nexthops.sh.
>
> [...]
Here is the summary with links:
- [v2,1/2] selftests: ptp: use KSFT_SKIP exit code for skip scenarios
https://git.kernel.org/netdev/net-next/c/166e664e702e
- [v2,2/2] selftests: ptp: treat unsupported PHC operations as skip
https://git.kernel.org/netdev/net-next/c/239f09e258b9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread