From: Jacob Keller <jacob.e.keller@intel.com>
To: <netdev-bot+sashiko@kernel.org>, <anthony.l.nguyen@intel.com>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <pabeni@redhat.com>,
<edumazet@kernel.org>, <andrew+netdev@lunn.ch>,
<netdev@vger.kernel.org>, <poros@redhat.com>,
<maciej.machnikowski@intel.com>, <przemyslaw.korba@intel.com>,
<grzegorz.nitka@intel.com>, <sergey.temerkhanov@intel.com>,
<arkadiusz.kubalewski@intel.com>, <richardcochran@gmail.com>,
<horms@kernel.org>
Subject: Re: [PATCH net v3 02/14] ice: use reference counting and SRCU for PTP port access
Date: Mon, 19 Oct 2026 16:16:37 -0700 [thread overview]
Message-ID: <cadf7730-3d9e-4d45-acf3-ee235fa64fd4@intel.com> (raw)
In-Reply-To: <179244084232.3135.1622859924790214166@kernel.org>
On 10/19/2026 1:14 PM, netdev-bot+sashiko@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found more severe
> issue(s) in other patches of this series. This mail is only an FYI, in case
> you want to address the nit picks below when you respin.
>
> Low priority / nit picks for your consideration:
>
> - [Low] drivers/net/ethernet/intel/ice/ice_adapter.h now embeds `struct
> srcu_struct srcu` by value in `struct ice_port_list` (line 32).
>
> Pre-existing issues:
> - [Medium] ice_ptp_prepare_rebuild_sec() (E825C owner reset path) holds
> only an SRCU read section and a kref on the peer port when it calls…
>
> --
>
> ice: use reference counting and SRCU for PTP port access
>
> This commit replaces the mutex-protected adapter port list with an SRCU
> protected list plus a spinlock for writers. It also adds a kref to each
> ice_ptp_port. Readers take the kref with kref_get_unless_zero(), and
> ice_ptp_cleanup_pf() waits for the last reference to drop before it calls
> synchronize_srcu().
>
>> diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.h b/drivers/net/ethernet/intel/ice/ice_adapter.h
>> index 4f695f32da3d8..0b01c7f5cf0da 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_adapter.h
>> +++ b/drivers/net/ethernet/intel/ice/ice_adapter.h
>> @@ -17,15 +17,19 @@ struct ice_pf;
>
> [ ... ]
>
>> struct ice_port_list {
>> - struct list_head ports;
>> - /* To synchronize the ports list operations */
>> - struct mutex lock;
>> + struct list_head list;
>> + /* To synchronize write operations on the port list */
>> + spinlock_t lock;
>> + struct srcu_struct srcu;
>
> [Severity: Low]
> Should ice_adapter.h include <linux/srcu.h> itself? struct ice_port_list
> now embeds struct srcu_struct by value, so it needs the complete type. The
> header only pulls in:
>
> #include <linux/types.h>
> #include <linux/mutex.h>
> #include <linux/spinlock_types.h>
> #include <linux/refcount_types.h>
>
> #include "ice_type.h"
>
> The patch adds <linux/srcu.h> to ice_adapter.c and ice_ptp.c instead. The
> header seems to build today only through a transitive chain:
>
> ice_type.h -> ice_osdep.h -> <net/udp_tunnel.h> -> ... -> <linux/notifier.h>
>
> and notifier.h is what includes <linux/srcu.h>.
>
> In the same patch, ice_ptp.h does get <linux/kref.h> for its new struct
> kref member.
>
If we need a respin I can fix this, otherwise I would prefer to follow
up with a cleanup, as this series has already taken a long time :/
>> };
>>
>> /**
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> index e1c66cd0f94ff..55241802d17ae 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
>
> [ ... ]
>
>> @@ -2890,14 +2934,18 @@ void ice_ptp_queue_work(struct ice_pf *pf)
>> static void ice_ptp_prepare_rebuild_sec(struct ice_pf *pf, bool rebuild,
>> enum ice_reset_req reset_type)
>> {
>
> [ ... ]
>
>> + srcu_idx = srcu_read_lock(&ports->srcu);
>> + list_for_each_entry_srcu(port, &ports->list, list_node,
>> + srcu_read_lock_held(&ports->srcu)) {
>> struct ice_pf *peer_pf = ptp_port_to_pf(port);
>>
>> + if (!kref_get_unless_zero(&port->ref))
>> + continue;
>> +
>> if (!ice_is_primary(&peer_pf->hw)) {
>> if (rebuild) {
>> /* TODO: When implementing rebuild=true:
>> @@ -2909,7 +2957,10 @@ static void ice_ptp_prepare_rebuild_sec(struct ice_pf *pf, bool rebuild,
>> ice_ptp_prepare_for_reset(peer_pf, reset_type);
>
> [Severity: Medium]
> This is a pre-existing issue, not one introduced by this patch. Can this
> call to ice_ptp_prepare_for_reset(peer_pf) race with the peer PF's own
> ice_ptp_release()?
>
> Here the owner holds only an SRCU read section and a kref on the peer
> port. ice_ptp_prepare_for_reset() then reads and writes peer_pf->ptp.state
> with no lock held:
>
> if (ptp->state != ICE_PTP_READY)
> return;
>
> ptp->state = ICE_PTP_RESETTING;
>
> /* Disable timestamping for both Tx and Rx */
> ice_ptp_disable_timestamp_mode(pf);
>
> kthread_cancel_delayed_work_sync(&ptp->work);
>
> At the same time, the peer can be in the READY path of ice_ptp_release().
> That path does the following before it reaches ice_ptp_cleanup_pf():
>
> pf->ptp.state = ICE_PTP_UNINIT;
>
> /* Disable timestamping for both Tx and Rx */
> ice_ptp_disable_timestamp_mode(pf);
>
> ice_ptp_cleanup_pf(pf);
>
> One possible interleaving:
>
> owner (E825C reset) peer PF (unbind/remove)
> ice_ptp_prepare_rebuild_sec()
> kref_get_unless_zero() succeeds
> ice_ptp_prepare_for_reset(peer_pf)
> sees state == ICE_PTP_READY
> ice_ptp_release()
> state = ICE_PTP_UNINIT
> ice_ptp_disable_timestamp_mode()
> state = ICE_PTP_RESETTING
> ice_ptp_disable_timestamp_mode()
>
> Could the peer then be torn down with ptp.state left at ICE_PTP_RESETTING
> instead of ICE_PTP_UNINIT? Both sides would also run
> ice_ptp_disable_timestamp_mode() with nothing ordering them.
>
> The new kref wait in ice_ptp_cleanup_pf() keeps the peer's kworker and Tx
> tracker alive until the owner drops its reference, so the earlier
> use-after-free window looks closed.
>
> Before this patch, the same call ran with no locking at all. The commit
> message also limits its scope to the port list.
>
This whole peer_pf stuff needs some investigation. I think its partly
being addressed by the work on ctrl_ptp/ctrl_pf being done, but I'm not
sure. Either way I don't believe it makes sense to address it in this
series.
> ^ permalink raw reply
>
next prev parent reply other threads:[~2026-10-19 23:16 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 19:10 [PATCH net v3 00/14][pull request] ice: E82x: timestamp processing logic fixes Tony Nguyen
2026-10-15 19:10 ` [PATCH net v3 01/14] ice: fix removal of PTP timestamp tracker during reset Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:14 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 02/14] ice: use reference counting and SRCU for PTP port access Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:16 ` Jacob Keller [this message]
2026-10-15 19:10 ` [PATCH net v3 03/14] ice: fix PHY port restart serialization Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:21 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 04/14] ice: set in_use only after preparing Tx timestamp index Tony Nguyen
2026-10-15 19:10 ` [PATCH net v3 05/14] ice: call PTP link change only from link events Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:35 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 06/14] ice: E822: keep Tx timestamps disabled during offset calibration Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:37 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 07/14] ice: E822: cancel offset verification work during reset preparation Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:40 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 08/14] ice: E825: stop clearing PHY_REG_TX_OFFSET_READY Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:42 ` Jacob Keller
2026-10-20 1:53 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 09/14] ice: E825: clear PHY_TSTAMP memory prior to soft reset Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:49 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 10/14] ice: E825: perform a soft reset when starting the PHY timer Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-19 23:57 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 11/14] ice: wait for in-flight Tx timestamps before removing the tracker Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-20 0:05 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 12/14] ice: keep Tx timestamp slots tracked until completion or timeout Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-20 0:11 ` Jacob Keller
2026-10-15 19:10 ` [PATCH net v3 13/14] ice: skip reading Tx ready bitmap on ports with no timestamps Tony Nguyen
2026-10-15 19:11 ` [PATCH net v3 14/14] ice: don't clear in_use until HW clears ready bitmap Tony Nguyen
2026-10-19 20:14 ` netdev-bot+sashiko
2026-10-20 0:18 ` Jacob Keller
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=cadf7730-3d9e-4d45-acf3-ee235fa64fd4@intel.com \
--to=jacob.e.keller@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=grzegorz.nitka@intel.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=maciej.machnikowski@intel.com \
--cc=netdev-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.korba@intel.com \
--cc=richardcochran@gmail.com \
--cc=sergey.temerkhanov@intel.com \
/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