Netdev List
 help / color / mirror / Atom feed
* [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links
@ 2026-11-26 20:32 Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 01/19] dpll: add " Ivan Vecera
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Sorry for the size, I know 19 patches is over the netdev limit of 15.
For the RFC I kept each step in its own patch, so all the changes are
easy to see one by one. The final series will squash some of them.

In the thread on "dpll: do not serialize driver callbacks under global
dpll_lock" [1], Jakub was not convinced: relations between DPLL objects
are hard to follow, objects of one driver plug into objects of another,
and the driver API should be much more "dummy-proof" [2]. Vadim agreed
and asked to step back, because the subsystem was shaped to model one
NIC family and is getting more complex for its next generation [3].
Jiri agreed with Vadim [4]. This RFC removes the sharing of pin objects
between drivers instead of picking a lock scheme for it.

Problems in DPLL today
Model:
- One pin, two owners: on E825, ice registers zl3073x output pins with
  its DPLLs (c191b319f208) and hangs its recovered clock pins under
  zl3073x inputs, so one request runs callbacks of two drivers.
- Per-registration needs on one object: a state change bypass for
  firmware node pins (521b6d5de08d), zl3073x inputs typed MUX although
  the mux is in the NIC, one pin that is both an output and an input.
Driver API:
- ice waits for the zl3073x pins on a notifier chain (2be467588d6b) and
  holds references to them, so probe order and lifetime are its job.
- Core code exists only for that: the owner check exception, the
  notifier source id (0bf47f722fa9), the owner ref selection
  (2c1bd78dc8e2, 84e85c325e5e) and a cached module name.
- Callbacks run under dpll_lock and must use __dpll_*_change_ntf(),
  notifications go out without driver locks. Only comments say so.
Locking:
- dpll_lock serializes every callback of every driver. With a dual NAC
  E825 and a ZL80132B, ice DPLL requests during zl3073x ToD writes took
  a median of 1448 ms, at most 3.9 s (idle 0.1 ms). zl3073x is narrowing
  its waits, but callbacks that wait for hardware stay (planned zl3073x
  resync, up to 1 s; mlx5 commands, 60 s timeout).
- No lock scheme fits pins shared between drivers. Options A-E from the
  thread each cost something, from callbacks invisible to lockdep (A)
  to one domain for everything connected, the global lock again (D).
Fragility: 13 fixes in a year in the (un)register, on-pin and
notification paths, e.g. 32239d600236, df0ba51ccf87, 1a2292101c0d.

All of these come from one dpll_pin being both a pad of a chip and a
wire on the board, so two drivers end up sharing one object.

Proposal
- I1: a pin is registered only with DPLLs and parent pins of its owner,
  the module and clock_id it was created with. The core enforces it.
- I2: so a request about an object runs only its owner's callbacks.
- I3: a wire between pins of two devices is a link. The driver of one
  end adds it to its own pin with dpll_pin_link_add() and names the
  other end by its firmware node, so no driver holds a pin of another.
- I4: a link is only a wire, with no state and no callbacks. pin-get
  reports DPLL_A_PIN_LINK with the peer id for both pins while both are
  registered, the peer is notified when one of them comes or goes.
On E825 this covers the TX reference (zl3073x output to the ice TXC
DPLL), the time reference (zl3073x output to the ice TSPLL) and the
recovered clock crossbar: two ice mux devices, one per CGU output, with
the port pins as inputs and outputs linked with zl3073x inputs.

This removes the model and driver API problems and options A-E. The
code of one fix is gone, the cross-owner cases behind other fixes cannot
happen. The stall and unenforced rules stay, per-owner locks become
possible. Not addressed: a netdev names only its recovered clock pin.

For a driver
TX reference and recovered clock, before and after (the first PF of the
adapter creates the muxes):

  pin = fwnode_dpll_pin_find(fwnode, &tracker); /* or wait for it */
  dpll_pin_register(txc_dpll, pin, &txclk_ops, priv);
  dpll_pin_on_pin_register(zl_input, rclk_pin, &rclk_ops, priv);

  pin = dpll_pin_get(txc_clock_id, idx, THIS_MODULE, &prop, &tracker);
  dpll_pin_link_add(pin, fwnode);
  dpll_pin_register(txc_dpll, pin, &txclk_ops, priv);
  dpll_device_register(mux, DPLL_TYPE_GENERIC, &mux_ops, adapter_mux);
  dpll_pin_link_add(mux_out, rclk_fwnode);
  dpll_pin_register(mux, mux_out, &out_ops, adapter_mux);
  dpll_pin_register(mux, rclk_pin, &rclk_ops, priv);

For user space (ids from the GNR-D below)
The zl3073x output OUT3 (id 36) no longer lists the ice TXC DPLLs as
parents; it is linked with the EXT_SYNCE pins of the eight PFs, which
are inputs of their TXC DPLLs:

  {'id': 36, 'module-name': 'zl3073x', 'package-label': 'OUT3',
   'parent-device': [{'parent-id': 11, 'direction': 'output', ...}],
   'link': [{'id': 4}, {'id': 8}, ..., {'id': 26}]}
  {'id': 4, 'module-name': 'ice', 'board-label': 'EXT_SYNCE',
   'parent-device': [{'parent-id': 1, 'direction': 'input', ...}],
   'link': [{'id': 36}]}

The port pin of eno1np0 (id 2) had the zl3073x inputs as parent pins.
It is now an input of the muxes 2 and 3, and RCLK0 (id 0) is linked
with REF1P (id 29):

  {'id': 2, 'module-name': 'ice', 'type': 'synce-eth-port',
   'parent-device': [{'parent-id': 2, 'state': 'connected', ...},
                     {'parent-id': 3, 'state': 'disconnected', ...}]}
  {'id': 0, 'board-label': 'RCLK0', 'link': [{'id': 29}], ...}

pin-set {"id": 2, "parent-device": {"parent-id": 2, "state":
"connected"}} routes the port and disconnects the one routed before.
The clock-id of the port pin is the adapter index instead of the DSN.
The E825 pins exist without zl3073x too.

What it removes
Core: everything under driver API above, cross-owner on-pin registration
is rejected. ice: the notifier work, the firmware node parent pins and
the foreign pin references. The tolerance for a DPLL without
registrations (33f016b23a21) stays: on E810 the recovered clock pins of
the PFs without the CGU stay registered with the DPLLs of the PF with
the CGU when that PF goes first.

  core (dpll_core, dpll_netlink, dpll.h)  +224/-173
  ice                                     +727/-503
  KUnit tests and build                   +563
  docs, spec, uapi                        +69
  exported symbols 21 -> 20 (+2 for KUnit only), ops unchanged

ice grows, as the PFs of an ASIC share the muxes and the adapter
records the routing. An E825 with N ports had N+1 DPLL devices (TXC per
port, TSPLL) and 2N ice pins, now N+3 devices and 3N+3 ice pins. A mux
is not a DPLL, but the generic type is for devices outside the EEC and
PPS classes, and two driver-local devices replace two core mechanisms:
cross-owner on-pin registration and a MUX parent of another driver.

Locking series: v3 is on hold until the direction is agreed. On top of
this the rule for drivers becomes "your callbacks run under your lock",
and options A-E are not needed.

Status: W=1 build at every patch, full build, sparse, kernel-doc,
ynl-regen, htmldocs, KUnit (12 tests, UML, lockdep). Tested on a GNR-D
platform with a dual NAC E825 and a ZL80132B: links, routing of all
eight ports with notifications, the recovered clock at the zl3073x
inputs, PF reset, CORER, GLOBR, PF unbind and bind, zl3073x reload and
the TX reference; the test script and its results are in [5]. Not
tested: EMPR, and the recovered clock of the second NAC, whose ports had
no link. Prepared with the help of an AI coding assistant.

Questions
1. The E825 TX reference and recovered clock views change. Fine, or
   should netlink translate the old view?
2. Is a mux fine as a generic DPLL device that reports locked while it
   routes a port, and are N+3 DPLL devices for N ports fine?
3. The two muxes share module, clock-id and type, so device-id-get
   finds neither. Is finding them through their output pins enough?
4. The firmware still types the zl3073x inputs as MUX. Leave it?
5. The ice pin does not know the frequency on the wire. Omit it, as
   now, or read it from a firmware node property?
6. Should the locking series be rebased on top of this?

[1] https://lore.kernel.org/netdev/20261111164021.273409-1-ivecera@redhat.com/
[2] https://lore.kernel.org/netdev/20261119133851.3f25074c@kernel.org/
[3] https://lore.kernel.org/netdev/ff8b63b7-b943-444a-bd37-b6fb493b5d9f@linux.dev/
[4] https://lore.kernel.org/netdev/awMP9Gj3Xhia0ZeI@FV6GYCPJ69/
[5] https://gist.github.com/ivecera/b31f67adac6deac318719bbe0f282707

Ivan Vecera (19):
  dpll: add pin links
  dpll: report pin links
  dpll: notify linked pins when a pin is registered or unregistered
  dpll: add KUnit tests for pin links
  ice: dpll: use own pins for the TX and time references
  ice: dpll: drop the filter of notifications from own registrations
  dpll: register pins only with a DPLL of their owner
  dpll: drop the state change exception for pins with a firmware node
  dpll: drop the source clock id from pin notifications
  dpll: drop device events from the in-kernel notifier
  dpll: drop the cached module name of a pin
  ice: dpll: track the E825 recovered clock routing in the adapter
  ice: dpll: register the E825 recovered clock muxes as DPLL devices
  ice: dpll: route the E825 recovered clock through the mux devices
  dpll: register pins only with a parent pin of their owner
  dpll: drop the in-kernel notifier chain
  dpll: require a registered DPLL for pin registration
  dpll: drop the owner reference selection of pins
  dpll: add KUnit tests for the pin owner checks

 Documentation/driver-api/dpll.rst            |   53 +
 Documentation/netlink/specs/dpll.yaml        |   15 +
 drivers/dpll/.kunitconfig                    |    5 +
 drivers/dpll/Kconfig                         |   18 +
 drivers/dpll/Makefile                        |    2 +
 drivers/dpll/dpll_core.c                     |  253 ++--
 drivers/dpll/dpll_core.h                     |   20 +-
 drivers/dpll/dpll_netlink.c                  |   82 +-
 drivers/dpll/dpll_netlink.h                  |   10 +-
 drivers/dpll/tests/dpll_kunit.c              |  538 ++++++++
 drivers/net/ethernet/intel/ice/ice_adapter.c |    3 +-
 drivers/net/ethernet/intel/ice/ice_adapter.h |   33 +
 drivers/net/ethernet/intel/ice/ice_dpll.c    | 1175 ++++++++++--------
 drivers/net/ethernet/intel/ice/ice_dpll.h    |   11 +-
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c  |    8 -
 include/linux/dpll.h                         |   32 +-
 include/uapi/linux/dpll.h                    |    1 +
 17 files changed, 1583 insertions(+), 676 deletions(-)
 create mode 100644 drivers/dpll/.kunitconfig
 create mode 100644 drivers/dpll/tests/dpll_kunit.c


base-commit: 2388bb763e323442f4dd8189238ac0c5f334c4a0
-- 
2.56.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 01/19] dpll: add pin links
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 02/19] dpll: report " Ivan Vecera
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

A pin is a pad of the chip whose driver registers it. When a board wires
a pad of one chip to a pad of another, for example an output of an
external DPLL to the TX reference input of a network controller, a
driver now registers the pin of the other driver with its own DPLL. The
pin then has two owners and a request about it runs callbacks of both
drivers.

Add a link that describes such a wire instead. A driver adds it to its
own pin with dpll_pin_link_add() and names the pin at the other end by
its firmware node, which the driver of that pin sets with
dpll_pin_fwnode_set(). The link holds only the firmware node, so the
driver needs no pointer to a pin of another driver and that pin does not
have to exist yet.

Links are added before the pin is registered and are released together
with the pin. Adding an existing link returns -EEXIST, also on a
registered pin, so each user of a shared pin can add the same link. The
next patch reports links to user space.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_core.c | 71 ++++++++++++++++++++++++++++++++++++++++
 drivers/dpll/dpll_core.h | 12 +++++++
 include/linux/dpll.h     |  2 ++
 3 files changed, 85 insertions(+)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 277692d12d3d1e..4d871542ddf762 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -147,6 +147,16 @@ static void __dpll_pin_hold(struct dpll_pin *pin, dpll_tracker *tracker)
 static void dpll_pin_idx_free(u32 pin_idx);
 static void dpll_pin_prop_free(struct dpll_pin_properties *prop);
 
+static void dpll_pin_links_free(struct dpll_pin *pin)
+{
+	struct dpll_pin_link *link, *tmp;
+
+	list_for_each_entry_safe(link, tmp, &pin->links, list) {
+		fwnode_handle_put(link->peer);
+		kfree(link);
+	}
+}
+
 static void __dpll_pin_put(struct dpll_pin *pin, dpll_tracker *tracker)
 {
 	dpll_pin_tracker_free(pin, tracker);
@@ -155,6 +165,7 @@ static void __dpll_pin_put(struct dpll_pin *pin, dpll_tracker *tracker)
 		xa_destroy(&pin->dpll_refs);
 		xa_destroy(&pin->parent_refs);
 		xa_destroy(&pin->ref_sync_pins);
+		dpll_pin_links_free(pin);
 		dpll_pin_prop_free(&pin->prop);
 		fwnode_handle_put(pin->fwnode);
 		dpll_pin_idx_free(pin->pin_idx);
@@ -665,6 +676,7 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
 	if (ret)
 		goto err_pin_prop;
 	refcount_set(&pin->refcount, 1);
+	INIT_LIST_HEAD(&pin->links);
 	xa_init_flags(&pin->dpll_refs, XA_FLAGS_ALLOC);
 	xa_init_flags(&pin->parent_refs, XA_FLAGS_ALLOC);
 	xa_init_flags(&pin->ref_sync_pins, XA_FLAGS_ALLOC);
@@ -838,6 +850,65 @@ struct dpll_pin *fwnode_dpll_pin_find(struct fwnode_handle *fwnode,
 }
 EXPORT_SYMBOL_GPL(fwnode_dpll_pin_find);
 
+static bool dpll_pin_has_link(const struct dpll_pin *pin,
+			      const struct fwnode_handle *peer)
+{
+	struct dpll_pin_link *link;
+
+	list_for_each_entry(link, &pin->links, list)
+		if (link->peer == peer)
+			return true;
+
+	return false;
+}
+
+/**
+ * dpll_pin_link_add - add a link from a pin to another pin
+ * @pin: pointer to a dpll pin
+ * @peer: firmware node of the pin at the other end
+ *
+ * Describe a fixed board connection between @pin and the pin of another
+ * device that its driver associates with @peer by dpll_pin_fwnode_set().
+ * The other pin does not need to exist yet. The link is kept until @pin is
+ * released. An existing link is reported also when @pin is registered, so
+ * each user of a shared pin can add the same link.
+ *
+ * Context: Acquires a lock (dpll_lock). Must be called before @pin is
+ *	    registered.
+ * Return:
+ * * 0 on success
+ * * -EEXIST if @pin already has a link to @peer
+ * * -EBUSY if @pin is already registered
+ * * -ENOMEM if the link cannot be allocated
+ */
+int dpll_pin_link_add(struct dpll_pin *pin, struct fwnode_handle *peer)
+{
+	struct dpll_pin_link *link;
+	int ret = 0;
+
+	mutex_lock(&dpll_lock);
+	if (dpll_pin_has_link(pin, peer)) {
+		ret = -EEXIST;
+		goto unlock;
+	}
+	if (WARN_ON(xa_get_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED))) {
+		ret = -EBUSY;
+		goto unlock;
+	}
+	link = kzalloc_obj(*link);
+	if (!link) {
+		ret = -ENOMEM;
+		goto unlock;
+	}
+	link->peer = fwnode_handle_get(peer);
+	list_add_tail(&link->list, &pin->links);
+unlock:
+	mutex_unlock(&dpll_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(dpll_pin_link_add);
+
 static int
 __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
 		    const struct dpll_pin_ops *ops, void *priv, void *cookie)
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index da8a369556ed11..26a16df2b6410d 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -47,6 +47,7 @@ struct dpll_device {
  * @module:		module of creator
  * @module_name:	module name of creator
  * @fwnode:		optional reference to firmware node
+ * @links:		links to other pins (struct dpll_pin_link)
  * @dpll_refs:		hold referencees to dplls pin was registered with
  * @parent_refs:	hold references to parent pins pin was registered with
  * @ref_sync_pins:	hold references to pins for Reference SYNC feature
@@ -62,6 +63,7 @@ struct dpll_pin {
 	struct module *module;
 	char module_name[MODULE_NAME_LEN];
 	struct fwnode_handle *fwnode;
+	struct list_head links;
 	struct xarray dpll_refs;
 	struct xarray parent_refs;
 	struct xarray ref_sync_pins;
@@ -71,6 +73,16 @@ struct dpll_pin {
 	struct rcu_head rcu;
 };
 
+/**
+ * struct dpll_pin_link - wire between a pin and another pin
+ * @list:		entry in the links list of the pin
+ * @peer:		firmware node of the pin at the other end
+ **/
+struct dpll_pin_link {
+	struct list_head list;
+	struct fwnode_handle *peer;
+};
+
 /**
  * struct dpll_pin_ref - structure for referencing either dpll or pins
  * @dpll:		pointer to a dpll
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 7a6f8796cda2ad..e252d3c6b4334a 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -301,6 +301,8 @@ void dpll_pin_put(struct dpll_pin *pin, dpll_tracker *tracker);
 
 void dpll_pin_fwnode_set(struct dpll_pin *pin, struct fwnode_handle *fwnode);
 
+int dpll_pin_link_add(struct dpll_pin *pin, struct fwnode_handle *peer);
+
 int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
 			     const struct dpll_pin_ops *ops, void *priv);
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 02/19] dpll: report pin links
  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
  2026-11-26 20:32 ` [PATCH RFC net-next 03/19] dpll: notify linked pins when a pin is registered or unregistered Ivan Vecera
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

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


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 03/19] dpll: notify linked pins when a pin is registered or unregistered
  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 ` [PATCH RFC net-next 02/19] dpll: report " Ivan Vecera
@ 2026-11-26 20:32 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 04/19] dpll: add KUnit tests for pin links Ivan Vecera
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

A link is reported only while the pins at both ends are registered. When
a pin gets its first registration or loses its last one, send a change
notification for every registered pin linked with it, so user space sees
the link appear and disappear at both ends.

The notifications follow the registration of the pin. A link also
disappears from the report when the last registered dpll device of
the pin goes away, so a pin with a link or a firmware node has to be
unregistered before its dpll devices, as zl3073x and ice do. The
documentation says so.

The notifications are sent from one helper, under dpll_lock like the
other notifications. The message about a linked pin is built with the
callbacks of its owner, also when another driver registers the pin at
the other end.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst |  6 ++++++
 drivers/dpll/dpll_core.c          | 24 ++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index aed92693d9e604..7b083a59f0122d 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -370,6 +370,12 @@ each of them with the id of the pin at the other end:
     ``DPLL_A_PIN_ID``            id of the pin at the other end
   ============================== ==========================================
 
+When a pin gets its first registration or loses its last one, the
+subsystem sends ``DPLL_CMD_PIN_CHANGE_NTF`` for the registered pins
+linked with it. A pin with a link or a firmware node has to be
+unregistered before the dpll devices it is registered with, otherwise
+its links disappear without a notification.
+
 For example, an output of a DPLL chip wired to an input of a network
 controller::
 
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 6c61801a293b7e..58a5a4a41a0b72 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -929,10 +929,30 @@ int dpll_pin_link_add(struct dpll_pin *pin, struct fwnode_handle *peer)
 }
 EXPORT_SYMBOL_GPL(dpll_pin_link_add);
 
+/**
+ * dpll_pin_links_ntf - notify the pins linked with a pin
+ * @pin: pin that was registered or unregistered
+ *
+ * A link is reported only while the pins at both ends are registered, so
+ * send a change notification for every registered pin linked with @pin.
+ */
+static void dpll_pin_links_ntf(struct dpll_pin *pin)
+{
+	struct dpll_pin *pos;
+	unsigned long i;
+
+	if (list_empty(&pin->links) && !pin->fwnode)
+		return;
+	xa_for_each_marked(&dpll_pin_xa, i, pos, DPLL_REGISTERED)
+		if (pos != pin && dpll_pins_linked(pin, pos))
+			__dpll_pin_change_ntf(pos);
+}
+
 static int
 __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
 		    const struct dpll_pin_ops *ops, void *priv, void *cookie)
 {
+	bool registered;
 	int ret;
 
 	ret = dpll_xa_ref_pin_add(&dpll->pin_refs, pin, ops, priv, cookie);
@@ -941,8 +961,11 @@ __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
 	ret = dpll_xa_ref_dpll_add(&pin->dpll_refs, dpll, ops, priv, cookie);
 	if (ret)
 		goto ref_pin_del;
+	registered = xa_get_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
 	xa_set_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
 	dpll_pin_create_ntf(pin, dpll->clock_id);
+	if (!registered)
+		dpll_pin_links_ntf(pin);
 
 	return ret;
 
@@ -1035,6 +1058,7 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
 	if (xa_empty(&pin->dpll_refs)) {
 		dpll_pin_ref_sync_pair_del(pin->id);
 		xa_clear_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
+		dpll_pin_links_ntf(pin);
 	}
 }
 
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 04/19] dpll: add KUnit tests for pin links
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (2 preceding siblings ...)
  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 ` 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
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Add a KUnit suite with a mock driver of two owners that differ in
clock_id: a pin of one owner with a firmware node and a pin of the other
owner with a link to it. The tests check that:

- the link is reported for both pins only while both are registered,
  whichever of them is registered first
- the pin at the other end gets a change notification whenever the link
  appears or disappears
- a pin keeps its link when it is unregistered and registered again
- for a pin registered with two DPLLs of its owner, only the first
  registration and the last unregistration change the link
- a pin with neither a link nor a firmware node is not linked or notified
- a duplicate link is rejected, also on a registered pin, and a new
  link cannot be added to a registered pin

The tests build the pin message with dpll_cmd_pin_get_one() under
dpll_lock, so both are exported for KUnit.

Run them with:

  tools/testing/kunit/kunit.py run --kunitconfig=drivers/dpll

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/.kunitconfig       |   5 +
 drivers/dpll/Kconfig            |  16 ++
 drivers/dpll/Makefile           |   2 +
 drivers/dpll/dpll_core.c        |   2 +
 drivers/dpll/dpll_netlink.c     |   4 +-
 drivers/dpll/dpll_netlink.h     |   6 +
 drivers/dpll/tests/dpll_kunit.c | 419 ++++++++++++++++++++++++++++++++
 7 files changed, 453 insertions(+), 1 deletion(-)
 create mode 100644 drivers/dpll/.kunitconfig
 create mode 100644 drivers/dpll/tests/dpll_kunit.c

diff --git a/drivers/dpll/.kunitconfig b/drivers/dpll/.kunitconfig
new file mode 100644
index 00000000000000..017c9d5b593a4f
--- /dev/null
+++ b/drivers/dpll/.kunitconfig
@@ -0,0 +1,5 @@
+CONFIG_KUNIT=y
+CONFIG_NET=y
+CONFIG_DPLL_KUNIT_TEST=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_PROVE_LOCKING=y
diff --git a/drivers/dpll/Kconfig b/drivers/dpll/Kconfig
index be98969f040ab6..6f1ffc3a6e7717 100644
--- a/drivers/dpll/Kconfig
+++ b/drivers/dpll/Kconfig
@@ -23,6 +23,22 @@ config DPLL_REFCNT_TRACKER
 
 	  If unsure, say N.
 
+config DPLL_KUNIT_TEST
+	tristate "KUnit tests for DPLL core" if !KUNIT_ALL_TESTS
+	depends on KUNIT && NET
+	select DPLL
+	default KUNIT_ALL_TESTS
+	help
+	  KUnit tests for the DPLL core. They use a mock driver to check
+	  that links between pins of two devices are reported and notified
+	  while the pins at both ends are registered.
+
+	  The mock devices and pins are registered with the DPLL subsystem,
+	  so user space sees them and their notifications while the tests
+	  run.
+
+	  If unsure, say N.
+
 source "drivers/dpll/zl3073x/Kconfig"
 
 endmenu
diff --git a/drivers/dpll/Makefile b/drivers/dpll/Makefile
index 9e7a3a3e592e81..ef3081be2a113b 100644
--- a/drivers/dpll/Makefile
+++ b/drivers/dpll/Makefile
@@ -8,4 +8,6 @@ dpll-y                  += dpll_core.o
 dpll-y                  += dpll_netlink.o
 dpll-y                  += dpll_nl.o
 
+obj-$(CONFIG_DPLL_KUNIT_TEST)	+= tests/dpll_kunit.o
+
 obj-$(CONFIG_ZL3073X)	+= zl3073x/
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 58a5a4a41a0b72..7fd84b0e90e993 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -8,6 +8,7 @@
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 
+#include <kunit/visibility.h>
 #include <linux/device.h>
 #include <linux/err.h>
 #include <linux/idr.h>
@@ -21,6 +22,7 @@
 
 /* Mutex lock to protect DPLL subsystem devices and pins */
 DEFINE_MUTEX(dpll_lock);
+EXPORT_SYMBOL_IF_KUNIT(dpll_lock);
 
 DEFINE_XARRAY_FLAGS(dpll_device_xa, XA_FLAGS_ALLOC);
 DEFINE_XARRAY_FLAGS(dpll_pin_xa, XA_FLAGS_ALLOC);
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 016f3026d2f2e5..931ea2027cf68f 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -6,6 +6,7 @@
  *  Copyright (c) 2023 Intel and affiliates
  *
  */
+#include <kunit/visibility.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
@@ -735,7 +736,7 @@ static int dpll_msg_add_pin_links(struct sk_buff *msg, struct dpll_pin *pin)
 	return 0;
 }
 
-static int
+VISIBLE_IF_KUNIT int
 dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
 		     struct netlink_ext_ack *extack)
 {
@@ -811,6 +812,7 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
 
 	return dpll_msg_add_pin_links(msg, pin);
 }
+EXPORT_SYMBOL_IF_KUNIT(dpll_cmd_pin_get_one);
 
 static int
 dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
diff --git a/drivers/dpll/dpll_netlink.h b/drivers/dpll/dpll_netlink.h
index 4f63aa58789a17..bc20bcd248a512 100644
--- a/drivers/dpll/dpll_netlink.h
+++ b/drivers/dpll/dpll_netlink.h
@@ -11,3 +11,9 @@ int dpll_device_delete_ntf(struct dpll_device *dpll);
 int dpll_pin_create_ntf(struct dpll_pin *pin, u64 src_clock_id);
 
 int dpll_pin_delete_ntf(struct dpll_pin *pin, u64 src_clock_id);
+
+#if IS_ENABLED(CONFIG_KUNIT)
+/* For KUnit tests, call with dpll_lock held for a registered pin */
+int dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
+			 struct netlink_ext_ack *extack);
+#endif
diff --git a/drivers/dpll/tests/dpll_kunit.c b/drivers/dpll/tests/dpll_kunit.c
new file mode 100644
index 00000000000000..7fb50fe0eea9a5
--- /dev/null
+++ b/drivers/dpll/tests/dpll_kunit.c
@@ -0,0 +1,419 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * KUnit tests for links between DPLL pins.
+ *
+ * Each test starts with two owners that differ in clock_id:
+ *
+ * Owner A: devices A0 and A1, pin P with firmware node F, pin U with
+ *          neither a firmware node nor a link
+ * Owner B: device B0, pin C with a link to F
+ *
+ * The devices are registered, the pins are not.
+ */
+
+#include <kunit/fwnode.h>
+#include <kunit/test.h>
+#include <linux/dpll.h>
+#include <linux/notifier.h>
+#include <net/netlink.h>
+
+#include "../dpll_core.h"
+#include "../dpll_netlink.h"
+
+MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+
+#define DT_CLOCK_ID_A		0xd011a
+#define DT_CLOCK_ID_B		0xd011b
+#define DT_MAX_LINKS		4
+
+struct dt_dev {
+	struct dpll_device *dpll;
+	dpll_tracker tracker;
+	bool registered;
+};
+
+struct dt_pin {
+	struct dpll_pin *pin;
+	dpll_tracker tracker;
+	int changes;		/* DPLL_PIN_CHANGED notifications */
+};
+
+struct dt_ctx {
+	struct dt_dev a0, a1, b0;
+	struct dt_pin p, u, c;
+	struct fwnode_handle *fwnode;
+	struct notifier_block nb;
+	bool nb_registered;
+	bool p_a0, p_a1, u_a0, c_b0;	/* registrations */
+};
+
+static int dt_mode_get(const struct dpll_device *dpll, void *dpll_priv,
+		       enum dpll_mode *mode, struct netlink_ext_ack *extack)
+{
+	*mode = DPLL_MODE_MANUAL;
+	return 0;
+}
+
+static int dt_lock_status_get(const struct dpll_device *dpll, void *dpll_priv,
+			      enum dpll_lock_status *status,
+			      enum dpll_lock_status_error *status_error,
+			      struct netlink_ext_ack *extack)
+{
+	*status = DPLL_LOCK_STATUS_UNLOCKED;
+	return 0;
+}
+
+static const struct dpll_device_ops dt_dev_ops = {
+	.mode_get = dt_mode_get,
+	.lock_status_get = dt_lock_status_get,
+};
+
+static int dt_state_get(const struct dpll_pin *pin, void *pin_priv,
+			const struct dpll_device *dpll, void *dpll_priv,
+			enum dpll_pin_state *state,
+			struct netlink_ext_ack *extack)
+{
+	*state = DPLL_PIN_STATE_CONNECTED;
+	return 0;
+}
+
+static int dt_direction_get(const struct dpll_pin *pin, void *pin_priv,
+			    const struct dpll_device *dpll, void *dpll_priv,
+			    enum dpll_pin_direction *direction,
+			    struct netlink_ext_ack *extack)
+{
+	*direction = DPLL_PIN_DIRECTION_INPUT;
+	return 0;
+}
+
+static const struct dpll_pin_ops dt_pin_ops = {
+	.state_on_dpll_get = dt_state_get,
+	.direction_get = dt_direction_get,
+};
+
+static const struct dpll_pin_properties dt_pin_prop = {
+	.type = DPLL_PIN_TYPE_EXT,
+};
+
+static int dt_notify(struct notifier_block *nb, unsigned long action,
+		     void *data)
+{
+	struct dt_ctx *ctx = container_of(nb, struct dt_ctx, nb);
+	struct dpll_pin_notifier_info *info = data;
+
+	if (action != DPLL_PIN_CHANGED)
+		return NOTIFY_DONE;
+	if (info->pin == ctx->p.pin)
+		ctx->p.changes++;
+	else if (info->pin == ctx->u.pin)
+		ctx->u.changes++;
+	else if (info->pin == ctx->c.pin)
+		ctx->c.changes++;
+
+	return NOTIFY_OK;
+}
+
+static void dt_dev_init(struct kunit *test, struct dt_dev *dev, u64 clock_id,
+			u32 idx)
+{
+	int ret;
+
+	dev->dpll = dpll_device_get(clock_id, idx, THIS_MODULE, &dev->tracker);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev->dpll);
+	ret = dpll_device_register(dev->dpll, DPLL_TYPE_EEC, &dt_dev_ops, dev);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+	dev->registered = true;
+}
+
+static void dt_dev_fini(struct dt_dev *dev)
+{
+	if (IS_ERR_OR_NULL(dev->dpll))
+		return;
+	if (dev->registered)
+		dpll_device_unregister(dev->dpll, &dt_dev_ops, dev);
+	dpll_device_put(dev->dpll, &dev->tracker);
+}
+
+static void dt_pin_get(struct kunit *test, struct dt_pin *pin, u64 clock_id,
+		       u32 idx)
+{
+	pin->pin = dpll_pin_get(clock_id, idx, THIS_MODULE, &dt_pin_prop,
+				&pin->tracker);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pin->pin);
+}
+
+static void dt_pin_put(struct dt_pin *pin)
+{
+	if (!IS_ERR_OR_NULL(pin->pin))
+		dpll_pin_put(pin->pin, &pin->tracker);
+}
+
+static void dt_reg(struct kunit *test, struct dt_dev *dev, struct dt_pin *pin,
+		   bool *registered)
+{
+	int ret;
+
+	ret = dpll_pin_register(dev->dpll, pin->pin, &dt_pin_ops, pin);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+	*registered = true;
+}
+
+static void dt_unreg(struct dt_dev *dev, struct dt_pin *pin, bool *registered)
+{
+	if (!*registered)
+		return;
+	dpll_pin_unregister(dev->dpll, pin->pin, &dt_pin_ops, pin);
+	*registered = false;
+}
+
+/* Fill @ids with the pins reported as linked with @pin, return their count */
+static int dt_links(struct kunit *test, struct dt_pin *pin, u32 *ids)
+{
+	struct sk_buff *msg;
+	struct nlattr *attr;
+	int n = 0, rem, ret;
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, msg);
+	mutex_lock(&dpll_lock);
+	ret = dpll_cmd_pin_get_one(msg, pin->pin, NULL);
+	mutex_unlock(&dpll_lock);
+	if (!ret)
+		nla_for_each_attr_type(attr, DPLL_A_PIN_LINK,
+				       (struct nlattr *)msg->data, msg->len,
+				       rem) {
+			struct nlattr *id = nla_find_nested(attr,
+							    DPLL_A_PIN_ID);
+
+			if (id && n < DT_MAX_LINKS)
+				ids[n] = nla_get_u32(id);
+			n++;
+		}
+	nlmsg_free(msg);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+	KUNIT_ASSERT_LE(test, n, DT_MAX_LINKS);
+
+	return n;
+}
+
+/* Check that @pin is reported as linked with @peer only */
+static void dt_expect_link(struct kunit *test, struct dt_pin *pin,
+			   struct dt_pin *peer)
+{
+	u32 ids[DT_MAX_LINKS];
+
+	KUNIT_ASSERT_EQ(test, dt_links(test, pin, ids), 1);
+	KUNIT_EXPECT_EQ(test, ids[0], peer->pin->id);
+}
+
+static void dt_expect_no_link(struct kunit *test, struct dt_pin *pin)
+{
+	u32 ids[DT_MAX_LINKS];
+
+	KUNIT_EXPECT_EQ(test, dt_links(test, pin, ids), 0);
+}
+
+static int dt_init(struct kunit *test)
+{
+	struct dt_ctx *ctx;
+	int ret;
+
+	ctx = kunit_kzalloc(test, sizeof(*ctx), GFP_KERNEL);
+	KUNIT_ASSERT_NOT_NULL(test, ctx);
+	test->priv = ctx;
+
+	ctx->fwnode = kunit_fwnode_create_software_node(test, NULL, NULL);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx->fwnode);
+
+	dt_dev_init(test, &ctx->a0, DT_CLOCK_ID_A, 0);
+	dt_dev_init(test, &ctx->a1, DT_CLOCK_ID_A, 1);
+	dt_dev_init(test, &ctx->b0, DT_CLOCK_ID_B, 0);
+	dt_pin_get(test, &ctx->p, DT_CLOCK_ID_A, 0);
+	dt_pin_get(test, &ctx->u, DT_CLOCK_ID_A, 1);
+	dt_pin_get(test, &ctx->c, DT_CLOCK_ID_B, 0);
+	dpll_pin_fwnode_set(ctx->p.pin, ctx->fwnode);
+	ret = dpll_pin_link_add(ctx->c.pin, ctx->fwnode);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+
+	ctx->nb.notifier_call = dt_notify;
+	ret = register_dpll_notifier(&ctx->nb);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+	ctx->nb_registered = true;
+
+	return 0;
+}
+
+static void dt_exit(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	if (!ctx)
+		return;
+	if (ctx->nb_registered)
+		unregister_dpll_notifier(&ctx->nb);
+	dt_unreg(&ctx->a0, &ctx->p, &ctx->p_a0);
+	dt_unreg(&ctx->a1, &ctx->p, &ctx->p_a1);
+	dt_unreg(&ctx->a0, &ctx->u, &ctx->u_a0);
+	dt_unreg(&ctx->b0, &ctx->c, &ctx->c_b0);
+	dt_pin_put(&ctx->c);
+	dt_pin_put(&ctx->u);
+	dt_pin_put(&ctx->p);
+	dt_dev_fini(&ctx->b0);
+	dt_dev_fini(&ctx->a1);
+	dt_dev_fini(&ctx->a0);
+}
+
+/* The pin with the link is registered before the pin it names */
+static void dt_test_link_first(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	dt_expect_no_link(test, &ctx->c);
+
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 1);
+	dt_expect_link(test, &ctx->c, &ctx->p);
+	dt_expect_link(test, &ctx->p, &ctx->c);
+}
+
+/* The pin named by the link is registered first */
+static void dt_test_link_last(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	dt_expect_no_link(test, &ctx->p);
+
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	KUNIT_EXPECT_EQ(test, ctx->p.changes, 1);
+	dt_expect_link(test, &ctx->p, &ctx->c);
+	dt_expect_link(test, &ctx->c, &ctx->p);
+}
+
+/* The pin named by the link goes away and comes back */
+static void dt_test_peer_reregister(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 1);
+
+	dt_unreg(&ctx->a0, &ctx->p, &ctx->p_a0);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 2);
+	dt_expect_no_link(test, &ctx->c);
+
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 3);
+	dt_expect_link(test, &ctx->c, &ctx->p);
+}
+
+/* The link stays with its pin when the pin is unregistered */
+static void dt_test_link_reregister(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	KUNIT_EXPECT_EQ(test, ctx->p.changes, 1);
+
+	dt_unreg(&ctx->b0, &ctx->c, &ctx->c_b0);
+	KUNIT_EXPECT_EQ(test, ctx->p.changes, 2);
+	dt_expect_no_link(test, &ctx->p);
+
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	KUNIT_EXPECT_EQ(test, ctx->p.changes, 3);
+	dt_expect_link(test, &ctx->p, &ctx->c);
+}
+
+/* Only the first registration and the last unregistration change the link */
+static void dt_test_peer_two_dplls(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	dt_reg(test, &ctx->a1, &ctx->p, &ctx->p_a1);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 1);
+
+	dt_unreg(&ctx->a0, &ctx->p, &ctx->p_a0);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 1);
+	dt_expect_link(test, &ctx->c, &ctx->p);
+
+	dt_unreg(&ctx->a1, &ctx->p, &ctx->p_a1);
+	KUNIT_EXPECT_EQ(test, ctx->c.changes, 2);
+	dt_expect_no_link(test, &ctx->c);
+}
+
+/* A pin without a link and a firmware node is not linked or notified */
+static void dt_test_unrelated(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_reg(test, &ctx->a0, &ctx->u, &ctx->u_a0);
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	dt_unreg(&ctx->a0, &ctx->p, &ctx->p_a0);
+
+	KUNIT_EXPECT_EQ(test, ctx->u.changes, 0);
+	dt_expect_no_link(test, &ctx->u);
+	dt_expect_no_link(test, &ctx->c);
+}
+
+/* A duplicate link is rejected, also on a registered pin */
+static void dt_test_add_duplicate(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+	int ret;
+
+	ret = dpll_pin_link_add(ctx->c.pin, ctx->fwnode);
+	KUNIT_EXPECT_EQ(test, ret, -EEXIST);
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+
+	kunit_warning_suppress(test) {
+		ret = dpll_pin_link_add(ctx->c.pin, ctx->fwnode);
+		KUNIT_EXPECT_EQ(test, ret, -EEXIST);
+		KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, 0);
+	}
+}
+
+static void dt_test_add_registered(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+	struct fwnode_handle *other;
+
+	other = kunit_fwnode_create_software_node(test, NULL, NULL);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, other);
+	dt_reg(test, &ctx->b0, &ctx->c, &ctx->c_b0);
+
+	kunit_warning_suppress(test) {
+		KUNIT_EXPECT_EQ(test, dpll_pin_link_add(ctx->c.pin, other),
+				-EBUSY);
+		KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, 1);
+	}
+}
+
+static struct kunit_case dt_cases[] = {
+	KUNIT_CASE(dt_test_link_first),
+	KUNIT_CASE(dt_test_link_last),
+	KUNIT_CASE(dt_test_peer_reregister),
+	KUNIT_CASE(dt_test_link_reregister),
+	KUNIT_CASE(dt_test_peer_two_dplls),
+	KUNIT_CASE(dt_test_unrelated),
+	KUNIT_CASE(dt_test_add_duplicate),
+	KUNIT_CASE(dt_test_add_registered),
+	{}
+};
+
+static struct kunit_suite dt_suite = {
+	.name = "dpll_pin_link",
+	.init = dt_init,
+	.exit = dt_exit,
+	.test_cases = dt_cases,
+};
+
+kunit_test_suite(dt_suite);
+
+MODULE_DESCRIPTION("KUnit tests for links between DPLL pins");
+MODULE_LICENSE("GPL");
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 05/19] ice: dpll: use own pins for the TX and time references
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (3 preceding siblings ...)
  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 ` 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
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

On E825 the TXC DPLL of each PF uses the zl3073x output pin wired to its
SyncE TX reference input, and the TSPLL DPLL of the PF that owns the
source timer uses the zl3073x output pin wired to its time reference
input. The driver finds these pins by firmware node, registers them with
its own DPLLs and uses the DPLL notifier to wait for them and to follow
their removal.

Register own pins instead, EXT_SYNCE next to EXT_EREF0 with the TXC DPLL
and TIME_REF with the TSPLL DPLL, and link each of them with the zl3073x
pin through the same firmware node. The pins keep the callbacks they had,
so the hardware is programmed as before. The notifier now serves the
recovered clock pin only.

The pins and EXT_EREF0 get dynamic pin indices. Without a valid MAC
address the TXC and TSPLL DPLLs fall back to the clock_id of the PF, and
fixed indices would make TIME_REF the EXT_EREF0 pin and EXT_SYNCE a pin
shared by the PFs of a NAC.

What user space sees on E825 changes:
- the zl3073x pins list only zl3073x DPLLs as parent devices and report
  a link to EXT_SYNCE of each PF or to TIME_REF
- the SyncE TX reference is selected by the state of EXT_SYNCE on the
  TXC DPLL and the time reference by the state of TIME_REF on the TSPLL
  DPLL, instead of the state of the zl3073x pins on those DPLLs
- EXT_SYNCE and TIME_REF report no frequency
- both pins exist also when the zl3073x driver is not loaded

Tested on a GNR-D platform with a dual NAC E825 and a ZL80132B DPLL: the
EXT_SYNCE pins of the eight PFs and the TIME_REF pin report their links
to the zl3073x outputs and stay without them while zl3073x is unloaded,
and connecting EXT_SYNCE on the TXC DPLL of a PF locks the DPLL.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/net/ethernet/intel/ice/ice_dpll.c | 276 ++++++++++------------
 drivers/net/ethernet/intel/ice/ice_dpll.h |   2 +-
 2 files changed, 121 insertions(+), 157 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index 5148e419f49a07..15b5f4a15af915 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -85,6 +85,8 @@ static const char * const pin_type_name[] = {
 static const char * const ice_dpll_sw_pin_sma[] = { "SMA1", "SMA2" };
 static const char * const ice_dpll_sw_pin_ufl[] = { "U.FL1", "U.FL2" };
 static const char * const ice_dpll_ext_eref_pin = "EXT_EREF0";
+static const char * const ice_dpll_ext_synce_pin = "EXT_SYNCE";
+static const char * const ice_dpll_time_ref_pin = "TIME_REF";
 static const char * const ice_dpll_fwnode_ext_synce = "clk_ref_synce";
 static const char * const ice_dpll_fwnode_time_ref = "time_ref";
 
@@ -3792,8 +3794,6 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
 						   struct ice_dpll_pin_work,
 						   work);
 	struct ice_dpll_pin *pin, *parent = w->pin;
-	bool is_tx_synce_parent = false;
-	bool is_tspll_time_ref = false;
 	struct ice_pf *pf = parent->pf;
 	bool is_rclk_parent = false;
 	int ret;
@@ -3811,14 +3811,7 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
 		}
 	}
 
-	is_tx_synce_parent =
-		ice_dpll_fwnode_eq(parent->fwnode,
-				   pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX].fwnode);
-
-	is_tspll_time_ref =
-		ice_dpll_fwnode_eq(parent->fwnode, pf->dplls.tspll_in.fwnode);
-
-	if (!is_rclk_parent && !is_tx_synce_parent && !is_tspll_time_ref)
+	if (!is_rclk_parent)
 		goto out;
 
 	switch (w->action) {
@@ -3837,40 +3830,15 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
 			goto out;
 		}
 
-		if (is_rclk_parent) {
-			/* Register rclk pin via on-pin relationship */
-			pin = &pf->dplls.rclk;
-			ret = dpll_pin_on_pin_register(parent->pin, pin->pin,
-						       &ice_dpll_rclk_ops, pin);
-			if (ret) {
-				dev_err(ice_pf_to_dev(pf),
-					"RCLK pin register failed: %pe\n",
-					ERR_PTR(ret));
-				goto drop_parent_ref;
-			}
-		} else if (is_tx_synce_parent) {
-			/* Register TX-CLK SYNCE pin directly to TXC DPLL */
-			pin = &pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX];
-			ret = dpll_pin_register(pf->dplls.txc.dpll, pin->pin,
-						&ice_dpll_txclk_ops, pin);
-			if (ret) {
-				dev_err(ice_pf_to_dev(pf),
-					"TX SYNCE pin register failed: %pe\n",
-					ERR_PTR(ret));
-				goto drop_parent_ref;
-			}
-		} else if (is_tspll_time_ref) {
-			/* Register TIME_REF pin directly to TSPLL DPLL */
-			ret = dpll_pin_register(pf->dplls.tspll.dpll,
-						parent->pin,
-						&ice_dpll_tspll_in_ops,
-						parent);
-			if (ret) {
-				dev_err(ice_pf_to_dev(pf),
-					"TSPLL TIME_REF pin register failed: %pe\n",
-					ERR_PTR(ret));
-				goto drop_parent_ref;
-			}
+		/* Register rclk pin via on-pin relationship */
+		pin = &pf->dplls.rclk;
+		ret = dpll_pin_on_pin_register(parent->pin, pin->pin,
+					       &ice_dpll_rclk_ops, pin);
+		if (ret) {
+			dev_err(ice_pf_to_dev(pf),
+				"RCLK pin register failed: %pe\n",
+				ERR_PTR(ret));
+			goto drop_parent_ref;
 		}
 		break;
 	case DPLL_PIN_DELETED:
@@ -3879,22 +3847,10 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
 			goto out;
 		}
 
-		if (is_rclk_parent) {
-			/* Unregister rclk pin */
-			pin = &pf->dplls.rclk;
-			dpll_pin_on_pin_unregister(parent->pin, pin->pin,
-						   &ice_dpll_rclk_ops, pin);
-		} else if (is_tx_synce_parent) {
-			/* Unregister TX-CLK SYNCE pin from TXC DPLL */
-			pin = &pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX];
-			dpll_pin_unregister(pf->dplls.txc.dpll, pin->pin,
-					    &ice_dpll_txclk_ops, pin);
-		} else if (is_tspll_time_ref) {
-			/* Unregister TIME_REF pin from TSPLL DPLL */
-			dpll_pin_unregister(pf->dplls.tspll.dpll,
-					    parent->pin,
-					    &ice_dpll_tspll_in_ops, parent);
-		}
+		/* Unregister rclk pin */
+		pin = &pf->dplls.rclk;
+		dpll_pin_on_pin_unregister(parent->pin, pin->pin,
+					   &ice_dpll_rclk_ops, pin);
 drop_parent_ref:
 		/* Drop fwnode pin reference */
 		dpll_pin_put(parent->pin, &parent->tracker);
@@ -4067,43 +4023,36 @@ ice_dpll_deinit_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
 	destroy_workqueue(pf->dplls.wq);
 }
 
-static int ice_dpll_deinit_txclk_pins(struct ice_pf *pf, bool flush)
+static void ice_dpll_deinit_txclk_pins(struct ice_pf *pf)
 {
-	struct ice_dpll_pin *synce_pin = &pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX];
-	struct ice_dpll *dt = &pf->dplls.txc;
+	struct ice_dplls *d = &pf->dplls;
+	int i;
 
-	ice_dpll_stop_fwnode_pin_activity(synce_pin, flush);
-	ice_dpll_unregister_pins(dt->dpll, pf->dplls.txclks,
-				 &ice_dpll_txclk_ops,
-				 ARRAY_SIZE(pf->dplls.txclks));
-	ice_dpll_release_pins(&pf->dplls.txclks[E825_EXT_EREF_PIN_IDX], 1);
-	/* ice_dpll_release_pins() puts the pin but does not clear the slot,
-	 * unlike ice_dpll_release_fwnode_pin() used for SYNCE below. NULL it
-	 * so a late ice_txclk_get_pin() returns NULL rather than a dangling
-	 * pointer.
+	ice_dpll_unregister_pins(d->txc.dpll, d->txclks, &ice_dpll_txclk_ops,
+				 ARRAY_SIZE(d->txclks));
+	ice_dpll_release_pins(d->txclks, ARRAY_SIZE(d->txclks));
+	/* ice_dpll_release_pins() puts the pins but does not clear the slots.
+	 * Clear them so a late ice_txclk_get_pin() returns NULL rather than a
+	 * dangling pointer.
 	 */
-	pf->dplls.txclks[E825_EXT_EREF_PIN_IDX].pin = NULL;
-	ice_dpll_release_fwnode_pin(synce_pin);
-	return 0;
+	for (i = 0; i < ARRAY_SIZE(d->txclks); i++)
+		d->txclks[i].pin = NULL;
 }
 
 /**
- * ice_dpll_deinit_tspll_pins - deinitialize TSPLL fwnode pin
+ * ice_dpll_deinit_tspll_pins - deinitialize TSPLL pin
  * @pf: board private structure
  *
- * Stop notifier activity and release the TIME_REF fwnode pin, unregistering
- * it from the TSPLL DPLL if it was registered.
+ * Unregister the TIME_REF pin from the TSPLL DPLL and release it.
  */
 static void ice_dpll_deinit_tspll_pins(struct ice_pf *pf)
 {
 	struct ice_dpll_pin *time_ref = &pf->dplls.tspll_in;
-	struct ice_dpll *tp = &pf->dplls.tspll;
 
-	ice_dpll_stop_fwnode_pin_activity(time_ref, true);
-	if (!IS_ERR_OR_NULL(time_ref->pin))
-		dpll_pin_unregister(tp->dpll, time_ref->pin,
-				    &ice_dpll_tspll_in_ops, time_ref);
-	ice_dpll_release_fwnode_pin(time_ref);
+	ice_dpll_unregister_pins(pf->dplls.tspll.dpll, time_ref,
+				 &ice_dpll_tspll_in_ops, 1);
+	ice_dpll_release_pins(time_ref, 1);
+	time_ref->pin = NULL;
 }
 
 /**
@@ -4129,7 +4078,7 @@ static void ice_dpll_deinit_pins(struct ice_pf *pf, bool cgu)
 		if (ice_pf_src_tmr_owned(pf) &&
 		    test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
 			ice_dpll_deinit_tspll_pins(pf);
-		ice_dpll_deinit_txclk_pins(pf, true);
+		ice_dpll_deinit_txclk_pins(pf);
 		ice_dpll_deinit_fwnode_pins(pf, pf->dplls.inputs, 0);
 	}
 	if (cgu) {
@@ -4173,6 +4122,34 @@ ice_dpll_pin_node_get(struct ice_pf *pf, const char *name)
 	return fwnode_find_reference(fwnode, "dpll-pins", index);
 }
 
+/**
+ * ice_dpll_pin_link_add - link a pin with the pin wired to it
+ * @pf: board private structure
+ * @pin: pin of the driver
+ * @name: name of the firmware node of the pin at the other end
+ *
+ * Return:
+ * * 0 - success
+ * * negative - failure reason
+ */
+static int ice_dpll_pin_link_add(struct ice_pf *pf, struct dpll_pin *pin,
+				 const char *name)
+{
+	struct fwnode_handle *fwnode;
+	int ret;
+
+	fwnode = ice_dpll_pin_node_get(pf, name);
+	if (IS_ERR(fwnode)) {
+		dev_err(ice_pf_to_dev(pf),
+			"Failed to find %s firmware node: %pe\n", name, fwnode);
+		return -ENODEV;
+	}
+	ret = dpll_pin_link_add(pin, fwnode);
+	fwnode_handle_put(fwnode);
+
+	return ret;
+}
+
 static int
 ice_dpll_init_fwnode_pin(struct ice_dpll_pin *pin, const char *name)
 {
@@ -4266,77 +4243,58 @@ ice_dpll_init_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
 	return ret;
 }
 
-static int ice_dpll_init_txclk_pins(struct ice_pf *pf, int start_idx)
+/**
+ * ice_dpll_init_txclk_pins - init and register TX reference clock pins
+ * @pf: board private structure
+ *
+ * Get the EXT_EREF0 and EXT_SYNCE pins, link EXT_SYNCE with the pin wired to
+ * it and register both pins with the TXC DPLL.
+ *
+ * Return:
+ * * 0 - success
+ * * negative - initialization failure reason
+ */
+static int ice_dpll_init_txclk_pins(struct ice_pf *pf)
 {
-	struct ice_dpll_pin *ref_pin = pf->dplls.txclks;
+	struct ice_dpll_pin *pins = pf->dplls.txclks;
 	struct ice_dpll *txc = &pf->dplls.txc;
 	u64 clock_id;
-	int ret;
+	int ret, i;
 
-	/* EXT_EREF0 is a non-fwnode pin; its clock_id must match the TX-CLK
-	 * DPLL device clock_id (see dpll_pin_register()).
+	/* The clock_id of the pins must match the TXC DPLL device clock_id
+	 * (see dpll_pin_register()). Without a valid MAC address it is the
+	 * clock_id of the other DPLLs of the NIC, so the pin indices are
+	 * dynamic to keep the pins distinct.
 	 */
 	clock_id = ice_generate_dpll_clock_id(pf, txc, DPLL_TYPE_GENERIC);
-
-	/* Configure EXT_EREF0 pin */
-	ret = ice_dpll_get_pins(pf, ref_pin, start_idx, 1, clock_id);
+	ret = ice_dpll_get_pins(pf, pins, DPLL_PIN_IDX_UNSPEC,
+				ICE_DPLL_TXCLK_NUM_MAX, clock_id);
 	if (ret)
 		return ret;
-	ret = dpll_pin_register(txc->dpll, ref_pin->pin, &ice_dpll_txclk_ops,
-				ref_pin);
+	ret = ice_dpll_pin_link_add(pf, pins[E825_EXT_SYNCE_PIN_IDX].pin,
+				    ice_dpll_fwnode_ext_synce);
 	if (ret)
-		goto err_release_ext_eref;
-
-	/*
-	 * Configure EXT_SYNCE pin (fwnode-backed).
-	 * The pin may not yet be available; in that case registration
-	 * will be deferred via the notifier path.
-	 */
-	ref_pin++;
-	ret = ice_dpll_init_fwnode_pin(ref_pin, ice_dpll_fwnode_ext_synce);
-	if (ret)
-		goto err_unregister_ext_eref;
-
-	if (IS_ERR_OR_NULL(ref_pin->pin)) {
-		dev_dbg(ice_pf_to_dev(pf),
-			"Tx-clk SYNCE pin not registered yet\n");
-		return 0;
-	}
-
-	ret = dpll_pin_register(txc->dpll, ref_pin->pin, &ice_dpll_txclk_ops,
-				ref_pin);
+		goto release_pins;
+	ret = ice_dpll_register_pins(txc->dpll, pins, &ice_dpll_txclk_ops,
+				     ICE_DPLL_TXCLK_NUM_MAX);
 	if (ret)
-		goto err_deinit_synce;
+		goto release_pins;
 
 	return 0;
 
-err_deinit_synce:
-	/*
-	 * Avoid deadlock against notifier workers blocked on dpll_init.
-	 * The outer init error path will complete dpll_init and flush the
-	 * shared workqueue before destroying it.
-	 */
-	ice_dpll_stop_fwnode_pin_activity(ref_pin, false);
-	ice_dpll_release_fwnode_pin(ref_pin);
-err_unregister_ext_eref:
-	dpll_pin_unregister(txc->dpll,
-			    pf->dplls.txclks[E825_EXT_EREF_PIN_IDX].pin,
-			    &ice_dpll_txclk_ops,
-			    &pf->dplls.txclks[E825_EXT_EREF_PIN_IDX]);
-
-err_release_ext_eref:
-	ice_dpll_release_pins(&pf->dplls.txclks[E825_EXT_EREF_PIN_IDX], 1);
-
+release_pins:
+	ice_dpll_release_pins(pins, ICE_DPLL_TXCLK_NUM_MAX);
+	for (i = 0; i < ICE_DPLL_TXCLK_NUM_MAX; i++)
+		pins[i].pin = NULL;
 	return ret;
 }
 
 /**
- * ice_dpll_init_tspll_pins - init and register TSPLL TIME_REF fwnode pin
+ * ice_dpll_init_tspll_pins - init and register TSPLL TIME_REF pin
  * @pf: board private structure
  *
- * Initialize the fwnode-based TIME_REF input pin for the TSPLL DPLL on E825.
- * If the pin is not yet available in the dpll subsystem, registration will
- * be deferred via the notifier path.
+ * Get the TIME_REF input pin of the TSPLL DPLL on E825, link it with the pin
+ * wired to it and register it with the TSPLL DPLL.
  *
  * Return:
  * * 0 - success
@@ -4346,26 +4304,36 @@ static int ice_dpll_init_tspll_pins(struct ice_pf *pf)
 {
 	struct ice_dpll_pin *time_ref = &pf->dplls.tspll_in;
 	struct ice_dpll *tp = &pf->dplls.tspll;
+	u64 clock_id;
 	int ret;
 
 	time_ref->pf = pf;
-	ret = ice_dpll_init_fwnode_pin(time_ref, ice_dpll_fwnode_time_ref);
+	time_ref->prop.type = DPLL_PIN_TYPE_EXT;
+	time_ref->prop.capabilities = DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE;
+	time_ref->prop.board_label = ice_dpll_time_ref_pin;
+
+	/* The clock_id of the pin must match the TSPLL DPLL device clock_id
+	 * (see dpll_pin_register()), the pin index is dynamic as for the TX
+	 * reference pins.
+	 */
+	clock_id = ice_generate_dpll_clock_id(pf, tp, DPLL_TYPE_GENERIC);
+	ret = ice_dpll_get_pins(pf, time_ref, DPLL_PIN_IDX_UNSPEC, 1, clock_id);
 	if (ret)
 		return ret;
-
-	if (IS_ERR_OR_NULL(time_ref->pin)) {
-		dev_dbg(ice_pf_to_dev(pf),
-			"TSPLL TIME_REF pin not registered yet\n");
-		return 0;
-	}
-
+	ret = ice_dpll_pin_link_add(pf, time_ref->pin,
+				    ice_dpll_fwnode_time_ref);
+	if (ret)
+		goto release_pin;
 	ret = dpll_pin_register(tp->dpll, time_ref->pin,
 				&ice_dpll_tspll_in_ops, time_ref);
-	if (ret) {
-		ice_dpll_stop_fwnode_pin_activity(time_ref, false);
-		ice_dpll_release_fwnode_pin(time_ref);
-	}
+	if (ret)
+		goto release_pin;
+
+	return 0;
 
+release_pin:
+	ice_dpll_release_pins(time_ref, 1);
+	time_ref->pin = NULL;
 	return ret;
 }
 
@@ -4394,7 +4362,7 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
 	if (ret)
 		goto unregister_pins;
 
-	ret = ice_dpll_init_txclk_pins(pf, 0);
+	ret = ice_dpll_init_txclk_pins(pf);
 	if (ret) {
 		ice_dpll_deinit_rclk_pin(pf);
 		goto unregister_pins;
@@ -4404,12 +4372,7 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
 	    test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) {
 		ret = ice_dpll_init_tspll_pins(pf);
 		if (ret) {
-			/* Avoid flushing pf->dplls.wq here: notifier work
-			 * items block on pf->dplls.dpll_init which is
-			 * completed by the unregister_pins path below.
-			 * destroy_workqueue() there drains queued items.
-			 */
-			ice_dpll_deinit_txclk_pins(pf, false);
+			ice_dpll_deinit_txclk_pins(pf);
 			ice_dpll_deinit_rclk_pin(pf);
 		}
 	}
@@ -4964,6 +4927,7 @@ static int ice_dpll_init_info_txclk_pins_e825c(struct ice_pf *pf)
 			tx_pin->prop.board_label = ice_dpll_ext_eref_pin;
 			tx_pin->tx_ref_src = ICE_REF_CLK_EREF0;
 		} else if (i == E825_EXT_SYNCE_PIN_IDX) {
+			tx_pin->prop.board_label = ice_dpll_ext_synce_pin;
 			tx_pin->tx_ref_src = ICE_REF_CLK_SYNCE;
 		}
 	}
diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.h b/drivers/net/ethernet/intel/ice/ice_dpll.h
index 3f9a993129acef..e0b48c8af3fbbb 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.h
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.h
@@ -138,7 +138,7 @@ struct ice_dpll {
  * @outputs: output pins pointer
  * @rclk: recovered pins pointer
  * @txclks: TX clock reference pins pointer
- * @tspll_in: TSPLL TIME_REF fwnode input pin (E825 only)
+ * @tspll_in: TSPLL TIME_REF input pin (E825 only)
  * @num_inputs: number of input pins available on dpll
  * @num_outputs: number of output pins available on dpll
  * @cgu_state_acq_err_num: number of errors returned during periodic work
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 06/19] ice: dpll: drop the filter of notifications from own registrations
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (4 preceding siblings ...)
  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 ` 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
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

ice_dpll_pin_notify() ignored the pin notifications that the driver
itself caused when it registered the zl3073x pins with its TXC and
TSPLL DPLLs. The driver does not do that any more, and the recovered
clock pin that it registers under a zl3073x pin has no firmware node,
so no notification caused by the driver matches a watched firmware
node. Remove the filter.

Tested on a GNR-D platform with a dual NAC E825 and a ZL80132B DPLL,
with the rest of the series.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/net/ethernet/intel/ice/ice_dpll.c | 34 -----------------------
 1 file changed, 34 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index 15b5f4a15af915..ccbe34abf74661 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -3098,32 +3098,6 @@ static u64 ice_generate_dpll_clock_id(struct ice_pf *pf, struct ice_dpll *d,
 	return pf->dplls.clock_id;
 }
 
-/**
- * ice_dpll_is_own_dpll_clock_id - check if clock_id belongs to this pf's DPLLs
- * @pf: board private structure
- * @clock_id: clock_id from a DPLL notification
- *
- * Match info->src_clock_id from a DPLL pin notification against any DPLL
- * device this PF has registered. Used to suppress self-notifications
- * generated as a side effect of our own dpll_pin_register() and
- * dpll_pin_unregister() calls on the fwnode-backed SYNCE and TIME_REF pins,
- * whose DPLLs (TXC and TSPLL) use MAC-derived clock_ids on E825.
- *
- * Return: true if clock_id matches one of this PF's registered DPLL devices.
- */
-static bool ice_dpll_is_own_dpll_clock_id(struct ice_pf *pf, u64 clock_id)
-{
-	if (clock_id == pf->dplls.clock_id)
-		return true;
-	if (pf->hw.mac_type != ICE_MAC_GENERIC_3K_E825)
-		return false;
-	if (clock_id == ice_generate_dpll_clock_id(pf, &pf->dplls.txc,
-						   DPLL_TYPE_GENERIC))
-		return true;
-	return clock_id == ice_generate_dpll_clock_id(pf, &pf->dplls.tspll,
-						      DPLL_TYPE_GENERIC);
-}
-
 /**
  * ice_dpll_pin_ntf - notify pin change including any SW pin wrappers
  * @dplls: pointer to dplls struct
@@ -3877,14 +3851,6 @@ static int ice_dpll_pin_notify(struct notifier_block *nb, unsigned long action,
 	if (pin->fwnode != info->fwnode)
 		return NOTIFY_DONE; /* Not this pin */
 
-	/* Ignore notifications that are a side effect of internal pin
-	 * registration/unregistration calls. E825 uses per-device
-	 * MAC-derived clock_ids for the TXC and TSPLL generic DPLLs, so
-	 * info->src_clock_id may not equal pf->dplls.clock_id.
-	 */
-	if (ice_dpll_is_own_dpll_clock_id(pin->pf, info->src_clock_id))
-		return NOTIFY_DONE;
-
 	work = kzalloc_obj(*work);
 	if (!work)
 		return NOTIFY_DONE;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 07/19] dpll: register pins only with a DPLL of their owner
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (5 preceding siblings ...)
  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 ` 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
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Commit c191b319f208 ("dpll: allow registering FW-identified pin with a
different DPLL") allowed a pin with a firmware node to be registered
with a DPLL of another owner. Its only user was ice on E825, which now
links its own pins with the zl3073x pins instead.

Require the same owner for every pin again and document the rule.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst |  8 ++++++--
 drivers/dpll/dpll_core.c          | 12 ++++++------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index 7b083a59f0122d..90c88fcf21b385 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -350,8 +350,12 @@ bound to only one other pin at any given time.
     ``DPLL_A_PIN_STATE``         state of Reference SYNC connection
   ============================== ==========================================
 
-Pin links
-=========
+Pin ownership and links
+=======================
+
+The owner of a dpll device or a pin is identified by the module and the
+clock_id passed to dpll_device_get() or dpll_pin_get(). dpll_pin_register()
+accepts only a dpll device of the same owner as the pin.
 
 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
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 7fd84b0e90e993..57eb4ff2c320e5 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -983,6 +983,9 @@ __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
  * @ops: ops for a dpll pin ops
  * @priv: pointer to private information of owner
  *
+ * The @dpll and the @pin must have the same owner, they must be created with
+ * the same module and clock_id.
+ *
  * Context: Acquires a lock (dpll_lock)
  * Return:
  * * 0 on success
@@ -1015,13 +1018,10 @@ dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
 		goto out_unlock;
 	}
 
-	/*
-	 * For pins identified via firmware (pin->fwnode), allow registration
-	 * even if the pin's (module, clock_id) differs from the target DPLL.
-	 * For non-fwnode pins, require a strict (module, clock_id) match.
+	/* A pin of another owner is connected by a link, see
+	 * dpll_pin_link_add().
 	 */
-	if (!pin->fwnode &&
-	    WARN_ON_ONCE(dpll->module != pin->module ||
+	if (WARN_ON_ONCE(dpll->module != pin->module ||
 			 dpll->clock_id != pin->clock_id)) {
 		ret = -EINVAL;
 		goto out_unlock;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 08/19] dpll: drop the state change exception for pins with a firmware node
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (6 preceding siblings ...)
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 09/19] dpll: drop the source clock id from pin notifications Ivan Vecera
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Commit 521b6d5de08d ("dpll: allow fwnode pins to attempt state change
without capability bit") let user space try to set the state of a pin
with a firmware node also without DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE.
It was needed for the zl3073x output pins that ice registered with its
TXC and TSPLL DPLLs. ice now uses its own pins, which have the
capability, and zl3073x, the only driver that sets a firmware node, gives
it to every pin whose state can be set.

Check the capability for all pins again.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_netlink.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 931ea2027cf68f..fab234553b422a 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -1328,11 +1328,8 @@ dpll_pin_on_pin_state_set(struct dpll_pin *pin, u32 parent_idx,
 	unsigned long i;
 	int ret;
 
-	/* fwnode pins may not set the capability bit upfront; let the ops
-	 * layer return -EOPNOTSUPP if the operation is unsupported.
-	 */
 	if (!(DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE &
-	      pin->prop.capabilities) && !pin->fwnode) {
+	      pin->prop.capabilities)) {
 		NL_SET_ERR_MSG(extack, "state changing is not allowed");
 		return -EOPNOTSUPP;
 	}
@@ -1367,11 +1364,8 @@ dpll_pin_state_set(struct dpll_device *dpll, struct dpll_pin *pin,
 	struct dpll_pin_ref *ref;
 	int ret;
 
-	/* fwnode pins may not set the capability bit upfront; let the ops
-	 * layer return -EOPNOTSUPP if the operation is unsupported.
-	 */
 	if (!(DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE &
-	      pin->prop.capabilities) && !pin->fwnode) {
+	      pin->prop.capabilities)) {
 		NL_SET_ERR_MSG(extack, "state changing is not allowed");
 		return -EOPNOTSUPP;
 	}
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 09/19] dpll: drop the source clock id from pin notifications
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (7 preceding siblings ...)
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 10/19] dpll: drop device events from the in-kernel notifier Ivan Vecera
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Commit 0bf47f722fa9 ("dpll: extend pin notifier with notification source
ID") added src_clock_id to the pin notifier info, so that ice could
ignore the notifications caused by its own registrations of the zl3073x
pins with its TXC and TSPLL DPLLs. ice does not register those pins any
more and no other notifier user reads the field. Remove it.

The notifications are sent as before, only without the field.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_core.c    | 14 ++++++--------
 drivers/dpll/dpll_core.h    |  3 +--
 drivers/dpll/dpll_netlink.c | 10 +++++-----
 drivers/dpll/dpll_netlink.h |  4 ++--
 include/linux/dpll.h        |  1 -
 5 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 57eb4ff2c320e5..b1b76856c4a188 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -74,8 +74,7 @@ void dpll_device_notify(struct dpll_device *dpll, unsigned long action)
 	call_dpll_notifiers(action, &info);
 }
 
-void dpll_pin_notify(struct dpll_pin *pin, u64 src_clock_id,
-		     unsigned long action)
+void dpll_pin_notify(struct dpll_pin *pin, unsigned long action)
 {
 	struct dpll_pin_notifier_info info = {
 		.pin = pin,
@@ -84,7 +83,6 @@ void dpll_pin_notify(struct dpll_pin *pin, u64 src_clock_id,
 		.clock_id = pin->clock_id,
 		.fwnode = pin->fwnode,
 		.prop = &pin->prop,
-		.src_clock_id = src_clock_id,
 	};
 
 	call_dpll_notifiers(action, &info);
@@ -965,7 +963,7 @@ __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
 		goto ref_pin_del;
 	registered = xa_get_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
 	xa_set_mark(&dpll_pin_xa, pin->id, DPLL_REGISTERED);
-	dpll_pin_create_ntf(pin, dpll->clock_id);
+	dpll_pin_create_ntf(pin);
 	if (!registered)
 		dpll_pin_links_ntf(pin);
 
@@ -1054,7 +1052,7 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,
 		      const struct dpll_pin_ops *ops, void *priv, void *cookie)
 {
 	ASSERT_DPLL_PIN_REGISTERED(pin);
-	dpll_pin_delete_ntf(pin, dpll->clock_id);
+	dpll_pin_delete_ntf(pin);
 	dpll_xa_ref_pin_del(&dpll->pin_refs, pin, ops, priv, cookie);
 	dpll_xa_ref_dpll_del(&pin->dpll_refs, dpll, ops, priv, cookie);
 	if (xa_empty(&pin->dpll_refs)) {
@@ -1128,7 +1126,7 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
 			stop = i;
 			goto dpll_unregister;
 		}
-		dpll_pin_create_ntf(pin, parent->clock_id);
+		dpll_pin_create_ntf(pin);
 	}
 	mutex_unlock(&dpll_lock);
 
@@ -1137,7 +1135,7 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
 dpll_unregister:
 	xa_for_each(&parent->dpll_refs, i, ref)
 		if (i < stop) {
-			dpll_pin_delete_ntf(pin, parent->clock_id);
+			dpll_pin_delete_ntf(pin);
 			__dpll_pin_unregister(ref->dpll, pin, ops, priv,
 					      parent);
 		}
@@ -1170,7 +1168,7 @@ void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,
 		reg = dpll_pin_registration_find(ref, ops, priv, parent);
 		if (!reg)
 			continue;
-		dpll_pin_delete_ntf(pin, parent->clock_id);
+		dpll_pin_delete_ntf(pin);
 		__dpll_pin_unregister(ref->dpll, pin, ops, priv, parent);
 	}
 	dpll_xa_ref_pin_del(&pin->parent_refs, parent, ops, priv, pin);
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index f158785bf401b6..eb33ae2d6080ab 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -114,7 +114,6 @@ extern struct xarray dpll_pin_xa;
 extern struct mutex dpll_lock;
 
 void dpll_device_notify(struct dpll_device *dpll, unsigned long action);
-void dpll_pin_notify(struct dpll_pin *pin, u64 src_clock_id,
-		     unsigned long action);
+void dpll_pin_notify(struct dpll_pin *pin, unsigned long action);
 
 #endif
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index fab234553b422a..7b9fadf3b3668a 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -969,15 +969,15 @@ dpll_pin_event_send(enum dpll_cmd event, struct dpll_pin *pin)
 	return ret;
 }
 
-int dpll_pin_create_ntf(struct dpll_pin *pin, u64 src_clock_id)
+int dpll_pin_create_ntf(struct dpll_pin *pin)
 {
-	dpll_pin_notify(pin, src_clock_id, DPLL_PIN_CREATED);
+	dpll_pin_notify(pin, DPLL_PIN_CREATED);
 	return dpll_pin_event_send(DPLL_CMD_PIN_CREATE_NTF, pin);
 }
 
-int dpll_pin_delete_ntf(struct dpll_pin *pin, u64 src_clock_id)
+int dpll_pin_delete_ntf(struct dpll_pin *pin)
 {
-	dpll_pin_notify(pin, src_clock_id, DPLL_PIN_DELETED);
+	dpll_pin_notify(pin, DPLL_PIN_DELETED);
 	return dpll_pin_event_send(DPLL_CMD_PIN_DELETE_NTF, pin);
 }
 
@@ -992,7 +992,7 @@ int dpll_pin_delete_ntf(struct dpll_pin *pin, u64 src_clock_id)
 int __dpll_pin_change_ntf(struct dpll_pin *pin)
 {
 	lockdep_assert_held(&dpll_lock);
-	dpll_pin_notify(pin, pin->clock_id, DPLL_PIN_CHANGED);
+	dpll_pin_notify(pin, DPLL_PIN_CHANGED);
 	return dpll_pin_event_send(DPLL_CMD_PIN_CHANGE_NTF, pin);
 }
 EXPORT_SYMBOL_GPL(__dpll_pin_change_ntf);
diff --git a/drivers/dpll/dpll_netlink.h b/drivers/dpll/dpll_netlink.h
index bc20bcd248a512..ec7cace106c268 100644
--- a/drivers/dpll/dpll_netlink.h
+++ b/drivers/dpll/dpll_netlink.h
@@ -8,9 +8,9 @@ int dpll_device_create_ntf(struct dpll_device *dpll);
 
 int dpll_device_delete_ntf(struct dpll_device *dpll);
 
-int dpll_pin_create_ntf(struct dpll_pin *pin, u64 src_clock_id);
+int dpll_pin_create_ntf(struct dpll_pin *pin);
 
-int dpll_pin_delete_ntf(struct dpll_pin *pin, u64 src_clock_id);
+int dpll_pin_delete_ntf(struct dpll_pin *pin);
 
 #if IS_ENABLED(CONFIG_KUNIT)
 /* For KUnit tests, call with dpll_lock held for a registered pin */
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index e252d3c6b4334a..99118dadb271e0 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -233,7 +233,6 @@ struct dpll_pin_notifier_info {
 	u64 clock_id;
 	const struct fwnode_handle *fwnode;
 	const struct dpll_pin_properties *prop;
-	u64 src_clock_id;
 };
 
 #if IS_ENABLED(CONFIG_DPLL)
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 10/19] dpll: drop device events from the in-kernel notifier
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (8 preceding siblings ...)
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 11/19] dpll: drop the cached module name of a pin Ivan Vecera
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Commit 2be467588d6b ("dpll: Add notifier chain for dpll events") sends
device created, deleted and changed events to the in-kernel notifier
chain, but no driver ever handled them. The only driver that uses the
notifier, ice, waits for pins with a firmware node and ignores
everything else.

Keep the pin events and remove the device ones.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_core.c    | 13 -------------
 drivers/dpll/dpll_core.h    |  1 -
 drivers/dpll/dpll_netlink.c |  3 ---
 include/linux/dpll.h        | 11 -----------
 4 files changed, 28 deletions(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index b1b76856c4a188..2371b81181471d 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -61,19 +61,6 @@ static int call_dpll_notifiers(unsigned long action, void *info)
 	return raw_notifier_call_chain(&dpll_notifier_chain, action, info);
 }
 
-void dpll_device_notify(struct dpll_device *dpll, unsigned long action)
-{
-	struct dpll_device_notifier_info info = {
-		.dpll = dpll,
-		.id = dpll->id,
-		.idx = dpll->device_idx,
-		.clock_id = dpll->clock_id,
-		.type = dpll->type,
-	};
-
-	call_dpll_notifiers(action, &info);
-}
-
 void dpll_pin_notify(struct dpll_pin *pin, unsigned long action)
 {
 	struct dpll_pin_notifier_info info = {
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index eb33ae2d6080ab..1b3c74ef4c1b42 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -113,7 +113,6 @@ extern struct xarray dpll_device_xa;
 extern struct xarray dpll_pin_xa;
 extern struct mutex dpll_lock;
 
-void dpll_device_notify(struct dpll_device *dpll, unsigned long action);
 void dpll_pin_notify(struct dpll_pin *pin, unsigned long action);
 
 #endif
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 7b9fadf3b3668a..78017aae19a6f2 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -891,13 +891,11 @@ dpll_device_event_send(enum dpll_cmd event, struct dpll_device *dpll)
 
 int dpll_device_create_ntf(struct dpll_device *dpll)
 {
-	dpll_device_notify(dpll, DPLL_DEVICE_CREATED);
 	return dpll_device_event_send(DPLL_CMD_DEVICE_CREATE_NTF, dpll);
 }
 
 int dpll_device_delete_ntf(struct dpll_device *dpll)
 {
-	dpll_device_notify(dpll, DPLL_DEVICE_DELETED);
 	return dpll_device_event_send(DPLL_CMD_DEVICE_DELETE_NTF, dpll);
 }
 
@@ -912,7 +910,6 @@ int dpll_device_delete_ntf(struct dpll_device *dpll)
 int __dpll_device_change_ntf(struct dpll_device *dpll)
 {
 	lockdep_assert_held(&dpll_lock);
-	dpll_device_notify(dpll, DPLL_DEVICE_CHANGED);
 	return dpll_device_event_send(DPLL_CMD_DEVICE_CHANGE_NTF, dpll);
 }
 EXPORT_SYMBOL_GPL(__dpll_device_change_ntf);
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 99118dadb271e0..9eccfe41240418 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -211,21 +211,10 @@ typedef struct ref_tracker *dpll_tracker;
 typedef struct {} dpll_tracker;
 #endif
 
-#define DPLL_DEVICE_CREATED	1
-#define DPLL_DEVICE_DELETED	2
-#define DPLL_DEVICE_CHANGED	3
 #define DPLL_PIN_CREATED	4
 #define DPLL_PIN_DELETED	5
 #define DPLL_PIN_CHANGED	6
 
-struct dpll_device_notifier_info {
-	struct dpll_device *dpll;
-	u32 id;
-	u32 idx;
-	u64 clock_id;
-	enum dpll_type type;
-};
-
 struct dpll_pin_notifier_info {
 	struct dpll_pin *pin;
 	u32 id;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 11/19] dpll: drop the cached module name of a pin
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (9 preceding siblings ...)
  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 ` 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
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Commit c191b319f208 ("dpll: allow registering FW-identified pin with a
different DPLL") cached the module name in the pin, because a pin that
another driver registered with its DPLL could stay registered after the
module that created the pin was removed. Every pin is now registered by
the driver that created it, with its DPLLs or under a parent pin, and a
driver unregisters its pins before its module goes away.

Read the module name from the module again.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_core.c    | 1 -
 drivers/dpll/dpll_core.h    | 2 --
 drivers/dpll/dpll_netlink.c | 6 +++---
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 2371b81181471d..7440b174c3de2b 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -653,7 +653,6 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,
 	pin->pin_idx = pin_idx;
 	pin->clock_id = clock_id;
 	pin->module = module;
-	strscpy(pin->module_name, module_name(module));
 	if (WARN_ON(prop->type < DPLL_PIN_TYPE_MUX ||
 		    prop->type > DPLL_PIN_TYPE_MAX)) {
 		ret = -EINVAL;
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index 1b3c74ef4c1b42..3b7e0af7f7ee6f 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -45,7 +45,6 @@ struct dpll_device {
  * @pin_idx:		index of a pin given by dev driver
  * @clock_id:		clock_id of creator
  * @module:		module of creator
- * @module_name:	module name of creator
  * @fwnode:		optional reference to firmware node
  * @links:		links to other pins (struct dpll_pin_link)
  * @dpll_refs:		hold referencees to dplls pin was registered with
@@ -61,7 +60,6 @@ struct dpll_pin {
 	u32 pin_idx;
 	u64 clock_id;
 	struct module *module;
-	char module_name[MODULE_NAME_LEN];
 	struct fwnode_handle *fwnode;
 	struct list_head links;
 	struct xarray dpll_refs;
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 78017aae19a6f2..372de086a7eb3d 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -754,7 +754,7 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
 	if (ret)
 		return ret;
 	if (nla_put_string(msg, DPLL_A_PIN_MODULE_NAME,
-			   pin->module_name))
+			   module_name(pin->module)))
 		return -EMSGSIZE;
 	if (nla_put_64bit(msg, DPLL_A_PIN_CLOCK_ID, sizeof(pin->clock_id),
 			  &pin->clock_id, DPLL_A_PIN_PAD))
@@ -1630,9 +1630,9 @@ dpll_pin_find(u64 clock_id, struct nlattr *mod_name_attr,
 	xa_for_each_marked(&dpll_pin_xa, i, pin, DPLL_REGISTERED) {
 		prop = &pin->prop;
 		cid_match = clock_id ? pin->clock_id == clock_id : true;
-		mod_match = mod_name_attr && pin->module_name[0] ?
+		mod_match = mod_name_attr && module_name(pin->module) ?
 			!nla_strcmp(mod_name_attr,
-				    pin->module_name) : true;
+				    module_name(pin->module)) : true;
 		type_match = type ? prop->type == type : true;
 		board_match = board_label ? (prop->board_label ?
 			!nla_strcmp(board_label, prop->board_label) : false) :
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 12/19] ice: dpll: track the E825 recovered clock routing in the adapter
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (10 preceding siblings ...)
  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 ` 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
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

On E825 the CGU has two muxes, each routing the recovered clock of one
port of the adapter to a SyncE output. All PFs of the adapter reach the
muxes, but the driver tracks the routing only per PF, as the state of
the recovered clock pin of the PF on each mux.

Record in the adapter which recovered clock pin each mux routes. A PF
records its pin when it creates the pin and the mux routes its port, and
when it routes its port. The record is cleared when a PF disables the
mux and when the routed PF removes its pin. A failed configuration may
leave the mux registers changed, for example the R11 selection of SyncE
output 1 is written before R10, so the record is then read back from
them, or set to no port if that read fails too, as the routing is then
unknown. Writers hold cgu_synce_lock, which already serializes the
writes of the mux registers.

Nothing reads the record yet. Creating the pin adds one read of the mux
registers R10 and R11, the same reads as for getting the pin state, and
a failed configuration adds a read of the register that selects the
port.

Tested on a GNR-D platform with a dual NAC E825 and a ZL80132B DPLL: the
record follows the routing of each of the eight ports, and the mux
registers keep the routing over a PF reset, a CORER and a GLOBR, so the
record stays valid. EMPR was not tested.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/net/ethernet/intel/ice/ice_adapter.h |  15 ++
 drivers/net/ethernet/intel/ice/ice_dpll.c    | 154 ++++++++++++++++---
 2 files changed, 150 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.h b/drivers/net/ethernet/intel/ice/ice_adapter.h
index 698a5b9af82ffd..1e4558f2d8c727 100644
--- a/drivers/net/ethernet/intel/ice/ice_adapter.h
+++ b/drivers/net/ethernet/intel/ice/ice_adapter.h
@@ -13,6 +13,7 @@
 
 #include "ice_type.h"
 
+struct dpll_pin;
 struct pci_dev;
 struct ice_pf;
 
@@ -34,6 +35,18 @@ struct ice_port_list {
 	struct srcu_struct srcu;
 };
 
+/**
+ * struct ice_dpll_rclk_mux - recovered clock mux of the E825C CGU
+ * @src: recovered clock pin of the port that the mux routes to its output,
+ *	 NULL when it routes no port of a bound PF or the routing is unknown
+ *
+ * The CGU routes the recovered clock of one port of the adapter to each of
+ * its two SyncE outputs. Writers of @src hold cgu_synce_lock of the adapter.
+ */
+struct ice_dpll_rclk_mux {
+	struct dpll_pin *src;
+};
+
 /**
  * struct ice_adapter - PCI adapter resources shared across PFs
  * @devlink: ice adapter's devlink (whole dev devlink)
@@ -44,6 +57,7 @@ struct ice_port_list {
  *               Index 0 = PHY0, index 1 = PHY1. Used on E825C devices.
  * @cgu_synce_lock: Mutex serializing changes of the CGU registers R10 and R11,
  *                  which all PFs reach. Used on E825C devices.
+ * @rclk_mux: Recovered clock muxes of the CGU. Used on E825C devices.
  * @ctrl_pf: Control PF of the adapter
  * @ports: Ports list
  */
@@ -58,6 +72,7 @@ struct ice_adapter {
 	struct mutex cpi_phy_lock[ICE_E825_MAX_PHYS];
 	/* Serialize changes of the SyncE CGU registers (E825C only) */
 	struct mutex cgu_synce_lock;
+	struct ice_dpll_rclk_mux rclk_mux[ICE_SYNCE_CLK_NUM];
 
 	struct ice_pf *ctrl_pf;
 	struct ice_port_list ports;
diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index ccbe34abf74661..11c5dc0376bb4c 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -556,6 +556,37 @@ ice_dpll_pin_store_state(struct ice_dpll_pin *pin, int parent, bool state)
 					DPLL_PIN_STATE_DISCONNECTED;
 }
 
+/**
+ * ice_dpll_rclk_mux_sel_get - get the input selected by a recovered clock mux
+ * @hw: pointer to the HW struct
+ * @output: SyncE output of the CGU fed by the mux
+ * @sel: on success holds the selected input
+ *
+ * Return:
+ * * 0 - OK
+ * * negative - error
+ */
+static int ice_dpll_rclk_mux_sel_get(struct ice_hw *hw,
+				     enum ice_synce_clk output, u8 *sel)
+{
+	int err;
+	u32 reg;
+
+	if (output == ICE_SYNCE_CLK0) {
+		err = ice_read_cgu_reg(hw, ICE_CGU_R10, &reg);
+		if (err)
+			return err;
+		*sel = FIELD_GET(ICE_CGU_R10_SYNCE_S_REF_CLK, reg);
+	} else {
+		err = ice_read_cgu_reg(hw, ICE_CGU_R11, &reg);
+		if (err)
+			return err;
+		*sel = FIELD_GET(ICE_CGU_R11_SYNCE_S_BYP_CLK, reg);
+	}
+
+	return 0;
+}
+
 /**
  * ice_dpll_rclk_update_e825c - updates the state of rclk pin on e825c device
  * @pf: private board struct
@@ -571,28 +602,19 @@ ice_dpll_pin_store_state(struct ice_dpll_pin *pin, int parent, bool state)
 static int ice_dpll_rclk_update_e825c(struct ice_pf *pf,
 				      struct ice_dpll_pin *pin)
 {
-	u8 rclk_bits;
-	int err;
-	u32 reg;
+	u8 port = pf->ptp.port.port_num + ICE_CGU_BYPASS_MUX_OFFSET_E825C;
+	int err, i;
+	u8 sel;
 
 	if (pf->dplls.rclk.num_parents > ICE_SYNCE_CLK_NUM)
 		return -EINVAL;
 
-	err = ice_read_cgu_reg(&pf->hw, ICE_CGU_R10, &reg);
-	if (err)
-		return err;
-
-	rclk_bits = FIELD_GET(ICE_CGU_R10_SYNCE_S_REF_CLK, reg);
-	ice_dpll_pin_store_state(pin, ICE_SYNCE_CLK0, rclk_bits ==
-		(pf->ptp.port.port_num + ICE_CGU_BYPASS_MUX_OFFSET_E825C));
-
-	err = ice_read_cgu_reg(&pf->hw, ICE_CGU_R11, &reg);
-	if (err)
-		return err;
-
-	rclk_bits = FIELD_GET(ICE_CGU_R11_SYNCE_S_BYP_CLK, reg);
-	ice_dpll_pin_store_state(pin, ICE_SYNCE_CLK1, rclk_bits ==
-		(pf->ptp.port.port_num + ICE_CGU_BYPASS_MUX_OFFSET_E825C));
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++) {
+		err = ice_dpll_rclk_mux_sel_get(&pf->hw, i, &sel);
+		if (err)
+			return err;
+		ice_dpll_pin_store_state(pin, i, sel == port);
+	}
 
 	return 0;
 }
@@ -2020,6 +2042,40 @@ ice_dpll_phase_offset_get(const struct dpll_pin *pin, void *pin_priv,
 	return 0;
 }
 
+/**
+ * ice_dpll_rclk_src_sync - record the port a recovered clock mux routes
+ * @pf: board private structure
+ * @output: SyncE output of the CGU fed by the mux
+ *
+ * Read the input selected by the mux. Record the recovered clock pin of the
+ * PF as the source of the mux when the mux routes the port of the PF, and no
+ * pin when it routes no port. When it routes another port, keep the record
+ * unless it names the PF.
+ *
+ * Context: Called under adapter->cgu_synce_lock
+ * Return:
+ * * 0 - OK
+ * * negative - error
+ */
+static int ice_dpll_rclk_src_sync(struct ice_pf *pf, enum ice_synce_clk output)
+{
+	u8 port = pf->ptp.port.port_num + ICE_CGU_BYPASS_MUX_OFFSET_E825C;
+	struct ice_dpll_rclk_mux *mux = &pf->adapter->rclk_mux[output];
+	struct dpll_pin *pin = pf->dplls.rclk.pin;
+	int err;
+	u8 sel;
+
+	err = ice_dpll_rclk_mux_sel_get(&pf->hw, output, &sel);
+	if (err)
+		return err;
+	if (sel == port)
+		WRITE_ONCE(mux->src, pin);
+	else if (sel < ICE_CGU_BYPASS_MUX_OFFSET_E825C || mux->src == pin)
+		WRITE_ONCE(mux->src, NULL);
+
+	return 0;
+}
+
 /**
  * ice_dpll_synce_update_e825c - setting PHY recovered clock pins on e825c
  * @hw: Pointer to the HW struct
@@ -2028,6 +2084,7 @@ ice_dpll_phase_offset_get(const struct dpll_pin *pin, void *pin_priv,
  * @output: output pin, we have two in E825C
  *
  * DPLL subsystem callback. Set proper signals to recover clock from port.
+ * Record in the adapter which port the mux routes.
  *
  * Context: Called under pf->dplls.lock, acquires adapter->cgu_synce_lock
  * Return:
@@ -2043,8 +2100,17 @@ static int ice_dpll_synce_update_e825c(struct ice_hw *hw, bool ena,
 	mutex_lock(&pf->adapter->cgu_synce_lock);
 	/* configure the mux to deliver proper signal to DPLL from the MUX */
 	err = ice_tspll_cfg_bypass_mux_e825c(hw, ena, port_num, output);
-	if (!err)
+	if (!err) {
+		/* A disabled mux routes no port, whichever it routed before */
+		WRITE_ONCE(pf->adapter->rclk_mux[output].src,
+			   ena ? pf->dplls.rclk.pin : NULL);
 		err = ice_tspll_cfg_synce_ethdiv_e825c(hw, output);
+	} else if (ice_dpll_rclk_src_sync(pf, output)) {
+		/* The routing is unknown after a partial write that cannot
+		 * be read back, record no port.
+		 */
+		WRITE_ONCE(pf->adapter->rclk_mux[output].src, NULL);
+	}
 	mutex_unlock(&pf->adapter->cgu_synce_lock);
 	if (err)
 		return err;
@@ -2055,6 +2121,48 @@ static int ice_dpll_synce_update_e825c(struct ice_hw *hw, bool ena,
 	return 0;
 }
 
+/**
+ * ice_dpll_rclk_src_init - record the muxes that route the port of the PF
+ * @pf: board private structure
+ *
+ * Record the recovered clock pin of the PF as the source of the recovered
+ * clock muxes that route the port of the PF, see ice_dpll_rclk_src_sync().
+ *
+ * Context: Acquires adapter->cgu_synce_lock
+ * Return:
+ * * 0 - success
+ * * negative - error
+ */
+static int ice_dpll_rclk_src_init(struct ice_pf *pf)
+{
+	int err = 0, i;
+
+	mutex_lock(&pf->adapter->cgu_synce_lock);
+	for (i = 0; !err && i < ICE_SYNCE_CLK_NUM; i++)
+		err = ice_dpll_rclk_src_sync(pf, i);
+	mutex_unlock(&pf->adapter->cgu_synce_lock);
+
+	return err;
+}
+
+/**
+ * ice_dpll_rclk_src_fini - drop the PF as the source of recovered clock muxes
+ * @pf: board private structure
+ *
+ * Context: Acquires adapter->cgu_synce_lock
+ */
+static void ice_dpll_rclk_src_fini(struct ice_pf *pf)
+{
+	struct ice_adapter *adapter = pf->adapter;
+	int i;
+
+	mutex_lock(&adapter->cgu_synce_lock);
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++)
+		if (adapter->rclk_mux[i].src == pf->dplls.rclk.pin)
+			WRITE_ONCE(adapter->rclk_mux[i].src, NULL);
+	mutex_unlock(&adapter->cgu_synce_lock);
+}
+
 /**
  * ice_dpll_output_esync_set - callback for setting embedded sync
  * @pin: pointer to a pin
@@ -3745,6 +3853,8 @@ static void ice_dpll_deinit_rclk_pin(struct ice_pf *pf)
 		dpll_pin_on_pin_unregister(parent->pin, rclk->pin,
 					   &ice_dpll_rclk_ops, rclk);
 	}
+	if (pf->hw.mac_type == ICE_MAC_GENERIC_3K_E825)
+		ice_dpll_rclk_src_fini(pf);
 	if (WARN_ON_ONCE(!vsi || !vsi->netdev))
 		return;
 	dpll_netdev_pin_clear(vsi->netdev);
@@ -4328,6 +4438,12 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
 	if (ret)
 		goto unregister_pins;
 
+	ret = ice_dpll_rclk_src_init(pf);
+	if (ret) {
+		ice_dpll_deinit_rclk_pin(pf);
+		goto unregister_pins;
+	}
+
 	ret = ice_dpll_init_txclk_pins(pf);
 	if (ret) {
 		ice_dpll_deinit_rclk_pin(pf);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 13/19] ice: dpll: register the E825 recovered clock muxes as DPLL devices
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (11 preceding siblings ...)
  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 ` 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
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Each of the two recovered clock muxes of the E825 CGU feeds a SyncE
output, which the board wires to an input of the platform DPLL. Describe
each mux with a DPLL device of type generic with one output pin, RCLK0
or RCLK1. The output pin is linked with the pin at the other end of the
wire through the firmware node rclk0 or rclk1, the same nodes the
recovered clock pins use to find their parent pins.

The devices and the output pins belong to the adapter. Their clock ID is
the adapter index, which all PFs of the adapter share, both NACs of E825
included. The device index is the SyncE output. The first PF registers
the devices and the pins and the last one unregisters them, under the
instance lock of the adapter devlink. The callers already hold the
instance lock of the PF devlink, which is nested in the adapter devlink,
so the two locks are taken in the order the devlink rules require.

A mux reports a locked status, and its output pin the connected state,
while the mux routes the port of a bound PF, as recorded in the adapter.
The callbacks of the devices and of the output pins do not access the
hardware. A change of the routing, also by a failed write, notifies the
device, its output pin and the recovered clock pins whose state on the
mux changed, the pin of the port routed before included, which is read
together with the write under cgu_synce_lock. When a PF finds at probe
that the registers differ from the record, it notifies only the device
and its output pin, because the pin routed before belongs to another PF,
which can go away meanwhile, and the state of a recovered clock pin is
read from the hardware. The recovered clock pins do not use the muxes
yet.

Tested on a GNR-D platform with a dual NAC E825 and a ZL80132B DPLL: the
mux devices and RCLK0/1 stay while any PF of the adapter is bound and go
with the last one, and RCLK0 and RCLK1 report their links to the zl3073x
inputs REF1P and REF1N.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/net/ethernet/intel/ice/ice_adapter.c |   3 +-
 drivers/net/ethernet/intel/ice/ice_adapter.h |  22 +-
 drivers/net/ethernet/intel/ice/ice_dpll.c    | 323 ++++++++++++++++++-
 3 files changed, 335 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.c b/drivers/net/ethernet/intel/ice/ice_adapter.c
index 8cb61f145d27a2..929c965724dba1 100644
--- a/drivers/net/ethernet/intel/ice/ice_adapter.c
+++ b/drivers/net/ethernet/intel/ice/ice_adapter.c
@@ -43,6 +43,7 @@ static int ice_adapter_init(void *priv, void *init_param)
 
 	devlink = shd_priv_to_devlink(adapter);
 	adapter->devlink = devlink;
+	adapter->index = *(u64 *)init_param;
 
 	spin_lock_init(&adapter->ptp_gltsyn_time_lock);
 	spin_lock_init(&adapter->txq_ctx_lock);
@@ -96,7 +97,7 @@ struct ice_adapter *ice_adapter_get(struct pci_dev *pdev)
 	index = ice_adapter_index(pdev);
 	snprintf(devlink_id, sizeof(devlink_id), "ice:%llx", index);
 	devlink = devlink_shd_get(devlink_id, &ice_adapter_devlink_ops,
-				  sizeof(*adapter), NULL, pdev->dev.driver);
+				  sizeof(*adapter), &index, pdev->dev.driver);
 	if (IS_ERR(devlink))
 		return ERR_CAST(devlink);
 
diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.h b/drivers/net/ethernet/intel/ice/ice_adapter.h
index 1e4558f2d8c727..e321bdd70d36a0 100644
--- a/drivers/net/ethernet/intel/ice/ice_adapter.h
+++ b/drivers/net/ethernet/intel/ice/ice_adapter.h
@@ -5,6 +5,7 @@
 #define _ICE_ADAPTER_H_
 
 #include <linux/types.h>
+#include <linux/dpll.h>
 #include <linux/mutex.h>
 #include <linux/srcu.h>
 #include <linux/spinlock_types.h>
@@ -13,7 +14,6 @@
 
 #include "ice_type.h"
 
-struct dpll_pin;
 struct pci_dev;
 struct ice_pf;
 
@@ -37,19 +37,33 @@ struct ice_port_list {
 
 /**
  * struct ice_dpll_rclk_mux - recovered clock mux of the E825C CGU
+ * @dpll: DPLL device of the mux
+ * @tracker: reference tracker of @dpll
+ * @out: output pin of the mux
+ * @out_tracker: reference tracker of @out
  * @src: recovered clock pin of the port that the mux routes to its output,
  *	 NULL when it routes no port of a bound PF or the routing is unknown
+ * @idx: SyncE output of the CGU fed by the mux
  *
  * The CGU routes the recovered clock of one port of the adapter to each of
- * its two SyncE outputs. Writers of @src hold cgu_synce_lock of the adapter.
+ * its two SyncE outputs. The PFs of the adapter share the muxes: the first
+ * PF registers @dpll and @out, the last one unregisters them, under the
+ * instance lock of the adapter devlink. Writers of @src hold cgu_synce_lock
+ * of the adapter.
  */
 struct ice_dpll_rclk_mux {
+	struct dpll_device *dpll;
+	dpll_tracker tracker;
+	struct dpll_pin *out;
+	dpll_tracker out_tracker;
 	struct dpll_pin *src;
+	enum ice_synce_clk idx;
 };
 
 /**
  * struct ice_adapter - PCI adapter resources shared across PFs
  * @devlink: ice adapter's devlink (whole dev devlink)
+ * @index: Index of the adapter, also the clock ID of its recovered clock muxes
  * @ptp_gltsyn_time_lock: Spinlock protecting access to the GLTSYN_TIME
  *                        register of the PTP clock.
  * @txq_ctx_lock: Spinlock protecting access to the GLCOMM_QTX_CNTX_CTL register
@@ -58,11 +72,14 @@ struct ice_dpll_rclk_mux {
  * @cgu_synce_lock: Mutex serializing changes of the CGU registers R10 and R11,
  *                  which all PFs reach. Used on E825C devices.
  * @rclk_mux: Recovered clock muxes of the CGU. Used on E825C devices.
+ * @rclk_mux_users: Number of PFs that use @rclk_mux, protected by the
+ *                  instance lock of @devlink
  * @ctrl_pf: Control PF of the adapter
  * @ports: Ports list
  */
 struct ice_adapter {
 	struct devlink *devlink;
+	u64 index;
 
 	/* For access to the GLTSYN_TIME register */
 	spinlock_t ptp_gltsyn_time_lock;
@@ -73,6 +90,7 @@ struct ice_adapter {
 	/* Serialize changes of the SyncE CGU registers (E825C only) */
 	struct mutex cgu_synce_lock;
 	struct ice_dpll_rclk_mux rclk_mux[ICE_SYNCE_CLK_NUM];
+	unsigned int rclk_mux_users;
 
 	struct ice_pf *ctrl_pf;
 	struct ice_port_list ports;
diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index 11c5dc0376bb4c..a608c5ea4d5cc3 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -89,6 +89,13 @@ static const char * const ice_dpll_ext_synce_pin = "EXT_SYNCE";
 static const char * const ice_dpll_time_ref_pin = "TIME_REF";
 static const char * const ice_dpll_fwnode_ext_synce = "clk_ref_synce";
 static const char * const ice_dpll_fwnode_time_ref = "time_ref";
+static const char * const ice_dpll_rclk_out_pins[ICE_SYNCE_CLK_NUM] = {
+	"RCLK0", "RCLK1"
+};
+
+static const char * const ice_dpll_fwnode_rclk[ICE_SYNCE_CLK_NUM] = {
+	"rclk0", "rclk1"
+};
 
 static const struct dpll_pin_frequency ice_esync_range[] = {
 	DPLL_PIN_FREQUENCY_RANGE(0, DPLL_PIN_FREQUENCY_1_HZ),
@@ -2082,6 +2089,7 @@ static int ice_dpll_rclk_src_sync(struct ice_pf *pf, enum ice_synce_clk output)
  * @ena: true if enable, false in disable
  * @port_num: port number
  * @output: output pin, we have two in E825C
+ * @prev: holds the recovered clock pin the mux routed before
  *
  * DPLL subsystem callback. Set proper signals to recover clock from port.
  * Record in the adapter which port the mux routes.
@@ -2092,12 +2100,14 @@ static int ice_dpll_rclk_src_sync(struct ice_pf *pf, enum ice_synce_clk output)
  * * negative - error
  */
 static int ice_dpll_synce_update_e825c(struct ice_hw *hw, bool ena,
-				       u32 port_num, enum ice_synce_clk output)
+				       u32 port_num, enum ice_synce_clk output,
+				       struct dpll_pin **prev)
 {
 	struct ice_pf *pf = hw->back;
 	int err;
 
 	mutex_lock(&pf->adapter->cgu_synce_lock);
+	*prev = pf->adapter->rclk_mux[output].src;
 	/* configure the mux to deliver proper signal to DPLL from the MUX */
 	err = ice_tspll_cfg_bypass_mux_e825c(hw, ena, port_num, output);
 	if (!err) {
@@ -2121,6 +2131,45 @@ static int ice_dpll_synce_update_e825c(struct ice_hw *hw, bool ena,
 	return 0;
 }
 
+/**
+ * ice_dpll_rclk_mux_ntf - notify a change of the port routed by a mux
+ * @mux: recovered clock mux
+ *
+ * The lock status and the output of a mux follow the port it routes.
+ */
+static void ice_dpll_rclk_mux_ntf(struct ice_dpll_rclk_mux *mux)
+{
+	dpll_device_change_ntf(mux->dpll);
+	dpll_pin_change_ntf(mux->out);
+}
+
+/**
+ * __ice_dpll_rclk_mux_ntf - notify a change of the port routed by a mux
+ * @mux: recovered clock mux
+ * @prev: recovered clock pin the mux routed before
+ * @skip: recovered clock pin the caller notifies, or NULL
+ *
+ * When the mux routes another port than before, notify its device and its
+ * output, and the recovered clock pins whose state on the mux changed.
+ *
+ * Context: Called under dpll_lock
+ */
+static void __ice_dpll_rclk_mux_ntf(struct ice_dpll_rclk_mux *mux,
+				    struct dpll_pin *prev,
+				    struct dpll_pin *skip)
+{
+	struct dpll_pin *src = READ_ONCE(mux->src);
+
+	if (src == prev)
+		return;
+	if (prev && prev != skip)
+		__dpll_pin_change_ntf(prev);
+	if (src && src != skip)
+		__dpll_pin_change_ntf(src);
+	__dpll_device_change_ntf(mux->dpll);
+	__dpll_pin_change_ntf(mux->out);
+}
+
 /**
  * ice_dpll_rclk_src_init - record the muxes that route the port of the PF
  * @pf: board private structure
@@ -2135,13 +2184,27 @@ static int ice_dpll_synce_update_e825c(struct ice_hw *hw, bool ena,
  */
 static int ice_dpll_rclk_src_init(struct ice_pf *pf)
 {
+	struct ice_dpll_rclk_mux *muxes = pf->adapter->rclk_mux;
+	bool changed[ICE_SYNCE_CLK_NUM] = {};
+	struct dpll_pin *prev;
 	int err = 0, i;
 
 	mutex_lock(&pf->adapter->cgu_synce_lock);
-	for (i = 0; !err && i < ICE_SYNCE_CLK_NUM; i++)
+	for (i = 0; !err && i < ICE_SYNCE_CLK_NUM; i++) {
+		prev = muxes[i].src;
 		err = ice_dpll_rclk_src_sync(pf, i);
+		changed[i] = muxes[i].src != prev;
+	}
 	mutex_unlock(&pf->adapter->cgu_synce_lock);
 
+	/* A pin routed before belongs to another PF, which can go away once
+	 * cgu_synce_lock is dropped, so notify only the muxes. The state of a
+	 * recovered clock pin is read from the hardware.
+	 */
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++)
+		if (changed[i])
+			ice_dpll_rclk_mux_ntf(&muxes[i]);
+
 	return err;
 }
 
@@ -2154,13 +2217,21 @@ static int ice_dpll_rclk_src_init(struct ice_pf *pf)
 static void ice_dpll_rclk_src_fini(struct ice_pf *pf)
 {
 	struct ice_adapter *adapter = pf->adapter;
+	struct dpll_pin *pin = pf->dplls.rclk.pin;
+	bool routed[ICE_SYNCE_CLK_NUM] = {};
 	int i;
 
 	mutex_lock(&adapter->cgu_synce_lock);
-	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++)
-		if (adapter->rclk_mux[i].src == pf->dplls.rclk.pin)
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++) {
+		routed[i] = adapter->rclk_mux[i].src == pin;
+		if (routed[i])
 			WRITE_ONCE(adapter->rclk_mux[i].src, NULL);
+	}
 	mutex_unlock(&adapter->cgu_synce_lock);
+
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++)
+		if (routed[i])
+			ice_dpll_rclk_mux_ntf(&adapter->rclk_mux[i]);
 }
 
 /**
@@ -2630,7 +2701,9 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 			       struct netlink_ext_ack *extack)
 {
 	bool enable = state == DPLL_PIN_STATE_CONNECTED;
+	struct ice_dpll_rclk_mux *mux = NULL;
 	struct ice_dpll_pin *p = pin_priv;
+	struct dpll_pin *prev = NULL;
 	struct ice_pf *pf = p->pf;
 	struct ice_hw *hw;
 	int ret = -EINVAL;
@@ -2658,11 +2731,15 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 		goto unlock;
 	}
 
-	ret = hw->mac_type == ICE_MAC_GENERIC_3K_E825 ?
-		ice_dpll_synce_update_e825c(hw, enable,
-					    pf->ptp.port.port_num,
-					    (enum ice_synce_clk)hw_idx) :
-		ice_aq_set_phy_rec_clk_out(hw, hw_idx, enable, &p->freq);
+	if (hw->mac_type == ICE_MAC_GENERIC_3K_E825) {
+		mux = &pf->adapter->rclk_mux[hw_idx];
+		ret = ice_dpll_synce_update_e825c(hw, enable,
+						  pf->ptp.port.port_num,
+						  (enum ice_synce_clk)hw_idx,
+						  &prev);
+	} else {
+		ret = ice_aq_set_phy_rec_clk_out(hw, hw_idx, enable, &p->freq);
+	}
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
 				   "err:%d %s failed to set pin state:%u for pin:%u on parent:%u",
@@ -2672,6 +2749,9 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 				   ice_dpll_pin_get_parent_num(p, parent_pin));
 unlock:
 	mutex_unlock(&pf->dplls.lock);
+	/* The core notifies this pin on success */
+	if (mux)
+		__ice_dpll_rclk_mux_ntf(mux, prev, ret ? NULL : p->pin);
 
 	return ret;
 }
@@ -2728,6 +2808,82 @@ ice_dpll_rclk_state_on_pin_get(const struct dpll_pin *pin, void *pin_priv,
 	return ret;
 }
 
+/**
+ * ice_dpll_rclk_mux_lock_status_get - get the status of a recovered clock mux
+ * @dpll: registered dpll pointer
+ * @dpll_priv: private data pointer passed on dpll registration
+ * @status: on success holds the lock status of the mux
+ * @status_error: status error value
+ * @extack: error reporting
+ *
+ * Dpll subsystem callback. A mux has no loop to lock, report it locked while
+ * it routes the recovered clock of a port to its output.
+ *
+ * Return: 0 - success
+ */
+static int
+ice_dpll_rclk_mux_lock_status_get(const struct dpll_device *dpll,
+				  void *dpll_priv,
+				  enum dpll_lock_status *status,
+				  enum dpll_lock_status_error *status_error,
+				  struct netlink_ext_ack *extack)
+{
+	struct ice_dpll_rclk_mux *mux = dpll_priv;
+
+	*status = READ_ONCE(mux->src) ? DPLL_LOCK_STATUS_LOCKED :
+					DPLL_LOCK_STATUS_UNLOCKED;
+
+	return 0;
+}
+
+/**
+ * ice_dpll_rclk_mux_mode_get - get the mode of a recovered clock mux
+ * @dpll: registered dpll pointer
+ * @dpll_priv: private data pointer passed on dpll registration
+ * @mode: on success holds the mode of the mux
+ * @extack: error reporting
+ *
+ * Dpll subsystem callback. The port routed by a mux is selected manually.
+ *
+ * Return: 0 - success
+ */
+static int ice_dpll_rclk_mux_mode_get(const struct dpll_device *dpll,
+				      void *dpll_priv, enum dpll_mode *mode,
+				      struct netlink_ext_ack *extack)
+{
+	*mode = DPLL_MODE_MANUAL;
+
+	return 0;
+}
+
+/**
+ * ice_dpll_rclk_out_state_get - get a state of a recovered clock mux output
+ * @pin: pointer to a pin
+ * @pin_priv: private data pointer passed on pin registration
+ * @dpll: registered dpll pointer
+ * @dpll_priv: private data pointer passed on dpll registration
+ * @state: on success holds the state of the output
+ * @extack: error reporting
+ *
+ * Dpll subsystem callback. The output carries a clock while the mux routes
+ * the recovered clock of a port.
+ *
+ * Return: 0 - success
+ */
+static int
+ice_dpll_rclk_out_state_get(const struct dpll_pin *pin, void *pin_priv,
+			    const struct dpll_device *dpll, void *dpll_priv,
+			    enum dpll_pin_state *state,
+			    struct netlink_ext_ack *extack)
+{
+	struct ice_dpll_rclk_mux *mux = dpll_priv;
+
+	*state = READ_ONCE(mux->src) ? DPLL_PIN_STATE_CONNECTED :
+				       DPLL_PIN_STATE_DISCONNECTED;
+
+	return 0;
+}
+
 /**
  * ice_dpll_txclk_work - apply a pending TX reference clock change
  * @work: work_struct embedded in struct ice_dplls
@@ -2922,6 +3078,11 @@ static const struct dpll_pin_ops ice_dpll_rclk_ops = {
 	.direction_get = ice_dpll_input_direction,
 };
 
+static const struct dpll_pin_ops ice_dpll_rclk_out_ops = {
+	.state_on_dpll_get = ice_dpll_rclk_out_state_get,
+	.direction_get = ice_dpll_output_direction,
+};
+
 static const struct dpll_pin_ops ice_dpll_txclk_ops = {
 	.state_on_dpll_set = ice_dpll_txclk_state_on_dpll_set,
 	.state_on_dpll_get = ice_dpll_txclk_state_on_dpll_get,
@@ -3156,6 +3317,11 @@ static const struct dpll_device_ops ice_dpll_pom_ops = {
 	.phase_offset_monitor_get = ice_dpll_phase_offset_monitor_get,
 };
 
+static const struct dpll_device_ops ice_dpll_rclk_mux_ops = {
+	.lock_status_get = ice_dpll_rclk_mux_lock_status_get,
+	.mode_get = ice_dpll_rclk_mux_mode_get,
+};
+
 /**
  * ice_generate_clock_id - generates unique clock_id for registering dpll.
  * @pf: board private structure
@@ -4131,6 +4297,40 @@ static void ice_dpll_deinit_tspll_pins(struct ice_pf *pf)
 	time_ref->pin = NULL;
 }
 
+/**
+ * ice_dpll_deinit_rclk_mux - deinitialize a recovered clock mux
+ * @mux: recovered clock mux
+ *
+ * Unregister the output pin and the DPLL device of the mux and release them.
+ */
+static void ice_dpll_deinit_rclk_mux(struct ice_dpll_rclk_mux *mux)
+{
+	dpll_pin_unregister(mux->dpll, mux->out, &ice_dpll_rclk_out_ops, mux);
+	dpll_pin_put(mux->out, &mux->out_tracker);
+	dpll_device_unregister(mux->dpll, &ice_dpll_rclk_mux_ops, mux);
+	dpll_device_put(mux->dpll, &mux->tracker);
+}
+
+/**
+ * ice_dpll_rclk_muxes_put - release the recovered clock muxes for a PF
+ * @pf: board private structure
+ *
+ * The last PF of the adapter deinitializes the recovered clock muxes.
+ *
+ * Context: Acquires the instance lock of the adapter devlink
+ */
+static void ice_dpll_rclk_muxes_put(struct ice_pf *pf)
+{
+	struct ice_adapter *adapter = pf->adapter;
+	int i;
+
+	devl_lock(adapter->devlink);
+	if (!--adapter->rclk_mux_users)
+		for (i = 0; i < ICE_SYNCE_CLK_NUM; i++)
+			ice_dpll_deinit_rclk_mux(&adapter->rclk_mux[i]);
+	devl_unlock(adapter->devlink);
+}
+
 /**
  * ice_dpll_deinit_pins - deinitialize direct pins
  * @pf: board private structure
@@ -4156,6 +4356,7 @@ static void ice_dpll_deinit_pins(struct ice_pf *pf, bool cgu)
 			ice_dpll_deinit_tspll_pins(pf);
 		ice_dpll_deinit_txclk_pins(pf);
 		ice_dpll_deinit_fwnode_pins(pf, pf->dplls.inputs, 0);
+		ice_dpll_rclk_muxes_put(pf);
 	}
 	if (cgu) {
 		ice_dpll_unregister_pins(dp->dpll, inputs, &ice_dpll_input_ops,
@@ -4226,6 +4427,101 @@ static int ice_dpll_pin_link_add(struct ice_pf *pf, struct dpll_pin *pin,
 	return ret;
 }
 
+/**
+ * ice_dpll_init_rclk_mux - initialize a recovered clock mux
+ * @pf: board private structure
+ * @i: SyncE output of the CGU fed by the mux
+ *
+ * Register the mux as a DPLL device with an output pin, and link the output
+ * pin with the pin wired to it. The clock ID of both is the adapter index.
+ *
+ * Return:
+ * * 0 - success
+ * * negative - initialization failure reason
+ */
+static int ice_dpll_init_rclk_mux(struct ice_pf *pf, enum ice_synce_clk i)
+{
+	struct ice_dpll_rclk_mux *mux = &pf->adapter->rclk_mux[i];
+	struct dpll_pin_properties prop = {
+		.board_label = ice_dpll_rclk_out_pins[i],
+		.type = DPLL_PIN_TYPE_EXT,
+	};
+	u64 clock_id = pf->adapter->index;
+	int ret;
+
+	mux->idx = i;
+	mux->dpll = dpll_device_get(clock_id, i, THIS_MODULE, &mux->tracker);
+	if (IS_ERR(mux->dpll))
+		return PTR_ERR(mux->dpll);
+	ret = dpll_device_register(mux->dpll, DPLL_TYPE_GENERIC,
+				   &ice_dpll_rclk_mux_ops, mux);
+	if (ret)
+		goto put_dpll;
+	mux->out = dpll_pin_get(clock_id, i, THIS_MODULE, &prop,
+				&mux->out_tracker);
+	if (IS_ERR(mux->out)) {
+		ret = PTR_ERR(mux->out);
+		goto unregister_dpll;
+	}
+	ret = ice_dpll_pin_link_add(pf, mux->out, ice_dpll_fwnode_rclk[i]);
+	if (ret)
+		goto put_pin;
+	ret = dpll_pin_register(mux->dpll, mux->out, &ice_dpll_rclk_out_ops,
+				mux);
+	if (ret)
+		goto put_pin;
+
+	return 0;
+
+put_pin:
+	dpll_pin_put(mux->out, &mux->out_tracker);
+unregister_dpll:
+	dpll_device_unregister(mux->dpll, &ice_dpll_rclk_mux_ops, mux);
+put_dpll:
+	dpll_device_put(mux->dpll, &mux->tracker);
+
+	return ret;
+}
+
+/**
+ * ice_dpll_rclk_muxes_get - get the recovered clock muxes for a PF
+ * @pf: board private structure
+ *
+ * The PFs of the adapter share the recovered clock muxes, the first PF
+ * initializes them.
+ *
+ * Context: Acquires the instance lock of the adapter devlink
+ * Return:
+ * * 0 - success
+ * * negative - initialization failure reason
+ */
+static int ice_dpll_rclk_muxes_get(struct ice_pf *pf)
+{
+	struct ice_adapter *adapter = pf->adapter;
+	int ret, i;
+
+	devl_lock(adapter->devlink);
+	if (adapter->rclk_mux_users)
+		goto out;
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++) {
+		ret = ice_dpll_init_rclk_mux(pf, i);
+		if (ret)
+			goto deinit_muxes;
+	}
+out:
+	adapter->rclk_mux_users++;
+	devl_unlock(adapter->devlink);
+
+	return 0;
+
+deinit_muxes:
+	while (i--)
+		ice_dpll_deinit_rclk_mux(&adapter->rclk_mux[i]);
+	devl_unlock(adapter->devlink);
+
+	return ret;
+}
+
 static int
 ice_dpll_init_fwnode_pin(struct ice_dpll_pin *pin, const char *name)
 {
@@ -4428,10 +4724,14 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
 {
 	int ret;
 
-	ret = ice_dpll_init_fwnode_pins(pf, pf->dplls.inputs, 0);
+	ret = ice_dpll_rclk_muxes_get(pf);
 	if (ret)
 		return ret;
 
+	ret = ice_dpll_init_fwnode_pins(pf, pf->dplls.inputs, 0);
+	if (ret)
+		goto put_muxes;
+
 	ret = ice_dpll_init_rclk_pin(pf, DPLL_PIN_IDX_UNSPEC,
 				     &ice_dpll_rclk_ops);
 
@@ -4467,6 +4767,9 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
 		complete_all(&pf->dplls.dpll_init);
 		ice_dpll_deinit_fwnode_pins(pf, pf->dplls.inputs, 0);
 	}
+put_muxes:
+	if (ret)
+		ice_dpll_rclk_muxes_put(pf);
 
 	return ret;
 }
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 14/19] ice: dpll: route the E825 recovered clock through the mux devices
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (12 preceding siblings ...)
  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 ` 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
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

On E825 the driver registers the recovered clock pin of each PF as a
child of the zl3073x pins rclk0 and rclk1 with
dpll_pin_on_pin_register(). It finds them by firmware node, holds
references to them and uses the DPLL notifier to wait for them and to
follow their removal.

Register the recovered clock pin as an input of both mux devices
instead, with the clock ID of the muxes. The state of the pin on a mux
selects the port for the output of the mux. Connecting a port
disconnects the port the mux routed before, which gets a change
notification. Setting and reading the state accesses the same CGU
registers as before.

Drop the notifier work, the firmware node pins and the dpll_init
completion, which served only this path, and the E825 case of
ice_get_cgu_rclk_pin_info().

What user space sees on E825 changes:
- the recovered clock pin lists the two mux devices as parent devices
  instead of the zl3073x pins as parent pins, so a port is routed by
  setting the state of its pin on a mux device
- the clock ID of the recovered clock pin is the adapter index instead
  of the DSN; neither tells the PFs apart, as all PFs of a complex have
  the same DSN
- the zl3073x pins have no child pins; the firmware still describes
  them as MUX pins, which they no longer need to be
- the recovered clock pin exists also when the zl3073x driver is not
  loaded

Tested on a GNR-D platform with a dual NAC E825 and a ZL80132B DPLL:
routing each port to RCLK0 or RCLK1 updates the pin states, the lock
status of the mux and the output pin, and notifies the port routed
before. With a 25 Gb/s port routed, the zl3073x input measures
78.125 MHz and qualifies; a 1 Gb/s port gives 62.5 MHz, as set by the
divider. A PF bound again finds its port still routed.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/net/ethernet/intel/ice/ice_dpll.c   | 522 +++++++-------------
 drivers/net/ethernet/intel/ice/ice_dpll.h   |   9 -
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c |   8 -
 3 files changed, 190 insertions(+), 349 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index a608c5ea4d5cc3..42579cc3fb9e03 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -613,9 +613,6 @@ static int ice_dpll_rclk_update_e825c(struct ice_pf *pf,
 	int err, i;
 	u8 sel;
 
-	if (pf->dplls.rclk.num_parents > ICE_SYNCE_CLK_NUM)
-		return -EINVAL;
-
 	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++) {
 		err = ice_dpll_rclk_mux_sel_get(&pf->hw, i, &sel);
 		if (err)
@@ -2701,9 +2698,7 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 			       struct netlink_ext_ack *extack)
 {
 	bool enable = state == DPLL_PIN_STATE_CONNECTED;
-	struct ice_dpll_rclk_mux *mux = NULL;
 	struct ice_dpll_pin *p = pin_priv;
-	struct dpll_pin *prev = NULL;
 	struct ice_pf *pf = p->pf;
 	struct ice_hw *hw;
 	int ret = -EINVAL;
@@ -2731,15 +2726,7 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 		goto unlock;
 	}
 
-	if (hw->mac_type == ICE_MAC_GENERIC_3K_E825) {
-		mux = &pf->adapter->rclk_mux[hw_idx];
-		ret = ice_dpll_synce_update_e825c(hw, enable,
-						  pf->ptp.port.port_num,
-						  (enum ice_synce_clk)hw_idx,
-						  &prev);
-	} else {
-		ret = ice_aq_set_phy_rec_clk_out(hw, hw_idx, enable, &p->freq);
-	}
+	ret = ice_aq_set_phy_rec_clk_out(hw, hw_idx, enable, &p->freq);
 	if (ret)
 		NL_SET_ERR_MSG_FMT(extack,
 				   "err:%d %s failed to set pin state:%u for pin:%u on parent:%u",
@@ -2749,9 +2736,6 @@ ice_dpll_rclk_state_on_pin_set(const struct dpll_pin *pin, void *pin_priv,
 				   ice_dpll_pin_get_parent_num(p, parent_pin));
 unlock:
 	mutex_unlock(&pf->dplls.lock);
-	/* The core notifies this pin on success */
-	if (mux)
-		__ice_dpll_rclk_mux_ntf(mux, prev, ret ? NULL : p->pin);
 
 	return ret;
 }
@@ -2856,6 +2840,108 @@ static int ice_dpll_rclk_mux_mode_get(const struct dpll_device *dpll,
 	return 0;
 }
 
+/**
+ * ice_dpll_rclk_state_on_dpll_set - set a state of rclk pin on a mux
+ * @pin: pointer to a pin
+ * @pin_priv: private data pointer passed on pin registration
+ * @dpll: registered dpll pointer
+ * @dpll_priv: private data pointer passed on dpll registration
+ * @state: state to be set on pin
+ * @extack: error reporting
+ *
+ * Dpll subsystem callback. Route the recovered clock of the port to the
+ * output of a recovered clock mux, or stop routing it.
+ *
+ * Context: Acquires pf->dplls.lock
+ * Return:
+ * * 0 - success
+ * * negative - failure
+ */
+static int
+ice_dpll_rclk_state_on_dpll_set(const struct dpll_pin *pin, void *pin_priv,
+				const struct dpll_device *dpll,
+				void *dpll_priv, enum dpll_pin_state state,
+				struct netlink_ext_ack *extack)
+{
+	bool enable = state == DPLL_PIN_STATE_CONNECTED;
+	struct ice_dpll_rclk_mux *mux = dpll_priv;
+	struct ice_dpll_pin *p = pin_priv;
+	struct ice_pf *pf = p->pf;
+	struct dpll_pin *prev;
+	int ret = -EINVAL;
+
+	if (ice_dpll_is_reset(pf, extack))
+		return -EBUSY;
+
+	/* Read again with the write of the mux, under cgu_synce_lock */
+	prev = READ_ONCE(mux->src);
+	mutex_lock(&pf->dplls.lock);
+	if ((enable && p->state[mux->idx] == DPLL_PIN_STATE_CONNECTED) ||
+	    (!enable && p->state[mux->idx] == DPLL_PIN_STATE_DISCONNECTED)) {
+		NL_SET_ERR_MSG_FMT(extack,
+				   "pin:%u state:%u on dpll:%u already set",
+				   p->idx, state, mux->idx);
+		goto unlock;
+	}
+
+	ret = ice_dpll_synce_update_e825c(&pf->hw, enable,
+					  pf->ptp.port.port_num, mux->idx,
+					  &prev);
+	if (ret)
+		NL_SET_ERR_MSG_FMT(extack,
+				   "err:%d %s failed to set pin state:%u for pin:%u on dpll:%u",
+				   ret,
+				   libie_aq_str(pf->hw.adminq.sq_last_status),
+				   state, p->idx, mux->idx);
+unlock:
+	mutex_unlock(&pf->dplls.lock);
+	/* The core notifies this pin on success */
+	__ice_dpll_rclk_mux_ntf(mux, prev, ret ? NULL : p->pin);
+
+	return ret;
+}
+
+/**
+ * ice_dpll_rclk_state_on_dpll_get - get a state of rclk pin on a mux
+ * @pin: pointer to a pin
+ * @pin_priv: private data pointer passed on pin registration
+ * @dpll: registered dpll pointer
+ * @dpll_priv: private data pointer passed on dpll registration
+ * @state: on success holds pin state on the mux
+ * @extack: error reporting
+ *
+ * Dpll subsystem callback. Get the state of the recovered clock pin on a
+ * recovered clock mux.
+ *
+ * Context: Acquires pf->dplls.lock
+ * Return:
+ * * 0 - success
+ * * negative - failure
+ */
+static int
+ice_dpll_rclk_state_on_dpll_get(const struct dpll_pin *pin, void *pin_priv,
+				const struct dpll_device *dpll,
+				void *dpll_priv, enum dpll_pin_state *state,
+				struct netlink_ext_ack *extack)
+{
+	struct ice_dpll_rclk_mux *mux = dpll_priv;
+	struct ice_dpll_pin *p = pin_priv;
+	struct ice_pf *pf = p->pf;
+	int ret;
+
+	if (ice_dpll_is_reset(pf, extack))
+		return -EBUSY;
+
+	mutex_lock(&pf->dplls.lock);
+	ret = ice_dpll_pin_state_update(pf, p, ICE_DPLL_PIN_TYPE_RCLK_INPUT,
+					extack);
+	if (!ret)
+		*state = p->state[mux->idx];
+	mutex_unlock(&pf->dplls.lock);
+
+	return ret;
+}
+
 /**
  * ice_dpll_rclk_out_state_get - get a state of a recovered clock mux output
  * @pin: pointer to a pin
@@ -3078,6 +3164,12 @@ static const struct dpll_pin_ops ice_dpll_rclk_ops = {
 	.direction_get = ice_dpll_input_direction,
 };
 
+static const struct dpll_pin_ops ice_dpll_rclk_in_ops = {
+	.state_on_dpll_set = ice_dpll_rclk_state_on_dpll_set,
+	.state_on_dpll_get = ice_dpll_rclk_state_on_dpll_get,
+	.direction_get = ice_dpll_input_direction,
+};
+
 static const struct dpll_pin_ops ice_dpll_rclk_out_ops = {
 	.state_on_dpll_get = ice_dpll_rclk_out_state_get,
 	.direction_get = ice_dpll_output_direction,
@@ -4019,125 +4111,34 @@ static void ice_dpll_deinit_rclk_pin(struct ice_pf *pf)
 		dpll_pin_on_pin_unregister(parent->pin, rclk->pin,
 					   &ice_dpll_rclk_ops, rclk);
 	}
-	if (pf->hw.mac_type == ICE_MAC_GENERIC_3K_E825)
-		ice_dpll_rclk_src_fini(pf);
 	if (WARN_ON_ONCE(!vsi || !vsi->netdev))
 		return;
 	dpll_netdev_pin_clear(vsi->netdev);
 	dpll_pin_put(rclk->pin, &rclk->tracker);
 }
 
-static bool ice_dpll_is_fwnode_pin(struct ice_dpll_pin *pin)
-{
-	return !IS_ERR_OR_NULL(pin->fwnode);
-}
-
-static bool ice_dpll_fwnode_eq(const struct fwnode_handle *a,
-			       const struct fwnode_handle *b)
-{
-	return a && a == b;
-}
-
-static void ice_dpll_pin_notify_work(struct work_struct *work)
-{
-	struct ice_dpll_pin_work *w = container_of(work,
-						   struct ice_dpll_pin_work,
-						   work);
-	struct ice_dpll_pin *pin, *parent = w->pin;
-	struct ice_pf *pf = parent->pf;
-	bool is_rclk_parent = false;
-	int ret;
-
-	wait_for_completion(&pf->dplls.dpll_init);
-	if (!test_bit(ICE_FLAG_DPLL, pf->flags))
-		goto out; /* DPLL initialization failed */
-
-	/* Decide which parent we are handling, defensively checking FWNs */
-	for (int i = 0; i < pf->dplls.rclk.num_parents; i++) {
-		if (ice_dpll_fwnode_eq(parent->fwnode,
-				       pf->dplls.inputs[i].fwnode)) {
-			is_rclk_parent = true;
-			break;
-		}
-	}
-
-	if (!is_rclk_parent)
-		goto out;
-
-	switch (w->action) {
-	case DPLL_PIN_CREATED:
-		if (!IS_ERR_OR_NULL(parent->pin)) {
-			/* We have already our pin registered */
-			goto out;
-		}
-
-		/* Grab reference on fwnode pin */
-		parent->pin = fwnode_dpll_pin_find(parent->fwnode,
-						   &parent->tracker);
-		if (IS_ERR_OR_NULL(parent->pin)) {
-			dev_err(ice_pf_to_dev(pf),
-				"Cannot get fwnode pin reference\n");
-			goto out;
-		}
-
-		/* Register rclk pin via on-pin relationship */
-		pin = &pf->dplls.rclk;
-		ret = dpll_pin_on_pin_register(parent->pin, pin->pin,
-					       &ice_dpll_rclk_ops, pin);
-		if (ret) {
-			dev_err(ice_pf_to_dev(pf),
-				"RCLK pin register failed: %pe\n",
-				ERR_PTR(ret));
-			goto drop_parent_ref;
-		}
-		break;
-	case DPLL_PIN_DELETED:
-		if (IS_ERR_OR_NULL(parent->pin)) {
-			/* We have already our pin unregistered */
-			goto out;
-		}
-
-		/* Unregister rclk pin */
-		pin = &pf->dplls.rclk;
-		dpll_pin_on_pin_unregister(parent->pin, pin->pin,
-					   &ice_dpll_rclk_ops, pin);
-drop_parent_ref:
-		/* Drop fwnode pin reference */
-		dpll_pin_put(parent->pin, &parent->tracker);
-		parent->pin = NULL;
-		break;
-	default:
-		break;
-	}
-out:
-	kfree(w);
-}
-
-static int ice_dpll_pin_notify(struct notifier_block *nb, unsigned long action,
-			       void *data)
+/**
+ * ice_dpll_deinit_rclk_pin_e825c - release rclk pin resources on E825
+ * @pf: board private structure
+ *
+ * Unregister the rclk pin from the recovered clock muxes and release it.
+ */
+static void ice_dpll_deinit_rclk_pin_e825c(struct ice_pf *pf)
 {
-	struct ice_dpll_pin *pin = container_of(nb, struct ice_dpll_pin, nb);
-	struct dpll_pin_notifier_info *info = data;
-	struct ice_dpll_pin_work *work;
-
-	if (action != DPLL_PIN_CREATED && action != DPLL_PIN_DELETED)
-		return NOTIFY_DONE;
-
-	/* Check if the reported pin is this one */
-	if (pin->fwnode != info->fwnode)
-		return NOTIFY_DONE; /* Not this pin */
-
-	work = kzalloc_obj(*work);
-	if (!work)
-		return NOTIFY_DONE;
-
-	INIT_WORK(&work->work, ice_dpll_pin_notify_work);
-	work->action = action;
-	work->pin = pin;
-
-	queue_work(pin->pf->dplls.wq, &work->work);
+	struct ice_dpll_rclk_mux *muxes = pf->adapter->rclk_mux;
+	struct ice_dpll_pin *rclk = &pf->dplls.rclk;
+	struct ice_vsi *vsi = ice_get_main_vsi(pf);
+	int i;
 
-	return NOTIFY_OK;
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++)
+		dpll_pin_unregister(muxes[i].dpll, rclk->pin,
+				    &ice_dpll_rclk_in_ops, rclk);
+	/* No callback of the pin runs any more and can route the port again */
+	ice_dpll_rclk_src_fini(pf);
+	if (WARN_ON_ONCE(!vsi || !vsi->netdev))
+		return;
+	dpll_netdev_pin_clear(vsi->netdev);
+	dpll_pin_put(rclk->pin, &rclk->tracker);
 }
 
 /**
@@ -4168,17 +4169,8 @@ ice_dpll_init_pin_common(struct ice_pf *pf, struct ice_dpll_pin *pin,
 	for (i = 0; i < pin->num_parents; i++) {
 		parent = &pf->dplls.inputs[pin->parent_idx[i]];
 		if (IS_ERR_OR_NULL(parent->pin)) {
-			if (!ice_dpll_is_fwnode_pin(parent)) {
-				ret = -ENODEV;
-				goto unregister_pins;
-			}
-			parent->pin = fwnode_dpll_pin_find(parent->fwnode,
-							   &parent->tracker);
-			if (IS_ERR_OR_NULL(parent->pin)) {
-				dev_info(ice_pf_to_dev(pf),
-					 "Mux pin not registered yet\n");
-				continue;
-			}
+			ret = -ENODEV;
+			goto unregister_pins;
 		}
 		ret = dpll_pin_on_pin_register(parent->pin, pin->pin, ops, pin);
 		if (ret)
@@ -4228,43 +4220,6 @@ ice_dpll_init_rclk_pin(struct ice_pf *pf, int start_idx,
 	return 0;
 }
 
-static void
-ice_dpll_stop_fwnode_pin_activity(struct ice_dpll_pin *pin, bool flush)
-{
-	unregister_dpll_notifier(&pin->nb);
-	if (flush)
-		flush_workqueue(pin->pf->dplls.wq);
-}
-
-static void
-ice_dpll_release_fwnode_pin(struct ice_dpll_pin *pin)
-{
-	if (!IS_ERR_OR_NULL(pin->pin)) {
-		dpll_pin_put(pin->pin, &pin->tracker);
-		pin->pin = NULL;
-	}
-	fwnode_handle_put(pin->fwnode);
-	pin->fwnode = NULL;
-}
-
-static void
-ice_dpll_deinit_fwnode_pin(struct ice_dpll_pin *pin)
-{
-	ice_dpll_stop_fwnode_pin_activity(pin, true);
-	ice_dpll_release_fwnode_pin(pin);
-}
-
-static void
-ice_dpll_deinit_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
-			    int start_idx)
-{
-	int i;
-
-	for (i = 0; i < pf->dplls.rclk.num_parents; i++)
-		ice_dpll_deinit_fwnode_pin(&pins[start_idx + i]);
-	destroy_workqueue(pf->dplls.wq);
-}
-
 static void ice_dpll_deinit_txclk_pins(struct ice_pf *pf)
 {
 	struct ice_dplls *d = &pf->dplls;
@@ -4349,14 +4304,16 @@ static void ice_dpll_deinit_pins(struct ice_pf *pf, bool cgu)
 	struct ice_dpll *de = &d->eec;
 	struct ice_dpll *dp = &d->pps;
 
-	ice_dpll_deinit_rclk_pin(pf);
 	if (pf->hw.mac_type == ICE_MAC_GENERIC_3K_E825) {
 		if (ice_pf_src_tmr_owned(pf) &&
 		    test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
 			ice_dpll_deinit_tspll_pins(pf);
 		ice_dpll_deinit_txclk_pins(pf);
-		ice_dpll_deinit_fwnode_pins(pf, pf->dplls.inputs, 0);
+		ice_dpll_deinit_rclk_pin_e825c(pf);
 		ice_dpll_rclk_muxes_put(pf);
+		destroy_workqueue(pf->dplls.wq);
+	} else {
+		ice_dpll_deinit_rclk_pin(pf);
 	}
 	if (cgu) {
 		ice_dpll_unregister_pins(dp->dpll, inputs, &ice_dpll_input_ops,
@@ -4522,96 +4479,50 @@ static int ice_dpll_rclk_muxes_get(struct ice_pf *pf)
 	return ret;
 }
 
-static int
-ice_dpll_init_fwnode_pin(struct ice_dpll_pin *pin, const char *name)
-{
-	struct ice_pf *pf = pin->pf;
-	int ret;
-
-	pin->fwnode = ice_dpll_pin_node_get(pf, name);
-	if (IS_ERR(pin->fwnode)) {
-		dev_err(ice_pf_to_dev(pf),
-			"Failed to find %s firmware node: %pe\n", name,
-			pin->fwnode);
-		pin->fwnode = NULL;
-		return -ENODEV;
-	}
-
-	dev_dbg(ice_pf_to_dev(pf), "Found fwnode node for %s\n", name);
-
-	pin->pin = fwnode_dpll_pin_find(pin->fwnode, &pin->tracker);
-	if (IS_ERR_OR_NULL(pin->pin)) {
-		dev_info(ice_pf_to_dev(pf),
-			 "DPLL pin for %pfwp not registered yet\n",
-			 pin->fwnode);
-		pin->pin = NULL;
-	}
-
-	pin->nb.notifier_call = ice_dpll_pin_notify;
-	ret = register_dpll_notifier(&pin->nb);
-	if (ret) {
-		dev_err(ice_pf_to_dev(pf),
-			"Failed to subscribe for DPLL notifications\n");
-
-		if (!IS_ERR_OR_NULL(pin->pin)) {
-			dpll_pin_put(pin->pin, &pin->tracker);
-			pin->pin = NULL;
-		}
-		fwnode_handle_put(pin->fwnode);
-		pin->fwnode = NULL;
-
-		return ret;
-	}
-
-	return ret;
-}
-
 /**
- * ice_dpll_init_fwnode_pins - initialize pins from device tree
+ * ice_dpll_init_rclk_pin_e825c - initialize recovered clock pin on E825
  * @pf: board private structure
- * @pins: pointer to pins array
- * @start_idx: starting index for pins
  *
- * Initialize input pins for E825 RCLK support. The parent pins (rclk0, rclk1)
- * are expected to be defined by the system firmware (ACPI). This function
- * allocates them in the dpll subsystem and stores their indices for later
- * registration with the rclk pin.
+ * Get the recovered clock pin of the PF, register it with both recovered
+ * clock muxes and record the muxes that route its port. The clock ID of the
+ * pin is the clock ID of the muxes, so the pins of all PFs of the adapter
+ * share it. A clock ID based on the DSN would not tell the PFs apart either,
+ * as all PFs of a complex have the same DSN.
  *
  * Return:
  * * 0 - success
- * * negative - initialization failure reason
+ * * negative - registration failure reason
  */
-static int
-ice_dpll_init_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
-			  int start_idx)
+static int ice_dpll_init_rclk_pin_e825c(struct ice_pf *pf)
 {
-	char pin_name[16];
-	int i, ret;
-
-	pf->dplls.wq = create_singlethread_workqueue("ice_dpll_wq");
-	if (!pf->dplls.wq)
-		return -ENOMEM;
+	struct ice_dpll_rclk_mux *muxes = pf->adapter->rclk_mux;
+	struct ice_dpll_pin *rclk = &pf->dplls.rclk;
+	struct ice_vsi *vsi = ice_get_main_vsi(pf);
+	int ret, i;
 
-	for (i = 0; i < pf->dplls.rclk.num_parents; i++) {
-		pins[start_idx + i].pf = pf;
-		snprintf(pin_name, sizeof(pin_name), "rclk%u", i);
-		ret = ice_dpll_init_fwnode_pin(&pins[start_idx + i], pin_name);
+	ret = ice_dpll_get_pins(pf, rclk, DPLL_PIN_IDX_UNSPEC, 1,
+				pf->adapter->index);
+	if (ret)
+		return ret;
+	for (i = 0; i < ICE_SYNCE_CLK_NUM; i++) {
+		ret = dpll_pin_register(muxes[i].dpll, rclk->pin,
+					&ice_dpll_rclk_in_ops, rclk);
 		if (ret)
-			goto error;
+			goto unregister_pin;
 	}
+	ret = ice_dpll_rclk_src_init(pf);
+	if (ret)
+		goto unregister_pin;
+	dpll_netdev_pin_set(vsi->netdev, rclk->pin);
 
 	return 0;
-error:
-	/*
-	 * A notifier worker may already be queued and blocked on dpll_init;
-	 * release it so the per-pin flush below does not deadlock.
-	 */
-	complete_all(&pf->dplls.dpll_init);
-	while (i--)
-		ice_dpll_deinit_fwnode_pin(&pins[start_idx + i]);
-
-	destroy_workqueue(pf->dplls.wq);
 
+unregister_pin:
+	while (i--)
+		dpll_pin_unregister(muxes[i].dpll, rclk->pin,
+				    &ice_dpll_rclk_in_ops, rclk);
+	ice_dpll_rclk_src_fini(pf);
+	ice_dpll_release_pins(rclk, 1);
 	return ret;
 }
 
@@ -4724,52 +4635,36 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
 {
 	int ret;
 
+	pf->dplls.wq = create_singlethread_workqueue("ice_dpll_wq");
+	if (!pf->dplls.wq)
+		return -ENOMEM;
+
 	ret = ice_dpll_rclk_muxes_get(pf);
 	if (ret)
-		return ret;
-
-	ret = ice_dpll_init_fwnode_pins(pf, pf->dplls.inputs, 0);
+		goto destroy_wq;
+	ret = ice_dpll_init_rclk_pin_e825c(pf);
 	if (ret)
 		goto put_muxes;
-
-	ret = ice_dpll_init_rclk_pin(pf, DPLL_PIN_IDX_UNSPEC,
-				     &ice_dpll_rclk_ops);
-
-	if (ret)
-		goto unregister_pins;
-
-	ret = ice_dpll_rclk_src_init(pf);
-	if (ret) {
-		ice_dpll_deinit_rclk_pin(pf);
-		goto unregister_pins;
-	}
-
 	ret = ice_dpll_init_txclk_pins(pf);
-	if (ret) {
-		ice_dpll_deinit_rclk_pin(pf);
-		goto unregister_pins;
-	}
-
+	if (ret)
+		goto deinit_rclk_pin;
 	if (ice_pf_src_tmr_owned(pf) &&
 	    test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) {
 		ret = ice_dpll_init_tspll_pins(pf);
-		if (ret) {
-			ice_dpll_deinit_txclk_pins(pf);
-			ice_dpll_deinit_rclk_pin(pf);
-		}
+		if (ret)
+			goto deinit_txclk_pins;
 	}
 
-unregister_pins:
-	if (ret) {
-		/* Inform DPLL notifier works that DPLL init was finished
-		 * unsuccessfully (ICE_DPLL_FLAG not set).
-		 */
-		complete_all(&pf->dplls.dpll_init);
-		ice_dpll_deinit_fwnode_pins(pf, pf->dplls.inputs, 0);
-	}
+	return 0;
+
+deinit_txclk_pins:
+	ice_dpll_deinit_txclk_pins(pf);
+deinit_rclk_pin:
+	ice_dpll_deinit_rclk_pin_e825c(pf);
 put_muxes:
-	if (ret)
-		ice_dpll_rclk_muxes_put(pf);
+	ice_dpll_rclk_muxes_put(pf);
+destroy_wq:
+	destroy_workqueue(pf->dplls.wq);
 
 	return ret;
 }
@@ -5146,7 +5041,7 @@ ice_dpll_init_info_direct_pins(struct ice_pf *pf,
 }
 
 /**
- * ice_dpll_init_info_pin_on_pin_e825c - initializes rclk pin information
+ * ice_dpll_init_info_rclk_pin_e825c - initializes rclk pin information
  * @pf: board private structure
  *
  * Init information for rclk pin, cache them in pf->dplls.rclk.
@@ -5154,7 +5049,7 @@ ice_dpll_init_info_direct_pins(struct ice_pf *pf,
  * Return:
  * * 0 - success
  */
-static int ice_dpll_init_info_pin_on_pin_e825c(struct ice_pf *pf)
+static int ice_dpll_init_info_rclk_pin_e825c(struct ice_pf *pf)
 {
 	struct ice_dpll_pin *rclk_pin = &pf->dplls.rclk;
 
@@ -5340,7 +5235,7 @@ ice_dpll_init_pins_info(struct ice_pf *pf, enum ice_dpll_pin_type pin_type)
 		return ice_dpll_init_info_direct_pins(pf, pin_type);
 	case ICE_DPLL_PIN_TYPE_RCLK_INPUT:
 		if (pf->hw.mac_type == ICE_MAC_GENERIC_3K_E825)
-			return ice_dpll_init_info_pin_on_pin_e825c(pf);
+			return ice_dpll_init_info_rclk_pin_e825c(pf);
 		else
 			return ice_dpll_init_info_rclk_pin(pf);
 	case ICE_DPLL_PIN_TYPE_SOFTWARE:
@@ -5387,11 +5282,9 @@ static int ice_dpll_init_info_e825c(struct ice_pf *pf)
 	struct ice_dplls *d = &pf->dplls;
 	struct ice_dpll *tp = &d->tspll;
 	struct ice_dpll *dt = &d->txc;
-	int ret = 0;
-	int i;
+	int ret;
 
 	d->clock_id = ice_generate_clock_id(pf);
-	d->num_inputs = ICE_SYNCE_CLK_NUM;
 	dt->dpll_state = ice_txclk_lock_status(pf->ptp.port.tx_clk);
 	dt->mode = DPLL_MODE_MANUAL;
 	dt->dpll_idx = E825_DPLL_TXCLK_BASE_IDX + pf->ptp.port.port_num;
@@ -5400,33 +5293,11 @@ static int ice_dpll_init_info_e825c(struct ice_pf *pf)
 	tp->mode = DPLL_MODE_MANUAL;
 	tp->dpll_idx = E825_DPLL_TSPLL_BASE_IDX;
 
-	d->inputs = kzalloc_objs(*d->inputs, d->num_inputs);
-	if (!d->inputs)
-		return -ENOMEM;
-
-	ret = ice_get_cgu_rclk_pin_info(&pf->hw, &d->base_rclk_idx,
-					&pf->dplls.rclk.num_parents);
-	if (ret)
-		goto deinit_info;
-
-	for (i = 0; i < pf->dplls.rclk.num_parents; i++)
-		pf->dplls.rclk.parent_idx[i] = d->base_rclk_idx + i;
-
 	ret = ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_RCLK_INPUT);
 	if (ret)
-		goto deinit_info;
-
-	ret = ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_TXCLK);
-	if (ret)
-		goto deinit_info;
+		return ret;
 
-	dev_dbg(ice_pf_to_dev(pf),
-		"%s - success, inputs: %u, outputs: %u, rclk-parents: %u\n",
-		 __func__, d->num_inputs, d->num_outputs, d->rclk.num_parents);
-	return 0;
-deinit_info:
-	ice_dpll_deinit_info(pf);
-	return ret;
+	return ice_dpll_init_pins_info(pf, ICE_DPLL_PIN_TYPE_TXCLK);
 }
 
 /**
@@ -5615,7 +5486,6 @@ static void ice_dpll_init_e825(struct ice_pf *pf)
 	 */
 	INIT_WORK(&d->txclk_work, ice_dpll_txclk_work);
 	init_rwsem(&d->txclk_notify_rwsem);
-	init_completion(&d->dpll_init);
 
 	err = ice_dpll_init_info_e825c(pf);
 	if (err)
@@ -5626,17 +5496,6 @@ static void ice_dpll_init_e825(struct ice_pf *pf)
 					 DPLL_TYPE_GENERIC);
 		if (err)
 			goto deinit_info;
-		/* Start the periodic worker before registering fwnode pins. The
-		 * fwnode notifier path (ice_dpll_pin_notify_work()) blocks on
-		 * pf->dplls.dpll_init, which is only signalled on the success
-		 * return below. Starting the worker before any fwnode notifier
-		 * is registered means a subsequent init failure cannot leave
-		 * notifier work items queued on pf->dplls.wq, so the deinit
-		 * flush_workqueue() paths in ice_dpll_deinit_pins() cannot
-		 * deadlock. The E825 periodic worker only touches
-		 * pf->dplls.tspll (already registered above) and pf->ptp state,
-		 * so it is safe to run before pins.
-		 */
 		err = ice_dpll_init_worker(pf);
 		if (err)
 			goto deinit_tspll;
@@ -5648,7 +5507,6 @@ static void ice_dpll_init_e825(struct ice_pf *pf)
 	if (err)
 		goto deinit_txclk;
 	set_bit(ICE_FLAG_DPLL, pf->flags);
-	complete_all(&d->dpll_init);
 
 	return;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.h b/drivers/net/ethernet/intel/ice/ice_dpll.h
index e0b48c8af3fbbb..73b0eed6774aa4 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.h
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.h
@@ -39,12 +39,6 @@ enum ice_dpll_pin_sw {
 	ICE_DPLL_PIN_SW_NUM
 };
 
-struct ice_dpll_pin_work {
-	struct work_struct work;
-	unsigned long action;
-	struct ice_dpll_pin *pin;
-};
-
 /** ice_dpll_pin - store info about pins
  * @pin: dpll pin structure
  * @pf: pointer to pf, which has registered the dpll_pin
@@ -64,8 +58,6 @@ struct ice_dpll_pin {
 	struct dpll_pin *pin;
 	struct ice_pf *pf;
 	dpll_tracker tracker;
-	struct fwnode_handle *fwnode;
-	struct notifier_block nb;
 	u8 idx;
 	u8 num_parents;
 	u8 parent_idx[ICE_DPLL_RCLK_NUM_MAX];
@@ -179,7 +171,6 @@ struct ice_dplls {
 	struct kthread_delayed_work work;
 	struct workqueue_struct *wq;
 	struct mutex lock;
-	struct completion dpll_init;
 	struct ice_dpll eec;
 	struct ice_dpll pps;
 	struct ice_dpll txc;
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index ee945ce08eb72c..3c741aa97292f1 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -6220,14 +6220,6 @@ int ice_get_cgu_rclk_pin_info(struct ice_hw *hw, u8 *base_idx, u8 *pin_num)
 		else
 			ret = -ENODEV;
 		break;
-	case ICE_DEV_ID_E825C_BACKPLANE:
-	case ICE_DEV_ID_E825C_QSFP:
-	case ICE_DEV_ID_E825C_SFP:
-	case ICE_DEV_ID_E825C_SGMII:
-		*pin_num = ICE_SYNCE_CLK_NUM;
-		*base_idx = 0;
-		ret = 0;
-		break;
 	default:
 		ret = -ENODEV;
 		break;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 15/19] dpll: register pins only with a parent pin of their owner
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (13 preceding siblings ...)
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 16/19] dpll: drop the in-kernel notifier chain Ivan Vecera
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

dpll_pin_on_pin_register() accepts a parent pin of another owner and
then registers the pin with the DPLLs of that owner. Its only user was
ice on E825, which now describes its recovered clock muxes with its own
DPLL devices linked with the zl3073x pins.

Require the same owner for the parent pin, as dpll_pin_register() does
for the DPLL, and document how to describe a mux in front of an input of
another device.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst | 7 +++++--
 drivers/dpll/dpll_core.c          | 9 +++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index 90c88fcf21b385..bc34fc83882fac 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -355,7 +355,8 @@ Pin ownership and links
 
 The owner of a dpll device or a pin is identified by the module and the
 clock_id passed to dpll_device_get() or dpll_pin_get(). dpll_pin_register()
-accepts only a dpll device of the same owner as the pin.
+accepts only a dpll device and dpll_pin_on_pin_register() only a parent pin
+of the same owner as the pin.
 
 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
@@ -364,7 +365,9 @@ 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.
+drivers may probe in any order. A mux of one device that feeds an input of
+another device is a dpll device of its own driver, with the selectable
+signals as input pins and an output pin linked with that input.
 
 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:
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 7440b174c3de2b..9b48d289ec7330 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -1081,6 +1081,8 @@ EXPORT_SYMBOL_GPL(dpll_pin_unregister);
  *
  * Register a pin with a parent pin, create references between them and
  * between newly registered pin and dplls connected with a parent pin.
+ * The @parent and the @pin must have the same owner, they must be created
+ * with the same module and clock_id.
  *
  * Context: Acquires a lock (dpll_lock)
  * Return:
@@ -1097,6 +1099,13 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
 	if (WARN_ON(parent->prop.type != DPLL_PIN_TYPE_MUX))
 		return -EINVAL;
 
+	/* A pin of another owner is connected by a link, see
+	 * dpll_pin_link_add().
+	 */
+	if (WARN_ON_ONCE(parent->module != pin->module ||
+			 parent->clock_id != pin->clock_id))
+		return -EINVAL;
+
 	if (WARN_ON(!ops) ||
 	    WARN_ON(!ops->state_on_pin_get) ||
 	    WARN_ON(!ops->direction_get))
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 16/19] dpll: drop the in-kernel notifier chain
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (14 preceding siblings ...)
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 17/19] dpll: require a registered DPLL for pin registration Ivan Vecera
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

The only user of the notifier chain from commit 2be467588d6b ("dpll: Add
notifier chain for dpll events") was ice on E825. The driver waited
there for the zl3073x pins it registered its own pins with. It now links
its own pins with them instead.

Drop the chain. The KUnit tests counted the change notifications of
linked pins through it. Count them with a static stub of
__dpll_pin_change_ntf() instead.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/Kconfig            |  4 +--
 drivers/dpll/dpll_core.c        | 43 ---------------------------------
 drivers/dpll/dpll_core.h        |  2 --
 drivers/dpll/dpll_netlink.c     |  5 ++--
 drivers/dpll/tests/dpll_kunit.c | 31 +++++++++---------------
 include/linux/dpll.h            | 18 --------------
 6 files changed, 15 insertions(+), 88 deletions(-)

diff --git a/drivers/dpll/Kconfig b/drivers/dpll/Kconfig
index 6f1ffc3a6e7717..d57696652d450a 100644
--- a/drivers/dpll/Kconfig
+++ b/drivers/dpll/Kconfig
@@ -34,8 +34,8 @@ config DPLL_KUNIT_TEST
 	  while the pins at both ends are registered.
 
 	  The mock devices and pins are registered with the DPLL subsystem,
-	  so user space sees them and their notifications while the tests
-	  run.
+	  so user space sees them and their create and delete notifications
+	  while the tests run.
 
 	  If unsure, say N.
 
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 9b48d289ec7330..e199342652d163 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -27,7 +27,6 @@ EXPORT_SYMBOL_IF_KUNIT(dpll_lock);
 DEFINE_XARRAY_FLAGS(dpll_device_xa, XA_FLAGS_ALLOC);
 DEFINE_XARRAY_FLAGS(dpll_pin_xa, XA_FLAGS_ALLOC);
 
-static RAW_NOTIFIER_HEAD(dpll_notifier_chain);
 static DEFINE_IDA(dpll_pin_idx_ida);
 
 static u32 dpll_device_xa_id;
@@ -55,26 +54,6 @@ struct dpll_pin_registration {
 	dpll_tracker tracker;
 };
 
-static int call_dpll_notifiers(unsigned long action, void *info)
-{
-	lockdep_assert_held(&dpll_lock);
-	return raw_notifier_call_chain(&dpll_notifier_chain, action, info);
-}
-
-void dpll_pin_notify(struct dpll_pin *pin, unsigned long action)
-{
-	struct dpll_pin_notifier_info info = {
-		.pin = pin,
-		.id = pin->id,
-		.idx = pin->pin_idx,
-		.clock_id = pin->clock_id,
-		.fwnode = pin->fwnode,
-		.prop = &pin->prop,
-	};
-
-	call_dpll_notifiers(action, &info);
-}
-
 static void dpll_device_tracker_alloc(struct dpll_device *dpll,
 				      dpll_tracker *tracker)
 {
@@ -704,28 +683,6 @@ void dpll_netdev_pin_clear(struct net_device *dev)
 }
 EXPORT_SYMBOL(dpll_netdev_pin_clear);
 
-int register_dpll_notifier(struct notifier_block *nb)
-{
-	int ret;
-
-	mutex_lock(&dpll_lock);
-	ret = raw_notifier_chain_register(&dpll_notifier_chain, nb);
-	mutex_unlock(&dpll_lock);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(register_dpll_notifier);
-
-int unregister_dpll_notifier(struct notifier_block *nb)
-{
-	int ret;
-
-	mutex_lock(&dpll_lock);
-	ret = raw_notifier_chain_unregister(&dpll_notifier_chain, nb);
-	mutex_unlock(&dpll_lock);
-	return ret;
-}
-EXPORT_SYMBOL_GPL(unregister_dpll_notifier);
-
 /**
  * dpll_pin_get - find existing or create new dpll pin
  * @clock_id: clock_id of creator
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index 3b7e0af7f7ee6f..6e10aadd2123d9 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -111,6 +111,4 @@ extern struct xarray dpll_device_xa;
 extern struct xarray dpll_pin_xa;
 extern struct mutex dpll_lock;
 
-void dpll_pin_notify(struct dpll_pin *pin, unsigned long action);
-
 #endif
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 372de086a7eb3d..6a46130fc687eb 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -6,6 +6,7 @@
  *  Copyright (c) 2023 Intel and affiliates
  *
  */
+#include <kunit/static_stub.h>
 #include <kunit/visibility.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -968,13 +969,11 @@ dpll_pin_event_send(enum dpll_cmd event, struct dpll_pin *pin)
 
 int dpll_pin_create_ntf(struct dpll_pin *pin)
 {
-	dpll_pin_notify(pin, DPLL_PIN_CREATED);
 	return dpll_pin_event_send(DPLL_CMD_PIN_CREATE_NTF, pin);
 }
 
 int dpll_pin_delete_ntf(struct dpll_pin *pin)
 {
-	dpll_pin_notify(pin, DPLL_PIN_DELETED);
 	return dpll_pin_event_send(DPLL_CMD_PIN_DELETE_NTF, pin);
 }
 
@@ -988,8 +987,8 @@ int dpll_pin_delete_ntf(struct dpll_pin *pin)
  */
 int __dpll_pin_change_ntf(struct dpll_pin *pin)
 {
+	KUNIT_STATIC_STUB_REDIRECT(__dpll_pin_change_ntf, pin);
 	lockdep_assert_held(&dpll_lock);
-	dpll_pin_notify(pin, DPLL_PIN_CHANGED);
 	return dpll_pin_event_send(DPLL_CMD_PIN_CHANGE_NTF, pin);
 }
 EXPORT_SYMBOL_GPL(__dpll_pin_change_ntf);
diff --git a/drivers/dpll/tests/dpll_kunit.c b/drivers/dpll/tests/dpll_kunit.c
index 7fb50fe0eea9a5..1804e5836f7db2 100644
--- a/drivers/dpll/tests/dpll_kunit.c
+++ b/drivers/dpll/tests/dpll_kunit.c
@@ -12,9 +12,9 @@
  */
 
 #include <kunit/fwnode.h>
+#include <kunit/static_stub.h>
 #include <kunit/test.h>
 #include <linux/dpll.h>
-#include <linux/notifier.h>
 #include <net/netlink.h>
 
 #include "../dpll_core.h"
@@ -35,15 +35,13 @@ struct dt_dev {
 struct dt_pin {
 	struct dpll_pin *pin;
 	dpll_tracker tracker;
-	int changes;		/* DPLL_PIN_CHANGED notifications */
+	int changes;		/* change notifications */
 };
 
 struct dt_ctx {
 	struct dt_dev a0, a1, b0;
 	struct dt_pin p, u, c;
 	struct fwnode_handle *fwnode;
-	struct notifier_block nb;
-	bool nb_registered;
 	bool p_a0, p_a1, u_a0, c_b0;	/* registrations */
 };
 
@@ -95,22 +93,19 @@ static const struct dpll_pin_properties dt_pin_prop = {
 	.type = DPLL_PIN_TYPE_EXT,
 };
 
-static int dt_notify(struct notifier_block *nb, unsigned long action,
-		     void *data)
+/* Stub of __dpll_pin_change_ntf() that counts the notifications */
+static int dt_pin_change_ntf(struct dpll_pin *pin)
 {
-	struct dt_ctx *ctx = container_of(nb, struct dt_ctx, nb);
-	struct dpll_pin_notifier_info *info = data;
+	struct dt_ctx *ctx = kunit_get_current_test()->priv;
 
-	if (action != DPLL_PIN_CHANGED)
-		return NOTIFY_DONE;
-	if (info->pin == ctx->p.pin)
+	if (pin == ctx->p.pin)
 		ctx->p.changes++;
-	else if (info->pin == ctx->u.pin)
+	else if (pin == ctx->u.pin)
 		ctx->u.changes++;
-	else if (info->pin == ctx->c.pin)
+	else if (pin == ctx->c.pin)
 		ctx->c.changes++;
 
-	return NOTIFY_OK;
+	return 0;
 }
 
 static void dt_dev_init(struct kunit *test, struct dt_dev *dev, u64 clock_id,
@@ -235,10 +230,8 @@ static int dt_init(struct kunit *test)
 	ret = dpll_pin_link_add(ctx->c.pin, ctx->fwnode);
 	KUNIT_ASSERT_EQ(test, ret, 0);
 
-	ctx->nb.notifier_call = dt_notify;
-	ret = register_dpll_notifier(&ctx->nb);
-	KUNIT_ASSERT_EQ(test, ret, 0);
-	ctx->nb_registered = true;
+	kunit_activate_static_stub(test, __dpll_pin_change_ntf,
+				   dt_pin_change_ntf);
 
 	return 0;
 }
@@ -249,8 +242,6 @@ static void dt_exit(struct kunit *test)
 
 	if (!ctx)
 		return;
-	if (ctx->nb_registered)
-		unregister_dpll_notifier(&ctx->nb);
 	dt_unreg(&ctx->a0, &ctx->p, &ctx->p_a0);
 	dt_unreg(&ctx->a1, &ctx->p, &ctx->p_a1);
 	dt_unreg(&ctx->a0, &ctx->u, &ctx->u_a0);
diff --git a/include/linux/dpll.h b/include/linux/dpll.h
index 9eccfe41240418..1e5b940a245a7d 100644
--- a/include/linux/dpll.h
+++ b/include/linux/dpll.h
@@ -11,7 +11,6 @@
 #include <linux/device.h>
 #include <linux/netlink.h>
 #include <linux/netdevice.h>
-#include <linux/notifier.h>
 #include <linux/rtnetlink.h>
 #include <net/netlink.h>
 
@@ -211,19 +210,6 @@ typedef struct ref_tracker *dpll_tracker;
 typedef struct {} dpll_tracker;
 #endif
 
-#define DPLL_PIN_CREATED	4
-#define DPLL_PIN_DELETED	5
-#define DPLL_PIN_CHANGED	6
-
-struct dpll_pin_notifier_info {
-	struct dpll_pin *pin;
-	u32 id;
-	u32 idx;
-	u64 clock_id;
-	const struct fwnode_handle *fwnode;
-	const struct dpll_pin_properties *prop;
-};
-
 #if IS_ENABLED(CONFIG_DPLL)
 void dpll_netdev_pin_set(struct net_device *dev, struct dpll_pin *dpll_pin);
 void dpll_netdev_pin_clear(struct net_device *dev);
@@ -306,8 +292,4 @@ int dpll_device_change_ntf(struct dpll_device *dpll);
 int __dpll_pin_change_ntf(struct dpll_pin *pin);
 int dpll_pin_change_ntf(struct dpll_pin *pin);
 
-int register_dpll_notifier(struct notifier_block *nb);
-
-int unregister_dpll_notifier(struct notifier_block *nb);
-
 #endif
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 17/19] dpll: require a registered DPLL for pin registration
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (15 preceding siblings ...)
  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 ` 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
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Since commit 33f016b23a21 ("dpll: fix NULL deref in dpll_device_ops()
during teardown race"), dpll_pin_register() accepts a DPLL without
registrations unless the pin has measured_freq_get, and
dpll_pin_on_pin_register() registers a pin with the DPLLs of the parent
pin without a check.

The drivers register a DPLL before its pins. Reject a DPLL that is not
registered in dpll_pin_register() before its ops are requested, and a
parent pin with such a DPLL in dpll_pin_on_pin_register(), and document
the order.

The pin paths keep the tolerance for a DPLL without registrations from
that commit. On E810, ice registers the recovered clock pin of a PF
without the CGU under the input pins of the PF with the CGU, and so with
its DPLLs. The pin stays registered with them when that PF goes first.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/driver-api/dpll.rst |  2 ++
 drivers/dpll/dpll_core.c          | 17 +++++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/Documentation/driver-api/dpll.rst b/Documentation/driver-api/dpll.rst
index bc34fc83882fac..75ebed0bb95e96 100644
--- a/Documentation/driver-api/dpll.rst
+++ b/Documentation/driver-api/dpll.rst
@@ -634,6 +634,8 @@ of pin callbacks, and private data pointer for calling them:
 - dpll_pin_register() - register pin with a dpll device,
 - dpll_pin_on_pin_register() - register pin with another MUX type pin.
 
+A dpll device is registered before its pins.
+
 Notifications of adding or removing dpll devices are created within
 subsystem itself.
 Notifications about registering/deregistering pins are also invoked by
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index e199342652d163..af61c4882c2b6f 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -925,7 +925,7 @@ __dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
  * @priv: pointer to private information of owner
  *
  * The @dpll and the @pin must have the same owner, they must be created with
- * the same module and clock_id.
+ * the same module and clock_id. The @dpll must be registered.
  *
  * Context: Acquires a lock (dpll_lock)
  * Return:
@@ -951,9 +951,13 @@ dpll_pin_register(struct dpll_device *dpll, struct dpll_pin *pin,
 
 	mutex_lock(&dpll_lock);
 
+	if (ASSERT_DPLL_REGISTERED(dpll)) {
+		ret = -EINVAL;
+		goto out_unlock;
+	}
 	dev_ops = dpll_device_ops(dpll);
 	if (WARN_ON(ops->measured_freq_get &&
-		    (!dev_ops || !dev_ops->freq_monitor_get ||
+		    (!dev_ops->freq_monitor_get ||
 		     !dev_ops->freq_monitor_set))) {
 		ret = -EINVAL;
 		goto out_unlock;
@@ -1039,7 +1043,8 @@ EXPORT_SYMBOL_GPL(dpll_pin_unregister);
  * Register a pin with a parent pin, create references between them and
  * between newly registered pin and dplls connected with a parent pin.
  * The @parent and the @pin must have the same owner, they must be created
- * with the same module and clock_id.
+ * with the same module and clock_id. The dpll devices of the @parent must
+ * be registered.
  *
  * Context: Acquires a lock (dpll_lock)
  * Return:
@@ -1073,7 +1078,11 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin,
 	if (ret)
 		goto unlock;
 	xa_for_each(&parent->dpll_refs, i, ref) {
-		ret = __dpll_pin_register(ref->dpll, pin, ops, priv, parent);
+		if (ASSERT_DPLL_REGISTERED(ref->dpll))
+			ret = -EINVAL;
+		else
+			ret = __dpll_pin_register(ref->dpll, pin, ops, priv,
+						  parent);
 		if (ret) {
 			stop = i;
 			goto dpll_unregister;
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 18/19] dpll: drop the owner reference selection of pins
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (16 preceding siblings ...)
  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 ` Ivan Vecera
  2026-11-26 20:32 ` [PATCH RFC net-next 19/19] dpll: add KUnit tests for the pin owner checks Ivan Vecera
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Commit 2c1bd78dc8e2 ("dpll: use pin owner's dpll ref for pin-level
attribute reporting") and commit 84e85c325e5e ("dpll: use pin owner's
dpll ref for pin-level attribute setting") made the pin-level paths look
for the reference of a DPLL of the pin's owner, because a pin could also
be registered with DPLLs of other owners.

Every DPLL a pin is registered with now has the owner of the pin. Use
the first reference of a registered DPLL and drop
dpll_pin_own_dpll_ref_first().

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/dpll_core.c    | 27 ---------------------------
 drivers/dpll/dpll_core.h    |  1 -
 drivers/dpll/dpll_netlink.c | 20 +++++++++-----------
 3 files changed, 9 insertions(+), 39 deletions(-)

diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index af61c4882c2b6f..a58cd22164f0be 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -1229,33 +1229,6 @@ void *dpll_pin_on_pin_priv(struct dpll_pin *parent,
 	return reg->priv;
 }
 
-/**
- * dpll_pin_own_dpll_ref_first - find the first owner dpll ref of a pin
- * @pin: pointer to a dpll pin
- *
- * Search pin's dpll_refs for a ref whose dpll matches the pin's
- * (module, clock_id) tuple, i.e. the dpll registered by the driver
- * that created the pin. This ensures pin-level attributes are
- * reported and modified using the owner's ops even when the pin is
- * also registered with dplls from other drivers.
- *
- * Return: pointer to the owner's dpll_pin_ref, or NULL if no
- * owner ref is found.
- */
-struct dpll_pin_ref *dpll_pin_own_dpll_ref_first(struct dpll_pin *pin)
-{
-	struct dpll_pin_ref *ref;
-	unsigned long i;
-
-	xa_for_each(&pin->dpll_refs, i, ref) {
-		if (ref->dpll->module == pin->module &&
-		    ref->dpll->clock_id == pin->clock_id)
-			return ref;
-	}
-
-	return NULL;
-}
-
 const struct dpll_pin_ops *dpll_pin_ops(struct dpll_pin_ref *ref)
 {
 	struct dpll_pin_registration *reg;
diff --git a/drivers/dpll/dpll_core.h b/drivers/dpll/dpll_core.h
index 6e10aadd2123d9..add518fef295d8 100644
--- a/drivers/dpll/dpll_core.h
+++ b/drivers/dpll/dpll_core.h
@@ -103,7 +103,6 @@ void *dpll_pin_on_pin_priv(struct dpll_pin *parent, struct dpll_pin *pin);
 
 const struct dpll_device_ops *dpll_device_ops(struct dpll_device *dpll);
 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);
diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
index 6a46130fc687eb..ac341e3eba61ac 100644
--- a/drivers/dpll/dpll_netlink.c
+++ b/drivers/dpll/dpll_netlink.c
@@ -745,9 +745,7 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
 	struct dpll_pin_ref *ref;
 	int ret;
 
-	ref = dpll_pin_own_dpll_ref_first(pin);
-	if (!ref || !dpll_device_registered(ref->dpll))
-		ref = dpll_pin_first_registered_ref(pin);
+	ref = dpll_pin_first_registered_ref(pin);
 	if (!ref)
 		return -ENODEV;
 
@@ -1134,8 +1132,8 @@ dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
 		return -EINVAL;
 	}
 
-	ref = dpll_pin_own_dpll_ref_first(pin);
-	if (!ref || !dpll_device_registered(ref->dpll)) {
+	ref = dpll_pin_first_registered_ref(pin);
+	if (!ref) {
 		NL_SET_ERR_MSG(extack, "pin owner dpll not found");
 		return -ENODEV;
 	}
@@ -1180,8 +1178,8 @@ dpll_pin_esync_set(struct dpll_pin *pin, struct nlattr *a,
 	bool supported = false;
 	int ret, i;
 
-	ref = dpll_pin_own_dpll_ref_first(pin);
-	if (!ref || !dpll_device_registered(ref->dpll)) {
+	ref = dpll_pin_first_registered_ref(pin);
+	if (!ref) {
 		NL_SET_ERR_MSG(extack, "pin owner dpll not found");
 		return -ENODEV;
 	}
@@ -1245,8 +1243,8 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin,
 		NL_SET_ERR_MSG(extack, "reference sync pin not available");
 		return -EINVAL;
 	}
-	ref = dpll_pin_own_dpll_ref_first(pin);
-	if (!ref || !dpll_device_registered(ref->dpll)) {
+	ref = dpll_pin_first_registered_ref(pin);
+	if (!ref) {
 		NL_SET_ERR_MSG(extack, "pin owner dpll not found");
 		return -ENODEV;
 	}
@@ -1458,8 +1456,8 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr,
 		return -EINVAL;
 	}
 
-	ref = dpll_pin_own_dpll_ref_first(pin);
-	if (!ref || !dpll_device_registered(ref->dpll)) {
+	ref = dpll_pin_first_registered_ref(pin);
+	if (!ref) {
 		NL_SET_ERR_MSG(extack, "pin owner dpll not found");
 		return -ENODEV;
 	}
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH RFC net-next 19/19] dpll: add KUnit tests for the pin owner checks
  2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
                   ` (17 preceding siblings ...)
  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 ` Ivan Vecera
  18 siblings, 0 replies; 20+ messages in thread
From: Ivan Vecera @ 2026-11-26 20:32 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Donald Hunter, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	Alexander Lobakin, Richard Cochran, linux-doc, linux-kernel,
	intel-wired-lan, Min Li, Grzegorz Nitka, Karol Kolacinski,
	Saeed Mahameed, Tariq Toukan, Petr Oros

Check that dpll_pin_register() rejects a DPLL of another owner and a
DPLL that is not registered, that dpll_pin_on_pin_register() rejects a
parent pin of another owner and a parent pin registered with a DPLL
that is not registered any more, and that a pin of the owner is still
shared by its DPLLs and registered under its parent pin.

The checks are WARN_ON_ONCE(), so the tests suppress the warning without
counting it. A registration that is not rejected is undone, so the next
case does not get the registered pin and the failure stays in its case.

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/Kconfig            |   4 +-
 drivers/dpll/tests/dpll_kunit.c | 150 +++++++++++++++++++++++++++++---
 2 files changed, 142 insertions(+), 12 deletions(-)

diff --git a/drivers/dpll/Kconfig b/drivers/dpll/Kconfig
index d57696652d450a..9be76330a1d1de 100644
--- a/drivers/dpll/Kconfig
+++ b/drivers/dpll/Kconfig
@@ -31,7 +31,9 @@ config DPLL_KUNIT_TEST
 	help
 	  KUnit tests for the DPLL core. They use a mock driver to check
 	  that links between pins of two devices are reported and notified
-	  while the pins at both ends are registered.
+	  while the pins at both ends are registered, and that a pin is
+	  registered only with the registered devices and the parent pins
+	  of its owner.
 
 	  The mock devices and pins are registered with the DPLL subsystem,
 	  so user space sees them and their create and delete notifications
diff --git a/drivers/dpll/tests/dpll_kunit.c b/drivers/dpll/tests/dpll_kunit.c
index 1804e5836f7db2..20bda0934acb1d 100644
--- a/drivers/dpll/tests/dpll_kunit.c
+++ b/drivers/dpll/tests/dpll_kunit.c
@@ -1,11 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * KUnit tests for links between DPLL pins.
+ * KUnit tests for links between DPLL pins and for the owner checks of pin
+ * registrations.
  *
  * Each test starts with two owners that differ in clock_id:
  *
  * Owner A: devices A0 and A1, pin P with firmware node F, pin U with
- *          neither a firmware node nor a link
+ *          neither a firmware node nor a link, MUX pin M
  * Owner B: device B0, pin C with a link to F
  *
  * The devices are registered, the pins are not.
@@ -40,9 +41,9 @@ struct dt_pin {
 
 struct dt_ctx {
 	struct dt_dev a0, a1, b0;
-	struct dt_pin p, u, c;
+	struct dt_pin p, u, c, m;
 	struct fwnode_handle *fwnode;
-	bool p_a0, p_a1, u_a0, c_b0;	/* registrations */
+	bool p_a0, p_a1, u_a0, c_b0, m_a0, u_m;	/* registrations */
 };
 
 static int dt_mode_get(const struct dpll_device *dpll, void *dpll_priv,
@@ -89,10 +90,29 @@ static const struct dpll_pin_ops dt_pin_ops = {
 	.direction_get = dt_direction_get,
 };
 
+static int dt_state_on_pin_get(const struct dpll_pin *pin, void *pin_priv,
+			       const struct dpll_pin *parent_pin,
+			       void *parent_pin_priv,
+			       enum dpll_pin_state *state,
+			       struct netlink_ext_ack *extack)
+{
+	*state = DPLL_PIN_STATE_CONNECTED;
+	return 0;
+}
+
+static const struct dpll_pin_ops dt_child_ops = {
+	.state_on_pin_get = dt_state_on_pin_get,
+	.direction_get = dt_direction_get,
+};
+
 static const struct dpll_pin_properties dt_pin_prop = {
 	.type = DPLL_PIN_TYPE_EXT,
 };
 
+static const struct dpll_pin_properties dt_mux_prop = {
+	.type = DPLL_PIN_TYPE_MUX,
+};
+
 /* Stub of __dpll_pin_change_ntf() that counts the notifications */
 static int dt_pin_change_ntf(struct dpll_pin *pin)
 {
@@ -130,9 +150,9 @@ static void dt_dev_fini(struct dt_dev *dev)
 }
 
 static void dt_pin_get(struct kunit *test, struct dt_pin *pin, u64 clock_id,
-		       u32 idx)
+		       u32 idx, const struct dpll_pin_properties *prop)
 {
-	pin->pin = dpll_pin_get(clock_id, idx, THIS_MODULE, &dt_pin_prop,
+	pin->pin = dpll_pin_get(clock_id, idx, THIS_MODULE, prop,
 				&pin->tracker);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pin->pin);
 }
@@ -223,9 +243,10 @@ static int dt_init(struct kunit *test)
 	dt_dev_init(test, &ctx->a0, DT_CLOCK_ID_A, 0);
 	dt_dev_init(test, &ctx->a1, DT_CLOCK_ID_A, 1);
 	dt_dev_init(test, &ctx->b0, DT_CLOCK_ID_B, 0);
-	dt_pin_get(test, &ctx->p, DT_CLOCK_ID_A, 0);
-	dt_pin_get(test, &ctx->u, DT_CLOCK_ID_A, 1);
-	dt_pin_get(test, &ctx->c, DT_CLOCK_ID_B, 0);
+	dt_pin_get(test, &ctx->p, DT_CLOCK_ID_A, 0, &dt_pin_prop);
+	dt_pin_get(test, &ctx->u, DT_CLOCK_ID_A, 1, &dt_pin_prop);
+	dt_pin_get(test, &ctx->m, DT_CLOCK_ID_A, 2, &dt_mux_prop);
+	dt_pin_get(test, &ctx->c, DT_CLOCK_ID_B, 0, &dt_pin_prop);
 	dpll_pin_fwnode_set(ctx->p.pin, ctx->fwnode);
 	ret = dpll_pin_link_add(ctx->c.pin, ctx->fwnode);
 	KUNIT_ASSERT_EQ(test, ret, 0);
@@ -242,11 +263,16 @@ static void dt_exit(struct kunit *test)
 
 	if (!ctx)
 		return;
+	if (ctx->u_m)
+		dpll_pin_on_pin_unregister(ctx->m.pin, ctx->u.pin,
+					   &dt_child_ops, &ctx->u);
+	dt_unreg(&ctx->a0, &ctx->m, &ctx->m_a0);
 	dt_unreg(&ctx->a0, &ctx->p, &ctx->p_a0);
 	dt_unreg(&ctx->a1, &ctx->p, &ctx->p_a1);
 	dt_unreg(&ctx->a0, &ctx->u, &ctx->u_a0);
 	dt_unreg(&ctx->b0, &ctx->c, &ctx->c_b0);
 	dt_pin_put(&ctx->c);
+	dt_pin_put(&ctx->m);
 	dt_pin_put(&ctx->u);
 	dt_pin_put(&ctx->p);
 	dt_dev_fini(&ctx->b0);
@@ -404,7 +430,109 @@ static struct kunit_suite dt_suite = {
 	.test_cases = dt_cases,
 };
 
-kunit_test_suite(dt_suite);
+/*
+ * The checks are WARN_ON_ONCE(), so the tests suppress the warning without
+ * counting it. A registration that is not rejected is undone, otherwise the
+ * next case would get the registered pin from dpll_pin_get() and fail too.
+ */
+
+/* Expect the registration of @pin with @dev to be rejected */
+static void dt_expect_reg_rejected(struct kunit *test, struct dt_dev *dev,
+				   struct dt_pin *pin)
+{
+	int ret;
+
+	kunit_warning_suppress(test) {
+		ret = dpll_pin_register(dev->dpll, pin->pin, &dt_pin_ops, pin);
+		KUNIT_EXPECT_EQ(test, ret, -EINVAL);
+		if (!ret)
+			dpll_pin_unregister(dev->dpll, pin->pin, &dt_pin_ops,
+					    pin);
+	}
+}
+
+/* Expect the registration of @pin under @parent to be rejected */
+static void dt_expect_on_pin_rejected(struct kunit *test,
+				      struct dt_pin *parent,
+				      struct dt_pin *pin)
+{
+	int ret;
+
+	kunit_warning_suppress(test) {
+		ret = dpll_pin_on_pin_register(parent->pin, pin->pin,
+					       &dt_child_ops, pin);
+		KUNIT_EXPECT_EQ(test, ret, -EINVAL);
+		if (!ret)
+			dpll_pin_on_pin_unregister(parent->pin, pin->pin,
+						   &dt_child_ops, pin);
+	}
+}
+
+/* A pin is registered with the DPLLs of its owner only */
+static void dt_test_owner_register(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	dt_expect_reg_rejected(test, &ctx->b0, &ctx->p);
+	dt_reg(test, &ctx->a0, &ctx->p, &ctx->p_a0);
+	dt_reg(test, &ctx->a1, &ctx->p, &ctx->p_a1);
+}
+
+/* A pin is registered under the parent pins of its owner only */
+static void dt_test_owner_on_pin(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+	int ret;
+
+	dt_reg(test, &ctx->a0, &ctx->m, &ctx->m_a0);
+	dt_expect_on_pin_rejected(test, &ctx->m, &ctx->c);
+
+	ret = dpll_pin_on_pin_register(ctx->m.pin, ctx->u.pin, &dt_child_ops,
+				       &ctx->u);
+	KUNIT_ASSERT_EQ(test, ret, 0);
+	ctx->u_m = true;
+}
+
+/* A pin is registered with a registered DPLL only */
+static void dt_test_unregistered_dpll(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+	struct dt_dev a2 = {};
+
+	a2.dpll = dpll_device_get(DT_CLOCK_ID_A, 2, THIS_MODULE, &a2.tracker);
+	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a2.dpll);
+	dt_expect_reg_rejected(test, &a2, &ctx->p);
+	dt_dev_fini(&a2);
+}
+
+/* A pin is registered under a parent pin with registered DPLLs only */
+static void dt_test_unregistered_parent_dpll(struct kunit *test)
+{
+	struct dt_ctx *ctx = test->priv;
+
+	/* The parent pin stays registered with a0 after a0 goes, as on E810 */
+	dt_reg(test, &ctx->a0, &ctx->m, &ctx->m_a0);
+	dpll_device_unregister(ctx->a0.dpll, &dt_dev_ops, &ctx->a0);
+	ctx->a0.registered = false;
+	dt_expect_on_pin_rejected(test, &ctx->m, &ctx->u);
+}
+
+static struct kunit_case dt_owner_cases[] = {
+	KUNIT_CASE(dt_test_owner_register),
+	KUNIT_CASE(dt_test_owner_on_pin),
+	KUNIT_CASE(dt_test_unregistered_dpll),
+	KUNIT_CASE(dt_test_unregistered_parent_dpll),
+	{}
+};
+
+static struct kunit_suite dt_owner_suite = {
+	.name = "dpll_pin_owner",
+	.init = dt_init,
+	.exit = dt_exit,
+	.test_cases = dt_owner_cases,
+};
+
+kunit_test_suites(&dt_suite, &dt_owner_suite);
 
-MODULE_DESCRIPTION("KUnit tests for links between DPLL pins");
+MODULE_DESCRIPTION("KUnit tests for links and owners of DPLL pins");
 MODULE_LICENSE("GPL");
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2026-11-26 20:34 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH RFC net-next 02/19] dpll: report " Ivan Vecera
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox