From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796225621; b=ilEzeomUMyS/8d68axgQQu+Jbu9MRg69k1B4wymwSrfSGvW0Ou8Pqr7/CEFfVRZqM8mA TZnQwx3bRUFx2+SnIdeYE3qB/nRFqVohIW/Z3YiGkpNLS/zyI7yR8maZYzu9SihZlMEbN BMoeZAYts/up2Kn/bQpRZtmlgJonOxsr9wm/MHEqBdu1GzUhU5QbjUyzPfsHFi0OpUF0Z qF2SNE16Rrh0YZ0l+RTa2mU8Q04Y0L+8NizqSrsIBaK+33buT2h7Rn/jxHR5tLCRTPvMD HZSf96fnqDdz2bs/Un8czqe9rwihUlfJa9FP58KTQAeazM9mGAAe8q6H7puocB4gwyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225621; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=WrgT4H609wznxC47+RLm+PvcO8uH+g7E3hNhyD1QgC8=; b=Z+w9VKA7A1KKvyTlNfC4arLzidfaFghAobmZR7NkYJhjl2hTXmr0U4qFNL75oMvZao1+ 1H9uuaKqhDHPmDeMB6p3vvM0oAKiuX0dSQe0kbO8GNB2xdh3B4mKEWPkDArWOWF6ACcPn rBS44gY4mRespE3zeqLCLpjSIeq8dwo/a7PIAUA3L5MKqEmYLGYcQRUlWkfO3FgA7kVrA vrPdBJ12FqszlT4ftqrD1cUgdjB4QzV8rJnRqm/NvoaNHxyeXaO0IIF6mn49T/kZq9R0N 4gtcdoUaJy4fhFY/J+G5uEeWgDQNEviBRk2eCvoACGAjk5QljVkexyf+8iF72ljfssg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eeX8D66N; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE14B606A339 for ; Wed, 2 Dec 2026 15:33:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EE14B606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eeX8D66N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796225621; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrgT4H609wznxC47+RLm+PvcO8uH+g7E3hNhyD1QgC8=; b=eeX8D66Nw1jlI3uPhGDajj9ZWhWyOO/TXyZnvFnUlqI2KV4xNV36eDfYTAbcGMsppwODIU laSlkmrOiNAEvB6wfRrdIvH0Bgo+Yrh/RAmeANA9oA7Gjp3nFoTQFS7JQZfl/klehA0QUQ rTMFkNTIibvpcJKSfj3bsq/DhITCfG0= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-441-r1ipdaFfOYqMKut44OCCpg-1; Wed, 2 Dec 2026 15:33:35 +0000 X-MC-Unique: r1ipdaFfOYqMKut44OCCpg-1 X-Mimecast-MFC-AGG-ID: r1ipdaFfOYqMKut44OCCpg_1796225613 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16378191AF02; Wed, 2 Dec 2026 15:33:31 +0000 (UTC) Received: from poros-thinkpadp16vgen1.tpbc.com (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1FF411801902; Wed, 2 Dec 2026 15:33:26 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: Petr Oros , Jonathan Corbet , Shuah Khan , Shuah Khan , Randy Dunlap , Jani Nikula , Vadim Fedorenko , Arkadiusz Kubalewski , Jiri Pirko , Ivan Vecera , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net-next v6 12/14] selftests: dpll: add pin phase adjust test Date: Wed, 2 Dec 2026 16:32:21 +0100 Message-ID: <20261202153223.2725780-13-poros@redhat.com> In-Reply-To: <20261202153223.2725780-1-poros@redhat.com> References: <20261202153223.2725780-1-poros@redhat.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Add a test that reads the phase adjustment range and granularity a pin advertises, picks another value, sets it, reads it back and restores the original value. On the device the script created that is the largest and the smallest multiple of the granularity inside the range. On a device provided by the user it is the value one granularity step away from the current one, the end of the range can be a large phase step there, 2.1 ms on zl3073x. The test skips when the dpll tool lacks the phase-adjust keyword of pin set, and a negative value is passed behind the separator, the tool would take it for an option of its own. A pin that reports no phase adjustment, no range or a range too narrow to pick a different value is a skip on a device provided by the user and a failure on the device the script created, whose pins report a wide range. The core refuses a value outside the advertised range and one that is not a multiple of the granularity a driver reports, the current value included, so a pin that sits at such a value could not be put back. The test bails out on either before it touches the pin. It then writes the current value back, which changes nothing and which the core refuses with EOPNOTSUPP for a driver without a setter, and defers the restore once that went through, so that an interrupted run restores the value too. The granularity is only reported by drivers that have the core enforce one. A missing one on the device the script created is a failure there, its simulator reports one, and without it the step on hardware is 1 ns. A driver may refuse a value for a granularity of its own or for any other constraint the interface does not advertise. A refused set is therefore a skip on a device provided by the user, with the reason the tool reported, and a failure on the device the script created, whose simulator accepts every value its range and granularity allow. The test ends there, a value that was not set has nothing to read back. Signed-off-by: Petr Oros --- v6: - check both ends of the phase adjust range on the device the script created, the negative one included, keep the deferred restore armed across them, a refused target must not disarm what the other one changed, and leave an end that does not fit out instead of ending the test there - report a missing phase adjust granularity on the created device as a failure, its simulator reports one - pass the separator to the dpll tool before a negative phase adjust, it would take the value for an option of its own - correct the comment on the rounding of the bounds, the truncation already rounds the usual bounds inward, the explicit steps cover a positive minimum and a negative maximum - drop the Reviewed-by and the Acked-by, the test changed since they were given v5: - on a device provided by the user step from the current phase adjust by the granularity or by 1 ns, the end of the range is a phase step of 2.1 ms on zl3073x - check that the pin is still spare before the test - write the current phase adjust back before the restore is deferred, like the priority and the frequency tests do - name the reason the tool reported when the restore fails - report a value that cannot be read back as such, not as a wrong one - fail on the created device when the range is too narrow to pick another value, a skip there would hide a regression of the simulator - skip the deferred restore once the test restored the phase adjust itself, a refused repeat would fail the run - leave the deferred restore out when nothing was changed, and take a refused restore of the test like the state test does, a skip when nothing failed before it, the deferred one tries again - count the pin as changed from before the set of the new value, see patch 6 - the 2.1 ms of zl3073x in the description is S32_MAX ps, the end of the phase adjust range the driver advertises v4: - bail out when the current value lies outside the advertised range, it could not be restored - tell a failed query from a pin without a phase adjust or a range and log a deferred restore that fails v3: - follow the move of the selftests to tools/testing/selftests/drivers/dpll v5: https://lore.kernel.org/all/20261125090522.3777494-13-poros@redhat.com/ v4: https://lore.kernel.org/all/20261112130359.840795-13-poros@redhat.com/ v3: https://lore.kernel.org/all/20261109093523.931201-13-poros@redhat.com/ v2: https://lore.kernel.org/all/20261105151852.1844305-13-poros@redhat.com/ v1: https://lore.kernel.org/all/20261103093910.596225-13-poros@redhat.com/ --- .../selftests/drivers/dpll/dpll_features.sh | 167 ++++++++++++++++++ .../selftests/drivers/dpll/dpll_lib.sh | 16 ++ 2 files changed, 183 insertions(+) diff --git a/tools/testing/selftests/drivers/dpll/dpll_features.sh b/tools/testing/selftests/drivers/dpll/dpll_features.sh index dd5320a1e9498f..9dba8ba953d566 100755 --- a/tools/testing/selftests/drivers/dpll/dpll_features.sh +++ b/tools/testing/selftests/drivers/dpll/dpll_features.sh @@ -35,6 +35,7 @@ ALL_TESTS=" test_pin_state_transitions test_pin_priority_get_set test_pin_frequency_set_get + test_pin_phase_adjust_set_get " ############################################################################## @@ -493,6 +494,172 @@ test_pin_state_transitions() log_test "DPLL pin state transitions" } +test_pin_phase_adjust_set_get() +{ + local before target after json min max gran step reason msg changed + local -a targets + + RET=0 + + if [ -z "$PIN_TUNE_ID" ]; then + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "no spare input pin" + return + fi + if ! dpll_pin_set_supports phase-adjust; then + log_test_skip "DPLL pin phase-adjust set/get" \ + "dpll tool lacks pin set phase-adjust" + return + fi + pin_tune_spare "DPLL pin phase-adjust set/get" || return + + # A query that failed is not a pin without a phase adjust. + if ! before=$(dpll_pin_get_phase_adjust "$PIN_TUNE_ID") || + ! json=$(dpll_pin_json "$PIN_TUNE_ID"); then + check_err 1 "pin $PIN_TUNE_ID query failed" + log_test "DPLL pin phase-adjust set/get" + return + fi + if [ -z "$before" ]; then + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "phase adjust not reported" + return + fi + if ! [[ "$before" =~ ^-?[0-9]+$ ]]; then + check_err 1 "phase adjust '$before' is not a number" + log_test "DPLL pin phase-adjust set/get" + return + fi + + # Pick a target inside the advertised range different from the + # current value and a multiple of the granularity. + min=$(jq -r '.["phase-adjust-min"] // empty' <<< "$json") + max=$(jq -r '.["phase-adjust-max"] // empty' <<< "$json") + gran=$(jq -r '.["phase-adjust-gran"] // empty' <<< "$json") + if [ -z "$min" ] || [ -z "$max" ]; then + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "no adjust range" + return + fi + # The core refuses a value outside the range or off the + # granularity, the current one included. A pin that sits at such a + # value could not be put back, so bail out before the restore is + # scheduled. + if [ "$before" -lt "$min" ] || [ "$before" -gt "$max" ]; then + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "current phase adjust outside the adjust range" + return + fi + if [ -n "$gran" ] && [ $((before % gran)) -ne 0 ]; then + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "current phase adjust not a granularity multiple" + return + fi + # For a driver without a phase adjust setter the core refuses the + # current value as well, writing it changes nothing otherwise. The + # restore is deferred once that went through. + if ! dpll_pin_set_phase_adjust "$PIN_TUNE_ID" "$before"; then + reason=${DPLL_LAST_ERR%%$'\n'*} + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "cannot write the phase adjust back${reason:+, $reason}" + return + fi + TUNE_CHANGED=0 + defer tune_restore dpll_pin_set_phase_adjust "$PIN_TUNE_ID" "$before" + + if [ -n "$DPLL_CREATED_DEVICE" ]; then + # The simulator is checked at both ends of its range, the + # negative one included. A missing granularity on it is + # broken tooling, its driver reports one. Shell division + # truncates towards zero, which already rounds a negative + # bound up and a positive one down, towards the inside of + # the range. The explicit steps below cover the opposite + # case, a positive minimum or a negative maximum. An end + # that still does not fit, or that is the current value, is + # left out and the other one is checked on its own. + if [ -z "$gran" ]; then + dpll_log_test_skip_or_fail \ + "DPLL pin phase-adjust set/get" \ + "no phase-adjust granularity" + return + fi + targets=() + target=$((max / gran * gran)) + [ "$target" -gt "$max" ] && target=$((target - gran)) + [ "$target" != "$before" ] && [ "$target" -ge "$min" ] && + [ "$target" -le "$max" ] && targets+=("$target") + target=$((min / gran * gran)) + [ "$target" -lt "$min" ] && target=$((target + gran)) + [ "$target" != "$before" ] && [ "$target" -ge "$min" ] && + [ "$target" -le "$max" ] && targets+=("$target") + else + # On hardware the end of the range can be a large phase step, + # 2.1 ms on zl3073x, which the outputs see once the pin becomes + # the reference. Step by the granularity, or by 1 ns when the + # driver reports none, towards the inside of the range. + step=${gran:-1000} + targets=() + target=$((before + step)) + [ "$target" -gt "$max" ] && target=$((before - step)) + [ "$target" != "$before" ] && [ "$target" -ge "$min" ] && + [ "$target" -le "$max" ] && targets+=("$target") + fi + if [ "${#targets[@]}" -eq 0 ]; then + dpll_log_test_skip_or_fail "DPLL pin phase-adjust set/get" \ + "range too narrow" + return + fi + for target in "${targets[@]}"; do + # A driver may enforce a granularity it does not report or + # another constraint, a skip on a device the user provided, + # the simulator accepts every value its range and granularity + # allow. A refused set puts the changed flag back instead of + # clearing it, an end checked before it may have left the pin + # changed and the deferred restore has to stay armed for it. + changed=$TUNE_CHANGED + TUNE_CHANGED=1 + if ! dpll_pin_set_phase_adjust "$PIN_TUNE_ID" "$target"; then + TUNE_CHANGED=$changed + reason=${DPLL_LAST_ERR%%$'\n'*} + msg="cannot set phase-adjust=$target" + [ -n "$reason" ] && msg="$msg, $reason" + dpll_log_test_skip_or_fail \ + "DPLL pin phase-adjust set/get" "$msg" + return + fi + after=$(dpll_pin_get_phase_adjust "$PIN_TUNE_ID") + if [ -z "$after" ]; then + check_err 1 "cannot read the phase adjust back" + elif [ "$after" != "$target" ]; then + check_err 1 "expected $target, got '$after'" + fi + + # A refused restore is taken like in the state test, the + # deferred one tries again. + if ! dpll_pin_set_phase_adjust "$PIN_TUNE_ID" "$before"; then + reason=${DPLL_LAST_ERR%%$'\n'*} + reason=${reason:+, $reason} + if [ "$RET" -eq 0 ]; then + dpll_log_test_skip_or_fail \ + "DPLL pin phase-adjust set/get" \ + "cannot restore phase-adjust$reason" + return + fi + check_err 1 "cannot restore phase-adjust$reason" + else + TUNE_CHANGED=0 + fi + after=$(dpll_pin_get_phase_adjust "$PIN_TUNE_ID") + if [ -z "$after" ]; then + check_err 1 "cannot read the restored phase adjust back" + elif [ "$after" != "$before" ]; then + check_err 1 "phase-adjust not restored, got '$after'" + fi + done + + log_test "DPLL pin phase-adjust set/get" +} + test_pin_frequency_set_get() { local before target after reason json near=true diff --git a/tools/testing/selftests/drivers/dpll/dpll_lib.sh b/tools/testing/selftests/drivers/dpll/dpll_lib.sh index 6803c6789268e2..e9f75adc82bc68 100644 --- a/tools/testing/selftests/drivers/dpll/dpll_lib.sh +++ b/tools/testing/selftests/drivers/dpll/dpll_lib.sh @@ -489,6 +489,11 @@ dpll_pin_get_prio() __dpll_pin_dev_field "$1" "$2" '.prio' } +dpll_pin_get_phase_adjust() +{ + __dpll_pin_field "$1" '.["phase-adjust"]' +} + ############################################################################## # Pin setters # @@ -548,6 +553,17 @@ dpll_pin_set_frequency() 2>&1 >/dev/null) } +# $2: phase adjust in ps. The separator keeps the tool from taking a +# negative value for an option of its own. +dpll_pin_set_phase_adjust() +{ + local pin_id=$1 + local phase_adjust=$2 + + DPLL_LAST_ERR=$(dpll pin set id "$pin_id" phase-adjust -- \ + "$phase_adjust" 2>&1 >/dev/null) +} + ############################################################################## # dpllsim configfs interface # -- 2.56.1