From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
Tony Nguyen <anthony.l.nguyen@intel.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Richard Cochran <richardcochran@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
intel-wired-lan@lists.osuosl.org, Min Li <min.li@microchip.com>,
Grzegorz Nitka <grzegorz.nitka@intel.com>,
Karol Kolacinski <karol.kolacinski@intel.com>,
Saeed Mahameed <saeedm@nvidia.com>,
Tariq Toukan <tariqt@nvidia.com>, Petr Oros <poros@redhat.com>
Subject: [PATCH RFC net-next 01/19] dpll: add pin links
Date: Thu, 26 Nov 2026 21:32:13 +0100 [thread overview]
Message-ID: <20261126203231.934632-2-ivecera@redhat.com> (raw)
In-Reply-To: <20261126203231.934632-1-ivecera@redhat.com>
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
next prev parent reply other threads:[~2026-11-26 20:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
2026-11-26 20:32 ` Ivan Vecera [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261126203231.934632-2-ivecera@redhat.com \
--to=ivecera@redhat.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@kernel.org \
--cc=grzegorz.nitka@intel.com \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jiri@resnulli.us \
--cc=karol.kolacinski@intel.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=min.li@microchip.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.com \
--cc=saeedm@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=tariqt@nvidia.com \
--cc=vadim.fedorenko@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox