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=1794217015; b=gnieqVCggAqnvweIK6LupWtzsv0Uip++prbp0aGbik7kmCQOPoszgJbRYClcdWbGmVpl zx00QNPr9RzjKvxtMhbSRSVWzxUDZ++Z8YNl0CoZjBnavWn1Sz3i213uCkW8dh8ThrQks DwsFCx/fon2iCGryAPK5NNAy/p85ZR7JWLE+Pp+rj4fcqoCr/VtzFG5lfFQCbOk48acUs ZkjlyfYdj6BYJRReBSkpFeXf9uOWg/KXTb+gEggxmzm0W15hGGjMSeyOeIjnNqTaJ315f k1Pmq7Kv+/h3MSA7RuTkkk3FspKIkMW7n7B0E4ru/3m5UaZBKqUAyqCCR8z8BEWMgMQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794217015; 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=z0aQvDSjlQ6la332PjVwuvpMyBbJb3KzHR5SSZtlNpU=; b=1z1IZn87F3orU+YhmCHtTk0i+R0leWbuHgSFkMDcGoDvW56PbqOtZ6fMbK8/1gp8eGNA MSR2xd1JFTMdHF0JkZP3D0jpbAaImXA89Iceih3TIU98FxZFs7HpIaLqqySNPn5XHKlgq dSP1xrsmeAd2flbPWIZVCF91GKvMBTZPgRZ1kK6Sm/+yjA1lt9UZy7l+nrNzImcY67R+b DGsOZuo3EwtGBTfRTMIB3BrCJnkzQr4nj291bfDVh8maSXXql3a+d8SnFX7dekB7+qrii +4sHKMbi/7zV1ug3Bv2E1M80vx5I+U2Jo9v7ymR9DsqYS0y4WBkR6B3OjH2IzmSYyWg== 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=f7iHawUh; 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 75A78606A33E for ; Mon, 9 Nov 2026 09:36:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 75A78606A33E 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=f7iHawUh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794217013; 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=z0aQvDSjlQ6la332PjVwuvpMyBbJb3KzHR5SSZtlNpU=; b=f7iHawUhhAO8CwXYTEKgoHSrb+nz5oRX8c1ctdQjMKZ/5FEgruczJNfV9Kv0LQgMNd33TZ b9EGDAd1aYQhVuLZWiY33eBJTFLgu6NvDANlJuxVnwugxeTBiXYjYcbZZpzsk/qavYTy3D W12E1tSfkFTGHQqXe4BXoSBsMyBokTU= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-ugitwJdxOSisVKmEJEVdMg-1; Mon, 09 Nov 2026 04:36:49 -0500 X-MC-Unique: ugitwJdxOSisVKmEJEVdMg-1 X-Mimecast-MFC-AGG-ID: ugitwJdxOSisVKmEJEVdMg_1794217007 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0215318002A8; Mon, 9 Nov 2026 09:36:47 +0000 (UTC) Received: from poros-thinkpadp16vgen1.tpbc.com (unknown [10.44.48.50]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 96A491800446; Mon, 9 Nov 2026 09:36:42 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: Petr Oros , Ivan Vecera , Jiri Pirko , Jonathan Corbet , Shuah Khan , Shuah Khan , Randy Dunlap , Jani Nikula , Vadim Fedorenko , Arkadiusz Kubalewski , Jiri Pirko , 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 v3 11/14] dpll: dpllsim: Add support to adjust phase Date: Mon, 9 Nov 2026 10:35:20 +0100 Message-ID: <20261109093523.931201-12-poros@redhat.com> In-Reply-To: <20261109093523.931201-1-poros@redhat.com> References: <20261109093523.931201-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.111 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. Reviewed-by: Ivan Vecera Acked-by: Jiri Pirko Signed-off-by: Petr Oros --- drivers/dpll/dpllsim/dpll.c | 40 ++++++++++++++++++++++++++++++++++ drivers/dpll/dpllsim/dpllsim.h | 1 + 2 files changed, 41 insertions(+) diff --git a/drivers/dpll/dpllsim/dpll.c b/drivers/dpll/dpllsim/dpll.c index 8590d2db808e45..d9a0bbedf89423 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), }; @@ -182,6 +187,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, @@ -190,6 +222,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 = { @@ -197,6 +231,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 * @@ -212,6 +248,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: @@ -273,6 +312,7 @@ static void dpllsim_pin_reset(struct dpllsim_pin *pin) { pin->ops = dpllsim_pin_select_ops(pin); pin->state = DPLL_PIN_STATE_DISCONNECTED; + 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 f59447d26a8668..886ac27f5f92d6 100644 --- a/drivers/dpll/dpllsim/dpllsim.h +++ b/drivers/dpll/dpllsim/dpllsim.h @@ -43,6 +43,7 @@ struct dpllsim_pin { /* Simulated state, guarded by dev->lock */ enum dpll_pin_state state; + s32 phase_adjust; }; struct dpllsim_dev { -- 2.56.0