From: Jakub Kicinski <kuba@kernel.org>
To: ivecera@redhat.com
Cc: Jakub Kicinski <kuba@kernel.org>,
conor+dt@kernel.org, poros@redhat.com,
anthony.l.nguyen@intel.com, linux-rdma@vger.kernel.org,
tariqt@nvidia.com, robh@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, aleksander.lobakin@intel.com,
mbloch@nvidia.com, jiri@resnulli.us,
Prathosh.Satish@microchip.com, krzk+dt@kernel.org,
saeedm@nvidia.com, devicetree@vger.kernel.org,
davem@davemloft.net, pabeni@redhat.com,
przemyslaw.kitszel@intel.com, arkadiusz.kubalewski@intel.com,
jonathan.lemon@gmail.com, saravanak@kernel.org,
aleksandr.loktionov@intel.com, mschmidt@redhat.com,
edumazet@google.com, leon@kernel.org, vadim.fedorenko@linux.dev,
grzegorz.nitka@intel.com, intel-wired-lan@lists.osuosl.org,
richardcochran@gmail.com, andrew+netdev@lunn.ch
Subject: Re: [net-next,v2,08/12] dpll: Enhance and consolidate reference counting logic
Date: Tue, 20 Jan 2026 16:16:51 -0800 [thread overview]
Message-ID: <20260121001650.1904392-2-kuba@kernel.org> (raw)
In-Reply-To: <20260116184610.147591-9-ivecera@redhat.com>
This is an AI-generated review of your patch.
Dunno if there's a reason for having this fixed by a later patch,
if not let's fix. I'm sending the review mostly because of the
comments on patch 12.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
dpll: Enhance and consolidate reference counting logic
This commit refactors DPLL reference counting by introducing centralized
__dpll_{device,pin}_{hold,put}() helpers and updating dpll_xa_ref_*
functions to automatically manage references when adding/removing entries.
> diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
> index 156f95de8e8e..f2a77eb1b991 100644
[ ... ]
> @@ -155,6 +194,7 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
> reg->ops = ops;
> reg->priv = priv;
> reg->cookie = cookie;
> + __dpll_pin_hold(pin);
> if (ref_exists)
> refcount_inc(&ref->refcount);
> list_add_tail(®->list, &ref->registration_list);
The new __dpll_pin_hold(pin) call is added here for the success path, but
looking at the context above this hunk, there is an early return path when
a duplicate registration is found:
reg = dpll_pin_registration_find(ref, ops, priv, cookie);
if (reg) {
refcount_inc(&ref->refcount);
return 0;
}
This early return path increments ref->refcount and returns success, but
does not call __dpll_pin_hold(pin). Meanwhile, dpll_xa_ref_pin_del() always
calls __dpll_pin_put(pin). Could this cause a refcount underflow if a caller
attempts duplicate registration and then later unregistration is attempted?
Note: This appears to be addressed by 934c22045c2a ("dpll: Prevent duplicate
registrations") later in the series, which changes this early return to
return -EEXIST instead of success.
[ ... ]
> @@ -236,6 +277,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
> reg->ops = ops;
> reg->priv = priv;
> reg->cookie = cookie;
> + __dpll_device_hold(dpll);
> if (ref_exists)
> refcount_inc(&ref->refcount);
> list_add_tail(®->list, &ref->registration_list);
The same pattern exists in dpll_xa_ref_dpll_add(): the early return path for
duplicate registrations increments ref->refcount without calling
__dpll_device_hold(dpll), while dpll_xa_ref_dpll_del() always calls
__dpll_device_put(dpll). The same fix in 934c22045c2a addresses this.
--
pw-bot: cr
next prev parent reply other threads:[~2026-01-21 0:18 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 18:45 [PATCH net-next v2 00/12] dpll: Core improvements and ice E825-C SyncE support Ivan Vecera
2026-01-16 18:45 ` [PATCH net-next v2 01/12] dt-bindings: dpll: support acting as pin provider Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 02/12] dpll: Allow associating dpll pin with a firmware node Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 03/12] dpll: Add helpers to find DPLL pin fwnode Ivan Vecera
2026-02-08 1:46 ` Saravana Kannan
2026-02-10 7:19 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 04/12] dpll: zl3073x: Associate pin with fwnode handle Ivan Vecera
2026-01-19 7:49 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 05/12] dpll: Add notifier chain for dpll events Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 06/12] dpll: Support dynamic pin index allocation Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 07/12] dpll: zl3073x: Add support for mux pin type Ivan Vecera
2026-01-19 7:50 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 08/12] dpll: Enhance and consolidate reference counting logic Ivan Vecera
2026-01-21 0:16 ` Jakub Kicinski [this message]
2026-01-21 8:18 ` [net-next,v2,08/12] " Ivan Vecera
2026-01-23 14:58 ` Simon Horman
2026-01-23 15:27 ` Ivan Vecera
2026-01-23 18:04 ` Simon Horman
2026-01-16 18:46 ` [PATCH net-next v2 09/12] dpll: Prevent duplicate registrations Ivan Vecera
2026-01-19 7:50 ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-16 18:46 ` [PATCH net-next v2 10/12] dpll: Add reference count tracking support Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 11/12] drivers: Add support for DPLL reference count tracking Ivan Vecera
2026-01-16 18:46 ` [PATCH net-next v2 12/12] ice: dpll: Support E825-C SyncE and dynamic pin discovery Ivan Vecera
2026-01-21 0:18 ` [net-next,v2,12/12] " Jakub Kicinski
2026-01-21 14:20 ` Nitka, Grzegorz
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=20260121001650.1904392-2-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=Prathosh.Satish@microchip.com \
--cc=aleksander.lobakin@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=grzegorz.nitka@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=ivecera@redhat.com \
--cc=jiri@resnulli.us \
--cc=jonathan.lemon@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=saeedm@nvidia.com \
--cc=saravanak@kernel.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