mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ali Rouhi <arouhi@sitime.com>
To: "jiri@resnulli.us" <jiri@resnulli.us>
Cc: "ivecera@redhat.com" <ivecera@redhat.com>,
	"vadim.fedorenko@linux.dev" <vadim.fedorenko@linux.dev>,
	"arkadiusz.kubalewski@intel.com" <arkadiusz.kubalewski@intel.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"prabhakar.mahadev-lad.rj@bp.renesas.com"
	<prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"cjubran@nvidia.com" <cjubran@nvidia.com>,
	"Oleg.Zadorozhnyi@devoxsoftware.com"
	<Oleg.Zadorozhnyi@devoxsoftware.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH net-next v17 01/13] dpll: omit pin phase attributes the driver has no value for
Date: Tue, 1 Dec 2026 23:52:03 +0000	[thread overview]
Message-ID: <20261201235202.97645-2-arouhi@sitime.com> (raw)
In-Reply-To: <20261201235202.97645-1-arouhi@sitime.com>

From: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>

Let phase_offset_get and phase_adjust_get return -ENODATA for a pin the
driver has no value for, and leave DPLL_A_PIN_PHASE_OFFSET and
DPLL_A_PIN_PHASE_ADJUST out of the message in that case, as
dpll_msg_add_ffo() already does for the fractional frequency offset.
Today any error from either callback fails the whole pin dump.

A driver that measures the phase offset only on the input its PLL
tracks, or whose part holds a delay larger than the s32 the adjust
attribute carries, has no value to report for the pin, and a zero
cannot be told from a measurement.  A phase adjust request on such a
pin is passed to the driver without the comparison against the old
value, so the delay can still be set or cleared.

Document the -ENODATA return in dpll.rst, at the two callbacks in
struct dpll_pin_ops and in the netlink spec.

Signed-off-by: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>
Signed-off-by: Ali Rouhi <arouhi@sitime.com>
Reviewed-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst     | 11 +++++++++--
 Documentation/netlink/specs/dpll.yaml |  6 ++++++
 drivers/dpll/dpll_netlink.c           | 14 ++++++++++----
 include/linux/dpll.h                  |  2 ++
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index 7c117ae37cc1..fce34a9e90b9 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -195,7 +195,9 @@ Phase offset measurement and adjustment
 Device may provide ability to measure a phase difference between signals
 on a pin and its parent dpll device. If pin-dpll phase offset measurement
 is supported, it shall be provided with ``DPLL_A_PIN_PHASE_OFFSET``
-attribute for each parent dpll device. The reported phase offset may be
+attribute for each parent dpll device. A driver that has no measurement
+for a pin returns ``-ENODATA`` from ``phase_offset_get`` and the attribute
+is left out of that parent device nest. The reported phase offset may be
 computed as the average of prior values and the current measurement, using
 the following formula:
 
@@ -221,6 +223,10 @@ granularity that pin handle shall be provided to the user on
 attributes. Configured phase adjust value is provided with
 ``DPLL_A_PIN_PHASE_ADJUST`` attribute of a pin, and value change can be
 requested with the same attribute with ``DPLL_CMD_PIN_SET`` command.
+A driver that has no value for a pin returns ``-ENODATA`` from
+``phase_adjust_get``; the attribute is then left out, while the minimum,
+maximum and granularity are still provided, and a requested value is
+passed to the driver without a comparison against the old one.
 
   ================================ ==========================================
   ``DPLL_A_PIN_ID``                configured pin id
@@ -260,7 +266,8 @@ In such cases, users can also control the feature using the
 ``DPLL_CMD_DEVICE_SET`` command by setting the ``enum dpll_feature_state``
 values for the attribute.
 Once enabled the phase offset measurements for the input shall be returned
-in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute.
+in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute, except for an input the driver
+has no measurement for (see above).
 
   =============================== ========================
   ``DPLL_A_PHASE_OFFSET_MONITOR`` attr state of a feature
diff --git a/Documentation/netlink/specs/dpll.yaml b/Documentation/netlink/specs/dpll.yaml
index 8fa789a50273..7d3dced30dd3 100644
--- a/Documentation/netlink/specs/dpll.yaml
+++ b/Documentation/netlink/specs/dpll.yaml
@@ -456,9 +456,15 @@ attribute-sets:
       -
         name: phase-adjust
         type: s32
+        doc: |
+          Configured phase adjustment of the pin, in picoseconds.
+          Left out when the driver has no value for the pin.
       -
         name: phase-offset
         type: s64
+        doc: |
+          Measured phase difference between the pin and the parent dpll
+          device. Left out when the driver has no measurement for the pin.
       -
         name: fractional-frequency-offset
         type: sint
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index e5380d95f238..acf71a93f230 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -388,8 +388,11 @@ dpll_msg_add_pin_phase_adjust(struct sk_buff *msg, struct dpll_pin *pin,
 	ret = ops->phase_adjust_get(pin, dpll_pin_on_dpll_priv(dpll, pin),
 				    dpll, dpll_priv(dpll),
 				    &phase_adjust, extack);
-	if (ret)
+	if (ret) {
+		if (ret == -ENODATA)
+			return 0;
 		return ret;
+	}
 	if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST, phase_adjust))
 		return -EMSGSIZE;
 
@@ -411,8 +414,11 @@ dpll_msg_add_phase_offset(struct sk_buff *msg, struct dpll_pin *pin,
 	ret = ops->phase_offset_get(pin, dpll_pin_on_dpll_priv(dpll, pin),
 				    dpll, dpll_priv(dpll), &phase_offset,
 				    extack);
-	if (ret)
+	if (ret) {
+		if (ret == -ENODATA)
+			return 0;
 		return ret;
+	}
 	if (nla_put_64bit(msg, DPLL_A_PIN_PHASE_OFFSET, sizeof(phase_offset),
 			  &phase_offset, DPLL_A_PIN_PAD))
 		return -EMSGSIZE;
@@ -1452,11 +1458,11 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr,
 	ret = ops->phase_adjust_get(pin, dpll_pin_on_dpll_priv(dpll, pin),
 				    dpll, dpll_priv(dpll), &old_phase_adj,
 				    extack);
-	if (ret) {
+	if (ret && ret != -ENODATA) {
 		NL_SET_ERR_MSG(extack, "unable to get old phase adjust value");
 		return ret;
 	}
-	if (phase_adj == old_phase_adj)
+	if (!ret && phase_adj == old_phase_adj)
 		return 0;
 
 	ret = ops->phase_adjust_set(pin, dpll_pin_on_dpll_priv(dpll, pin),
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 7a6f8796cda2..46980b419e1c 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -121,10 +121,12 @@ struct dpll_pin_ops {
 	int (*prio_set)(const struct dpll_pin *pin, void *pin_priv,
 			const struct dpll_device *dpll, void *dpll_priv,
 			const u32 prio, struct netlink_ext_ack *extack);
+	/* -ENODATA: no value, DPLL_A_PIN_PHASE_OFFSET is left out */
 	int (*phase_offset_get)(const struct dpll_pin *pin, void *pin_priv,
 				const struct dpll_device *dpll, void *dpll_priv,
 				s64 *phase_offset,
 				struct netlink_ext_ack *extack);
+	/* -ENODATA: no value, DPLL_A_PIN_PHASE_ADJUST is left out */
 	int (*phase_adjust_get)(const struct dpll_pin *pin, void *pin_priv,
 				const struct dpll_device *dpll, void *dpll_priv,
 				s32 *phase_adjust,
-- 
2.39.2 (Apple Git-143)


  reply	other threads:[~2026-12-01 23:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:52 [PATCH net-next v17 00/13] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-12-01 23:52 ` Ali Rouhi [this message]
2026-12-01 23:52 ` [PATCH net-next v17 02/13] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 04/13] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 03/13] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 06/13] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 05/13] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 07/13] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 08/13] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 10/13] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 09/13] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 11/13] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 12/13] dpll: sit9531x: add support to get phase offset on the connected input Ali Rouhi
2026-12-01 23:52 ` [PATCH net-next v17 13/13] dpll: sit9531x: model the inter-PLL sync line as a pair of pins Ali Rouhi

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=20261201235202.97645-2-arouhi@sitime.com \
    --to=arouhi@sitime.com \
    --cc=Oleg.Zadorozhnyi@devoxsoftware.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=cjubran@nvidia.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh@kernel.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

all inboxes | Powered by JetHome®