Linux Documentation
 help / color / mirror / Atom feed
From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
	Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Donald Hunter <donald.hunter@gmail.com>,
	Tony Nguyen <anthony.l.nguyen@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	Richard Cochran <richardcochran@gmail.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, Min Li <min.li@microchip.com>,
	Grzegorz Nitka <grzegorz.nitka@intel.com>,
	Karol Kolacinski <karol.kolacinski@intel.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Tariq Toukan <tariqt@nvidia.com>, Petr Oros <poros@redhat.com>
Subject: [PATCH RFC net-next 02/19] dpll: report pin links
Date: Thu, 26 Nov 2026 21:32:14 +0100	[thread overview]
Message-ID: <20261126203231.934632-3-ivecera@redhat.com> (raw)
In-Reply-To: <20261126203231.934632-1-ivecera@redhat.com>

Report the links of a pin in pin-get with a new multi-attr nest
DPLL_A_PIN_LINK, which carries the id of the pin at the other end. The
link is reported for both pins, the one that has it and the one whose
firmware node it names, and only while both of them are registered.

DPLL_A_PIN_LINK is a nest rather than a repeated u32, so that
attributes of a link, for example the delay of the board trace, can
be added later. The message layout is uAPI, so a flat u32 could not
be extended.

Links name a pin by its firmware node, so dpll_pin_fwnode_set() now
refuses to change the node of a registered pin, which would change
the reported links without a notification. Setting the same node
again, as zl3073x does for each of its DPLLs, still works.

Pins with no links and no firmware node are not affected.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst     | 38 +++++++++++++++++++++++++++
 Documentation/netlink/specs/dpll.yaml | 15 +++++++++++
 drivers/dpll/dpll_core.c              | 26 +++++++++++++++---
 drivers/dpll/dpll_core.h              |  1 +
 drivers/dpll/dpll_netlink.c           | 30 ++++++++++++++++++++-
 include/uapi/linux/dpll.h             |  1 +
 6 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index 7c117ae37cc1bc..aed92693d9e604 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -350,6 +350,41 @@ bound to only one other pin at any given time.
     ``DPLL_A_PIN_STATE``         state of Reference SYNC connection
   ============================== ==========================================
 
+Pin links
+=========
+
+A pin represents a pad of the device whose driver registers it. When the
+board connects a pad of one device to a pad of another one, for example an
+output of a DPLL chip to a reference clock input of a network controller,
+the driver of one of them describes the connection with
+dpll_pin_link_add() on its own pin. The link names the pin at the other
+end by its firmware node, which the driver of that pin sets with
+dpll_pin_fwnode_set(). Each driver registers only its own pins and the
+drivers may probe in any order.
+
+While both pins are registered, ``DPLL_CMD_PIN_GET`` reports the link for
+each of them with the id of the pin at the other end:
+
+  ============================== ==========================================
+  ``DPLL_A_PIN_LINK``            nested attribute for each linked pin
+    ``DPLL_A_PIN_ID``            id of the pin at the other end
+  ============================== ==========================================
+
+For example, an output of a DPLL chip wired to an input of a network
+controller::
+
+        'pin': [{
+          'id': 7,
+          'module-name': 'zl3073x',
+          'parent-device': [{'parent-id': 0, 'direction': 'output', ...}],
+          'link': [{'id': 21}]
+          }, {
+          'id': 21,
+          'module-name': 'ice',
+          'parent-device': [{'parent-id': 5, 'direction': 'input', ...}],
+          'link': [{'id': 7}]
+          }]
+
 Configuration commands group
 ============================
 
@@ -467,6 +502,9 @@ according to attribute purpose.
     ``DPLL_A_PIN_CAPABILITIES``        attr bitmask of pin capabilities
     ``DPLL_A_PIN_MEASURED_FREQUENCY``  attr measured frequency of
                                        an input pin in mHz
+    ``DPLL_A_PIN_LINK``                nested attr for each pin linked
+                                       with the pin
+      ``DPLL_A_PIN_ID``                attr id of the linked pin
   ==================================== ==================================
 
   ==================================== =================================
diff --git a/Documentation/netlink/specs/dpll.yaml b/Documentation/netlink/specs/dpll.yaml
index 8fa789a502732a..c81e4dbe65d73e 100644
--- a/Documentation/netlink/specs/dpll.yaml
+++ b/Documentation/netlink/specs/dpll.yaml
@@ -542,6 +542,14 @@ attribute-sets:
           Operational state of the pin with respect to its parent DPLL
           device. Unlike state (which reflects the administrative intent),
           operstate reflects the actual hardware status.
+      -
+        name: link
+        type: nest
+        multi-attr: true
+        nested-attributes: pin-link
+        doc: |
+          A pin connected with this pin on the board, usually a pin of
+          another device. Reported while both pins are registered.
 
   -
     name: pin-parent-device
@@ -591,6 +599,12 @@ attribute-sets:
         name: id
       -
         name: state
+  -
+    name: pin-link
+    subset-of: pin
+    attributes:
+      -
+        name: id
 
 operations:
   enum-name: dpll_cmd
@@ -741,6 +755,7 @@ operations:
             - esync-pulse
             - reference-sync
             - measured-frequency
+            - link
 
       dump:
         reply: *pin-attrs
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 4d871542ddf762..6c61801a293b7e 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -806,13 +806,19 @@ EXPORT_SYMBOL_GPL(dpll_pin_put);
  * @pin: pointer to a dpll pin
  * @fwnode: firmware node handle
  *
- * Set firmware node handle for the given dpll pin.
+ * Set firmware node handle for the given dpll pin. Links name pins by their
+ * firmware node, so the node of a registered pin must not change.
+ *
+ * Context: Acquires a lock (dpll_lock)
  */
 void dpll_pin_fwnode_set(struct dpll_pin *pin, struct fwnode_handle *fwnode)
 {
 	mutex_lock(&dpll_lock);
-	fwnode_handle_put(pin->fwnode); /* Drop fwnode previously set */
-	pin->fwnode = fwnode_handle_get(fwnode);
+	if (pin->fwnode != fwnode &&
+	    !WARN_ON(xa_get_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED))) {
+		fwnode_handle_put(pin->fwnode); /* Drop fwnode previously set */
+		pin->fwnode = fwnode_handle_get(fwnode);
+	}
 	mutex_unlock(&dpll_lock);
 }
 EXPORT_SYMBOL_GPL(dpll_pin_fwnode_set);
@@ -862,6 +868,20 @@ static bool dpll_pin_has_link(const struct dpll_pin *pin,
 	return false;
 }
 
+/**
+ * dpll_pins_linked - check if two pins are linked
+ * @a: pointer to a dpll pin
+ * @b: pointer to another dpll pin
+ *
+ * Context: Caller must hold dpll_lock.
+ * Return: true if either pin has a link to the firmware node of the other
+ */
+bool dpll_pins_linked(const struct dpll_pin *a, const struct dpll_pin *b)
+{
+	return (b->fwnode && dpll_pin_has_link(a, b->fwnode)) ||
+	       (a->fwnode && dpll_pin_has_link(b, a->fwnode));
+}
+
 /**
  * dpll_pin_link_add - add a link from a pin to another pin
  * @pin: pointer to a dpll pin
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index 26a16df2b6410d..f158785bf401b6 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -108,6 +108,7 @@ struct dpll_device *dpll_device_get_by_id(int id);
 struct dpll_pin_ref *dpll_pin_own_dpll_ref_first(struct dpll_pin *pin);
 const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref);
 struct dpll_pin_ref *dpll_xa_ref_dpll_first(struct xarray *xa_refs);
+bool dpll_pins_linked(const struct dpll_pin *a, const struct dpll_pin *b);
 extern struct xarray dpll_device_xa;
 extern struct xarray dpll_pin_xa;
 extern struct mutex dpll_lock;
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index e5380d95f238b3..016f3026d2f2e5 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -709,6 +709,32 @@ dpll_msg_add_pin_dplls(struct sk_buff *msg, struct dpll_pin *pin,
 	return ret;
 }
 
+static int dpll_msg_add_pin_links(struct sk_buff *msg, struct dpll_pin *pin)
+{
+	struct dpll_pin *pos;
+	struct nlattr *nest;
+	unsigned long i;
+
+	/* Only a pin with links or with a firmware node can be linked */
+	if (list_empty(&pin->links) && !pin->fwnode)
+		return 0;
+	xa_for_each_marked(&dpll_pin_xa, i, pos, DPLL_REGISTERED) {
+		if (pos == pin || !dpll_pins_linked(pin, pos) ||
+		    !dpll_pin_available(pos))
+			continue;
+		nest = nla_nest_start(msg, DPLL_A_PIN_LINK);
+		if (!nest)
+			return -EMSGSIZE;
+		if (nla_put_u32(msg, DPLL_A_PIN_ID, pos->id)) {
+			nla_nest_cancel(msg, nest);
+			return -EMSGSIZE;
+		}
+		nla_nest_end(msg, nest);
+	}
+
+	return 0;
+}
+
 static int
 dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
 		     struct netlink_ext_ack *extack)
@@ -780,8 +806,10 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
 		ret = dpll_msg_add_pin_dplls(msg, pin, extack);
 	else
 		ret = dpll_msg_add_pin_parents(msg, pin, ref, extack);
+	if (ret)
+		return ret;
 
-	return ret;
+	return dpll_msg_add_pin_links(msg, pin);
 }
 
 static int
diff --git a/include/uapi/linux/dpll.h b/include/uapi/linux/dpll.h
index 8c71fc3f986343..02e9004426f49c 100644
--- a/include/uapi/linux/dpll.h
+++ b/include/uapi/linux/dpll.h
@@ -289,6 +289,7 @@ enum dpll_a_pin {
 	DPLL_A_PIN_FRACTIONAL_FREQUENCY_OFFSET_PPT,
 	DPLL_A_PIN_MEASURED_FREQUENCY,
 	DPLL_A_PIN_OPERSTATE,
+	DPLL_A_PIN_LINK,
 
 	__DPLL_A_PIN_MAX,
 	DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)
-- 
2.56.1


  parent reply	other threads:[~2026-11-26 20:33 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 01/19] dpll: add " Ivan Vecera
2026-11-26 20:32 ` Ivan Vecera [this message]
2026-11-26 20:32 ` [PATCH RFC net-next 03/19] dpll: notify linked pins when a pin is registered or unregistered Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 04/19] dpll: add KUnit tests for pin links Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 05/19] ice: dpll: use own pins for the TX and time references Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 06/19] ice: dpll: drop the filter of notifications from own registrations Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 07/19] dpll: register pins only with a DPLL of their owner Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 08/19] dpll: drop the state change exception for pins with a firmware node Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 09/19] dpll: drop the source clock id from pin notifications Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 10/19] dpll: drop device events from the in-kernel notifier Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 11/19] dpll: drop the cached module name of a pin Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 12/19] ice: dpll: track the E825 recovered clock routing in the adapter Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 13/19] ice: dpll: register the E825 recovered clock muxes as DPLL devices Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 14/19] ice: dpll: route the E825 recovered clock through the mux devices Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 15/19] dpll: register pins only with a parent pin of their owner Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 16/19] dpll: drop the in-kernel notifier chain Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 17/19] dpll: require a registered DPLL for pin registration Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 18/19] dpll: drop the owner reference selection of pins Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 19/19] dpll: add KUnit tests for the pin owner checks Ivan Vecera

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=20261126203231.934632-3-ivecera@redhat.com \
    --to=ivecera@redhat.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@kernel.org \
    --cc=grzegorz.nitka@intel.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jiri@resnulli.us \
    --cc=karol.kolacinski@intel.com \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=min.li@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=saeedm@nvidia.com \
    --cc=skhan@linuxfoundation.org \
    --cc=tariqt@nvidia.com \
    --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