Linux Documentation
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: poros@redhat.com
Cc: netdev@vger.kernel.org, ivecera@redhat.com, jiri@nvidia.com,
	corbet@lwn.net, skhan@linuxfoundation.org, shuah@kernel.org,
	rdunlap@infradead.org, jani.nikula@intel.com,
	vadim.fedorenko@linux.dev, arkadiusz.kubalewski@intel.com,
	jiri@resnulli.us, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next v4 06/14] selftests: dpll: add pin state tests
Date: Mon, 16 Nov 2026 14:30:01 +0000	[thread overview]
Message-ID: <179483940186.3136.8507799107612530903@kernel.org> (raw)
In-Reply-To: <20261112130359.840795-7-poros@redhat.com>

Thank you for your contribution! Sashiko AI review found 9 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 4 · Low: 5

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In test_pin_state_transitions, the guard against touching a
  pin that automatic selection has since locked onto only checks the…
- [Medium] In manual mode, test_pin_state_transitions finds the reference
  to restore with find_connected_pin(), which only searches input_pins.
- [Medium] pin_is_spare() and pick_tune_pin() never check the pin type,
  so zl3073x's internal NCO pseudo-input can be chosen as PIN_TUNE_ID.
- [Medium] test_pin_state_transitions assumes that 'manual' means one
  connected reference, and that reconnecting it restores the device.
- [Low] The commit message and the script header say the reference is
  never touched, but in manual mode the test takes the reference over on…
- [Low] Both state tests accept 'connected' as the readback after
  'selectable' was set in automatic mode, even on dpllsim devices the…
- [Low] In dpll_lib.sh, the comment on dpll_pin_set_supports says the
  keyword 'must stand on its own between blanks or brackets'.
- [Low] test_pin_state_transitions ignores the exit status of
  `mode=$(dpll_device_get_mode ...)` (line 98) and of…
- [Low] In manual mode, the deferred restore of PIN_TUNE_ID to `before`
  (line 144) still runs after the test body has already restored…

--

selftests: dpll: add pin state tests

This adds dpll_features.sh. Its test moves a spare input pin through the
states of the device mode and then restores it. It runs on a dpllsim
device it creates, or on a device the user names. It also adds a state
flooding test to dpll_stress.sh, plus library helpers for the pin state
setter, the device mode getter, deferred restores and a dpll tool
keyword check.

> diff --git a/tools/testing/selftests/drivers/dpll/dpll_features.sh b/tools/testing/selftests/drivers/dpll/dpll_features.sh
> new file mode 100755
> index 0000000000000..0a00a18bded2c
> --- /dev/null
> +++ b/tools/testing/selftests/drivers/dpll/dpll_features.sh
> @@ -0,0 +1,339 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0

[ ... ]

> +# The tests reconfigure a spare input pin of the device and restore it
> +# afterwards, see pick_tune_pin. A pin the device uses as its reference
> +# is never picked, but on hardware a spare pin that carries a valid
> +# signal can still be selected while a test reconfigures it, so do not
> +# point the script at a device whose reference must not be disturbed.

[Severity: Low]
The header says a pin used as the reference is never picked. The commit
message says the pin is picked up front:

  "so that no test touches the reference the device is locked to"

Does that hold in manual mode? test_pin_state_transitions() uses:

	manual)
		states="connected disconnected"

Connecting PIN_TUNE_ID makes it the reference in place of the locked one.
Disconnecting it then leaves the device with no reference until ref_pin
is connected back. This happens on every manual mode run, whether or not
the spare pin carries a valid signal.

A later paragraph of the commit message says as much ("connecting the
pin makes it the reference ... connects it back at the end"), which
contradicts the earlier claim.

Could the header and the commit message say that manual mode switches the
reference away and back on purpose?

[ ... ]

> +find_connected_pin()
> +{
> +	local pin_id
> +
> +	for pin_id in "${input_pins[@]}"; do
> +		if [ "$(dpll_pin_get_state "$DPLL_DEV_ID" "$pin_id")" = \
> +		     connected ]; then
> +			echo "$pin_id"
> +			return
> +		fi
> +	done
> +}

[Severity: Medium]
Can this miss the manual mode reference? input_pins comes from
dpll_pin_find_by_direction(), which drops mux-typed pins:

	   '(.pin? // [.])[] | select(.type != "mux") |

This loop also ignores the exit status of dpll_pin_get_state(), so a
failed query looks like a pin that is not connected.

zl3073x supports manual mode, and zl3073x_pin_props_get() can give input
pins DPLL_PIN_TYPE_MUX from firmware properties. ice registers mux-typed
direct inputs as well.

If the reference is such a pin, or its state query fails, ref_pin stays
empty in test_pin_state_transitions():

		ref_pin=$(find_connected_pin)
		if [ -n "$ref_pin" ]; then
			defer dpll_restore dpll_pin_set_state "$DPLL_DEV_ID" \
			      "$ref_pin" connected
		fi

Then neither the deferred reconnect nor the one at the end of the test
runs. The loop still connects PIN_TUNE_ID, which displaces the real
reference, and then disconnects it. Only PIN_TUNE_ID goes back to
$before.

Would the device be left without its reference while the test reports a
pass?

[ ... ]

> +	mode=$(dpll_device_get_mode "$DPLL_DEV_ID")
> +	case "$mode" in
> +	automatic)
> +		states="disconnected selectable"
> +		;;
> +	manual)
> +		states="connected disconnected"
> +		;;

[Severity: Medium]
Does a mode of manual always mean one connected reference that can simply
be reconnected? zl3073x_dpll_mode_get() reports DPLL_MODE_MANUAL for the
freerun, holdover, NCO and reflock refsel modes.

In freerun or holdover every ref reads disconnected, so
find_connected_pin() returns nothing and ref_pin is empty. The connected
step then makes zl3073x_dpll_input_pin_state_on_dpll_set() select
PIN_TUNE_ID and switch to reflock:

	case ZL_DPLL_MODE_REFSEL_MODE_FREERUN:
	case ZL_DPLL_MODE_REFSEL_MODE_HOLDOVER:
		if (state == DPLL_PIN_STATE_CONNECTED) {
			/* Choose the pin as new selected reference */
			zl3073x_chan_ref_set(&chan, ref);
			/* Switch to reflock mode */

The disconnected step then picks holdover or freerun from the cached
lock_status. A channel that started in holdover can end in freerun, or
in a holdover that is now based on PIN_TUNE_ID.

The original refsel mode is never saved or restored. Every pin reads
disconnected again, so the test passes.

In NCO mode the NCO pin is the connected input and becomes ref_pin.
Connecting PIN_TUNE_ID leaves NCO mode, which steps the ToD and clears
the PPS TIE. Reconnecting the NCO pin re-enters NCO mode, and
nco_auto_read captures the current tracking offset, not the offset
userspace had programmed.

Should the test skip in manual mode when no regular input is connected,
or save and restore the refsel mode?

> +	*)
> +		dpll_log_test_skip_or_fail "DPLL pin state transitions" \
> +		    "device mode '$mode' not handled"
> +		return
> +		;;
> +	esac
> +
> +	before=$(dpll_pin_get_state "$DPLL_DEV_ID" "$PIN_TUNE_ID")
> +	if [ -z "$before" ]; then
> +		dpll_log_test_skip_or_fail "DPLL pin state transitions" \
> +		    "state not reported"
> +		return
> +	fi

[Severity: Low]
__dpll_device_field() and __dpll_pin_dev_field() return 1 when the dpll
tool fails. The status of the mode= and before= assignments is dropped
here, though. On a device the user provided, a failed query is then
logged as a skip, with "device mode '' not handled" or "state not
reported".

The commit message says "A pin that cannot be queried is a failure, not
a pin that is in use or lacks a capability". pin_is_spare() and
dpll_pin_has_capability() return 2 for exactly that case.

Should these two queries be reported as failures as well?

> +	# The automatic selection may have taken the pin since it was
> +	# picked, it is the reference then and not to be touched.
> +	if [ "$mode" = automatic ] && [ "$before" = connected ]; then
> +		dpll_log_test_skip_or_fail "DPLL pin state transitions" \
> +		    "spare input pin became the reference"
> +		return
> +	fi

[Severity: Medium]
Is the admin state enough to tell that the automatic selection took this
pin? Documentation/driver-api/dpll.rst says the pin state reflects the
administrative intent, while the operstate reflects what the hardware
actually does with the pin.

In automatic mode, zl3073x_dpll_input_pin_state_on_dpll_get() reports
selectable for the active ref too:

	case ZL_DPLL_MODE_REFSEL_MODE_AUTO:
		if (zl3073x_chan_ref_is_selectable(chan, ref))
			*state = DPLL_PIN_STATE_SELECTABLE;

pin_is_spare() already rejects .operstate == "active", but this check
does not. Suppose PIN_TUNE_ID becomes the active reference after
pick_tune_pin() ran. On zl3073x this check passes, and the loop sets the
pin to disconnected, which withdraws the reference the device is locked
to.

The loop comment ("the pin reports connected then") seems to rest on the
same assumption.

[ ... ]

> +	# Restore the original state even when the test aborts half way.
> +	defer dpll_restore dpll_pin_set_state "$DPLL_DEV_ID" "$PIN_TUNE_ID" \
> +	      "$before"

[Severity: Low]
In manual mode, does this restore run a second time after the test body
has already put both pins back? On a successful run, the end of the test
sets PIN_TUNE_ID to $before and reconnects ref_pin:

	if [ -n "$ref_pin" ]; then
		dpll_pin_set_state "$DPLL_DEV_ID" "$ref_pin" connected

The deferred commands then run last in first out. PIN_TUNE_ID is set to
disconnected again while the channel is locked to ref_pin, and only
after that is ref_pin connected.

In zl3073x_dpll_input_pin_state_on_dpll_set(), DPLL_PIN_STATE_DISCONNECTED
in reflock mode switches the channel to holdover or freerun. It does not
check whether the pin is the selected ref:

		} else if (state == DPLL_PIN_STATE_DISCONNECTED) {
			/* Choose new mode based on lock status */
			switch (zldpll->lock_status) {

So the device loses its reference a second time. If the deferred
reconnect then fails, dpll_restore() only logs it, and the device stays
in holdover or freerun.

[ ... ]

> +pin_is_spare()
> +{
> +	local out
> +
> +	out=$(dpll pin show id "$2" -j 2>/dev/null) || return 2
> +	jq -e --argjson dev "$1" '
> +		(.pin[0]? // .) | [.["parent-device"][]?] |
> +		any(.[]; .["parent-id"] == $dev and
> +			 (.state == "disconnected" or
> +			  .state == "selectable")) and
> +		all(.[]; .state != "connected" and .operstate != "active")' \
> +		<<< "$out" &> /dev/null || return 1
> +}

[ ... ]

> +pick_tune_pin()
> +{
> +	local pin_id
> +
> +	PIN_TUNE_ID=""
> +	for pin_id in "${input_pins[@]}"; do
> +		pin_is_spare "$DPLL_DEV_ID" "$pin_id"

[ ... ]

> +		PIN_TUNE_ID=$pin_id
> +		[ "$pin_id" != "${input_pins[0]}" ] && return
> +	done
> +}

[Severity: Medium]
Can this pick the zl3073x NCO pseudo-input as PIN_TUNE_ID?

zl3073x_dpll_nco_pin_register() registers that pin with
DPLL_PIN_DIRECTION_INPUT, DPLL_PIN_TYPE_INT_NCO and
DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE, after all the ref pins. Outside
NCO mode it reports disconnected and standby, so pin_is_spare() accepts
it.

The NCO pin is dumped last. So when input_pins[0] is spare and no other
ref qualifies, pick_tune_pin() takes the NCO pin over the real spare
input.

In manual mode the test then connects the NCO pin, which enters NCO mode
with the nco_auto_read, tod_step_reset and tie_clear settings programmed
at registration. Disconnecting it makes
zl3073x_dpll_nco_pin_state_on_dpll_set() force freerun:

		/* Switch to freerun - holdover averaging was not
		 * updated during NCO mode.
		 */
		zl3073x_chan_mode_set(&chan,
				      ZL_DPLL_MODE_REFSEL_MODE_FREERUN);

In automatic mode, setting selectable on the NCO pin returns -EINVAL, so
on a user device the test skips and no real input gets exercised.

Should pin_is_spare() leave out pins of type int-nco? Later tests that
reuse PIN_TUNE_ID would inherit the same choice.

> diff --git a/tools/testing/selftests/drivers/dpll/dpll_lib.sh b/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> index 2da8cbe8a883e..783db2a4dbc18 100644
> --- a/tools/testing/selftests/drivers/dpll/dpll_lib.sh
> +++ b/tools/testing/selftests/drivers/dpll/dpll_lib.sh

[ ... ]

> +# Return 0 when the dpll tool knows the given "pin set" keyword, such as
> +# state or frequency. A test that sets something checks its keyword
> +# first and skips on a tool that is too old for it. Only the "pin set"
> +# usage is searched, a keyword that only "pin show" knows must not
> +# count, and the keyword must stand on its own between blanks or
> +# brackets, a hyphenated compound that contains it does not count.
> +dpll_pin_set_supports()
> +{
> +	local usage
> +
> +	usage=$(__dpll_usage_block pin set) || return 1
> +	grep -qE "(^|[[:space:][])$1([[:space:]]|$)" <<< "$usage"
> +}

[Severity: Low]
This isn't a bug, but the comment says the keyword must stand between
blanks or brackets. The regex accepts an opening bracket before the
keyword, but only a blank or the end of the line after it, so "state]"
would not match.

Every pin set keyword takes an argument, so this works in practice.
Should the trailing group also accept ], or should the comment be
adjusted?

[ ... ]

> diff --git a/tools/testing/selftests/drivers/dpll/dpll_stress.sh b/tools/testing/selftests/drivers/dpll/dpll_stress.sh
> index b21325d8368fb..396d44c7bbe35 100755
> --- a/tools/testing/selftests/drivers/dpll/dpll_stress.sh
> +++ b/tools/testing/selftests/drivers/dpll/dpll_stress.sh

[ ... ]

> +			# A device in automatic mode may pick the pin it
> +			# was offered as its reference, the pin reports
> +			# connected then.
> +			state=$(dpll_pin_get_state "$dev_id" "$pin_id")
> +			case "$state" in
> +			selectable|connected)
> +				;;

[Severity: Low]
Does accepting connected here hide a wrong readback on the simulator?

test_pin_state_flooding() only runs on a fresh dpllsim device.
dpllsim_pin_state_set() stores exactly the requested state, after
dpllsim_pin_state_valid() has refused connected in automatic mode.
Nothing in drivers/dpll/dpllsim/ writes DPLL_PIN_STATE_CONNECTED.

So a regression that stores connected when selectable was requested
would pass this test. test_pin_state_transitions() applies the same
automatic/selectable/connected exemption, even when DPLL_CREATED_DEVICE
is set.

Could this exemption apply only to devices the user provided?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112130359.840795-1-poros%40redhat.com

  reply	other threads:[~2026-11-16 14:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 13:03 [PATCH net-next v4 00/14] dpll: add a simulated DPLL device driver Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 01/14] dpll: dpllsim: Add " Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 02/14] selftests: dpll: add test library and device lifecycle tests Petr Oros
2026-11-16 14:29   ` netdev-bot+sashiko
2026-11-12 13:03 ` [PATCH net-next v4 03/14] dpll: dpllsim: Add configurable pins Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 04/14] selftests: dpll: add pin enumeration and property tests Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 05/14] dpll: dpllsim: Add support to set input pin state Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 06/14] selftests: dpll: add pin state tests Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko [this message]
2026-11-12 13:03 ` [PATCH net-next v4 07/14] dpll: dpllsim: Add support to get/set priority on input pins Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 08/14] selftests: dpll: add pin priority test Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko
2026-11-12 13:03 ` [PATCH net-next v4 09/14] dpll: dpllsim: Add support to set frequency on pins Petr Oros
2026-11-12 13:03 ` [PATCH net-next v4 10/14] selftests: dpll: add pin frequency test Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko
2026-11-12 13:03 ` [PATCH net-next v4 11/14] dpll: dpllsim: Add support to adjust phase Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko
2026-11-12 13:03 ` [PATCH net-next v4 12/14] selftests: dpll: add pin phase adjust test Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko
2026-11-12 13:03 ` [PATCH net-next v4 13/14] selftests: dpll: add concurrency stress tests Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko
2026-11-12 13:03 ` [PATCH net-next v4 14/14] selftests: dpll: add reference leak tests Petr Oros
2026-11-16 14:30   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179483940186.3136.8507799107612530903@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=ivecera@redhat.com \
    --cc=jani.nikula@intel.com \
    --cc=jiri@nvidia.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=vadim.fedorenko@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox