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=1796225614; b=twEsDxa+NCVXBUiKI3h4C3nvjz2MWHE4T6P2Pa8z2iyjKXO2T9m4TYVSdO6lPbdNADWz qIpSeEAa2jqnF/Ds2qtWSZjkVasNoY32zeQEKqLZSch4tetiydKw8Ga7oSFuF+MEBygGc rB7XW5Ap+I0bZTOZmdl7Z7nvbjD7QesM2/w3h6ylNGs0O8EQnIcDSem8PNv26v1oEHnfm A4XiATYP2xQoK0WxkTM0u2UtLaASEnP3j519LTeUdYIKNiGQQ0jIopHb1IjyTbpUImuam XuKIScxldufY/Bh65mjWCTUIKtGYWq+X6/t8TSiEZkX1FBHy7CjhHKOgbv+Hd3DdW3A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225614; 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=zIKlSpkt5HwfzSiPXZBxUQAKEQDIPccvLNiTcROQ6Lk=; b=0Mg/2la/hcReocUM+G8F4wcpWIeYABrOF8dPAEt7JhkG93H4FqaZ4iYmVm/LGJip/8mO zCXd0tgcmyN+j44nDrbj94h3ClH/FWGXbvLWUiSI+QuScjGzP8I6/4PBdJnIndLSX9Rqh /Dq0jk7gISJKGTwT8e9P9qFAGI24nA42WiDL40jQ+dQG/psOzjiQgKXPpZMyPx0wayCtO pXDD0x3u6JIK4K9sFGzx0zkKUYXqObqlOprSn2yU0qW2TPG3poSl3jd+CU2Je326zJspJ XYIm9PY9c3RyRc+UMQ8yLQZiwxm5BXS4kmGk5woIuIcm5drFB3/S2dPaleO7QFjmx3w== 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=HgouctgW; 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 410E4606A329 for ; Wed, 2 Dec 2026 15:33:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 410E4606A329 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=HgouctgW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796225614; 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=zIKlSpkt5HwfzSiPXZBxUQAKEQDIPccvLNiTcROQ6Lk=; b=HgouctgWt9PjqMbVG9S+iRgbUYyxk/8X2K4kAr9moTobzf62Nup5EWaEitI3w5eG05CVT3 PBHy1WkDw416HTtPGUPSHU7YDaz+7vcKAHUfZZCnyGLnNqpqCTA4gUAXZqd/fh1CqAO0s7 2E9DZRFCnwzTRvUFwdFADNdUQ4hXIYM= Received: from mx-prod-mc-03.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-327-pEcgU-doO-CY0pQis5gozg-1; Wed, 2 Dec 2026 15:33:29 +0000 X-MC-Unique: pEcgU-doO-CY0pQis5gozg-1 X-Mimecast-MFC-AGG-ID: pEcgU-doO-CY0pQis5gozg_1796225607 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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B7A2B192C194; Wed, 2 Dec 2026 15:33:26 +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 E750D1801438; Wed, 2 Dec 2026 15:33:21 +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 11/14] dpll: dpllsim: Add support to adjust phase Date: Wed, 2 Dec 2026 16:32:20 +0100 Message-ID: <20261202153223.2725780-12-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 support to get and set the phase adjustment of input and output pins. The pins advertise a granularity of 100 ps and a symmetric range whose ends are the largest multiples of the granularity that fit a 32-bit signed value, so that the advertised ends themselves are settable, the core validates the requested value against both and the driver stores it. The adjustment is reset to zero every time the device goes live, so that repeated deploy cycles start from a known state. It becomes the baseline of the simulated phase offset measurements once those exist. The documentation of the simulator describes the range, the granularity and the reset, and says that a pin state set over netlink is not kept across a live transition either. Signed-off-by: Petr Oros --- v6: - drop the Reviewed-by and the Acked-by, the documentation and the comments changed since they were given v5: - describe the phase adjust range, its granularity and its reset in the documentation, and that a pin state set over netlink is not kept across a live transition either - give the phase adjust its own comment in the pin structure, it starts from 0 and has no configured value - split the documentation sentence on values set over netlink, only an input pin takes a state and neither the state nor a phase adjust has a configfs attribute v5: https://lore.kernel.org/all/20261125090522.3777494-12-poros@redhat.com/ v4: https://lore.kernel.org/all/20261112130359.840795-12-poros@redhat.com/ v3: https://lore.kernel.org/all/20261109093523.931201-12-poros@redhat.com/ v2: https://lore.kernel.org/all/20261105151852.1844305-12-poros@redhat.com/ v1: https://lore.kernel.org/all/20261103093910.596225-12-poros@redhat.com/ --- Documentation/driver-api/dpllsim.rst | 13 ++++++--- drivers/dpll/dpllsim/dpll.c | 40 ++++++++++++++++++++++++++++ drivers/dpll/dpllsim/dpllsim.h | 2 ++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-api/dpllsim.rst b/Documentation/driver-api/dpllsim.rst index fd38f4c2ea19f1..df67b7c49bf1aa 100644 --- a/Documentation/driver-api/dpllsim.rst +++ b/Documentation/driver-api/dpllsim.rst @@ -68,11 +68,16 @@ priority other than the default, and with ``ENOENT`` when a pin directory is being created or removed at the same time. An ``EINVAL`` does not name the pin, the attributes of the pins show which one it is. -Every live transition starts from the configured values. A frequency or -a priority set over netlink while the instance is live is reported back +Every live transition starts from the configured values, and every pin +starts disconnected and with a phase adjust of 0. A frequency or a +priority set over netlink while the instance is live is reported back over netlink, it is not written to the ``frequency`` or ``prio`` -attribute and is gone once the instance is taken down. The driver -stores the priority, it does not select a reference by it. +attribute and is gone once the instance is taken down. The same holds +for the state of an input pin and for a phase adjust set over netlink, +neither has an attribute. The driver stores the priority, it does not +select a reference by it. +Input and output pins accept a phase adjust in steps of 100 ps between +-2147483600 and 2147483600 ps. Example ======= diff --git a/drivers/dpll/dpllsim/dpll.c b/drivers/dpll/dpllsim/dpll.c index 8900f2042f5539..d960b4a1cbab1a 100644 --- a/drivers/dpll/dpllsim/dpll.c +++ b/drivers/dpll/dpllsim/dpll.c @@ -12,6 +12,11 @@ #include "dpllsim.h" +#define DPLLSIM_PHASE_ADJUST_GRAN 100 /* ps */ +/* Largest multiple of the granularity, so the range ends are settable */ +#define DPLLSIM_PHASE_ADJUST_MAX \ + (S32_MAX - S32_MAX % DPLLSIM_PHASE_ADJUST_GRAN) + static struct dpll_pin_frequency dpllsim_freq_1pps[] = { DPLL_PIN_FREQUENCY_RANGE(1, 1), }; @@ -187,6 +192,33 @@ static int dpllsim_pin_prio_set(const struct dpll_pin *pin, void *pin_priv, return 0; } +static int dpllsim_pin_phase_adjust_get(const struct dpll_pin *pin, + void *pin_priv, + const struct dpll_device *dpll, + void *dpll_priv, s32 *phase_adjust, + struct netlink_ext_ack *extack) +{ + struct dpllsim_pin *sim_pin = pin_priv; + + guard(mutex)(&sim_pin->dev->lock); + *phase_adjust = sim_pin->phase_adjust; + return 0; +} + +static int dpllsim_pin_phase_adjust_set(const struct dpll_pin *pin, + void *pin_priv, + const struct dpll_device *dpll, + void *dpll_priv, + const s32 phase_adjust, + struct netlink_ext_ack *extack) +{ + struct dpllsim_pin *sim_pin = pin_priv; + + guard(mutex)(&sim_pin->dev->lock); + sim_pin->phase_adjust = phase_adjust; + return 0; +} + static const struct dpll_pin_ops dpllsim_input_pin_ops = { .frequency_get = dpllsim_pin_frequency_get, .frequency_set = dpllsim_pin_frequency_set, @@ -195,6 +227,8 @@ static const struct dpll_pin_ops dpllsim_input_pin_ops = { .state_on_dpll_set = dpllsim_pin_state_set, .prio_get = dpllsim_pin_prio_get, .prio_set = dpllsim_pin_prio_set, + .phase_adjust_get = dpllsim_pin_phase_adjust_get, + .phase_adjust_set = dpllsim_pin_phase_adjust_set, }; static const struct dpll_pin_ops dpllsim_output_pin_ops = { @@ -202,6 +236,8 @@ static const struct dpll_pin_ops dpllsim_output_pin_ops = { .frequency_set = dpllsim_pin_frequency_set, .direction_get = dpllsim_pin_direction_get, .state_on_dpll_get = dpllsim_pin_state_get, + .phase_adjust_get = dpllsim_pin_phase_adjust_get, + .phase_adjust_set = dpllsim_pin_phase_adjust_set, }; static const struct dpll_pin_ops * @@ -217,6 +253,9 @@ static void dpllsim_pin_props(struct dpllsim_pin *pin, { prop->type = pin->type; prop->board_label = config_item_name(&pin->item); + prop->phase_range.min = -DPLLSIM_PHASE_ADJUST_MAX; + prop->phase_range.max = DPLLSIM_PHASE_ADJUST_MAX; + prop->phase_gran = DPLLSIM_PHASE_ADJUST_GRAN; switch (pin->type) { case DPLL_PIN_TYPE_GNSS: @@ -280,6 +319,7 @@ static void dpllsim_pin_reset(struct dpllsim_pin *pin) pin->state = DPLL_PIN_STATE_DISCONNECTED; pin->frequency = pin->cfg_frequency; pin->prio = pin->cfg_prio; + pin->phase_adjust = 0; } /* Build sim->pins in registration order, the order the pins were created */ diff --git a/drivers/dpll/dpllsim/dpllsim.h b/drivers/dpll/dpllsim/dpllsim.h index f897969eb9ca69..2e0b024bd391ea 100644 --- a/drivers/dpll/dpllsim/dpllsim.h +++ b/drivers/dpll/dpllsim/dpllsim.h @@ -45,6 +45,8 @@ struct dpllsim_pin { */ u64 frequency; u32 prio; + /* Starts from 0 at live=1, changed by the netlink setter */ + s32 phase_adjust; }; struct dpllsim_dev { -- 2.56.1