From: Jacob Keller <jacob.e.keller@intel.com>
To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
Cc: <netdev@vger.kernel.org>,
Maciej Machnikowski <maciej.machnikowski@intel.com>,
Anthony Nguyen <anthony.l.nguyen@intel.com>,
Przemyslaw Korba <przemyslaw.korba@intel.com>,
Grzegorz Nitka <grzegorz.nitka@intel.com>,
Petr Oros <poros@redhat.com>, <alexander.nowlin@intel.com>,
<kevin.bross@intel.com>, <ranjit.cavatur@intel.com>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Subject: Re: [PATCH iwl-net 04/12] ice: call PTP link change only from link events
Date: Mon, 24 Aug 2026 16:48:31 -0700 [thread overview]
Message-ID: <fe1d1e1f-be5f-40b8-8b2c-f3b13cb75309@intel.com> (raw)
In-Reply-To: <20260821-jk-e825c-minimized-fixes-v1-4-9d0731eb4858@intel.com>
On 8/21/2026 5:13 PM, Jacob Keller wrote:
> From: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
>
> Remove redundant ice_ptp_link_change() calls from ice_up_complete() and
> ice_down(). These duplicate the call already made from
> ice_handle_link_event(), creating three problems:
>
> 1. Double initialization on link-up: ice_handle_link_event() calls
> ice_ptp_link_change(true), then ice_up_complete() calls it again.
> The second call re-enters ice_ptp_port_phy_restart(), re-setting the
> calibrating flag and restarting the PHY timer while the first
> invocation's offset verification work (ov_work) may still be running.
>
> 2. Premature cleanup on administrative down: ice_down() calls
> ice_ptp_link_change(false) during ifconfig down or reset preparation,
> even when the physical link is still up. This clears timestamp state
> unnecessarily and can interfere with ongoing PTP operations.
>
> 3. Ordering dependency: ice_down()/ice_up_complete() are called during
> reset sequences where PTP may not be fully initialized, creating
> edge cases with partially configured state.
>
> The link event handler is the correct and sufficient place to drive PTP
> link state changes, as it reflects actual physical link transitions. Remove
> the calls of ice_ptp_link_change from the ice_down()/ice_up() flows.
>
> Initialize the link_up in ice_ptp_init() and ensure that we check and
> restore the link status at the end of the rebuild flow, ensuring that we
> initialize the PHY timer appropriately after a reset.
>
> Fixes: 6b1ff5d39228 ("ice: always call ice_ptp_link_change and make it void")
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
> Signed-off-by: Przemyslaw Korba <przemyslaw.korba@intel.com>
> Signed-off-by: Petr Oros <poros@redhat.com>
> Reviewed-by: Maciek Machnikowski <maciej.machnikowski@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_main.c | 11 +++++++--
> drivers/net/ethernet/intel/ice/ice_ptp.c | 38 +++++++++++++++++++++++--------
> 2 files changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index d88835482d3a..bb631ae9e67d 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -7794,6 +7792,15 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
>
> ice_update_pf_netdev_link(pf);
>
> + if (test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags) && pf->hw.port_info) {
> + bool link_up;
> +
> + link_up = !!(pf->hw.port_info->phy.link_info.link_info &
> + ICE_AQ_LINK_UP);
> + if (pf->ptp.port.link_up != link_up)
> + ice_ptp_link_change(pf, link_up);
> + }
> +
Sashiko says:
> Does conditionally skipping ice_ptp_link_change() here leave the non-owner PF
> PHY timer stopped indefinitely after a global reset if the link remains up?
> During a global reset (like EMPR or GLOBR), concurrent rebuilds are triggered
> across all PFs. The clock-owner PF iterates over all adapter ports in
> ice_ptp_rebuild_owner() and calls ice_ptp_port_phy_restart().
> If the clock-owner PF executes this before a non-owner PF has finished
> ice_init_all_ctrlq() or cleared its reset state, the SBQ command fails.
> Previously, the unconditional call to ice_ptp_link_change() masked this race
> by forcing a successful retry. Since ice_down() no longer clears link_up, and
> the physical link may stay UP across the reset, the condition
> pf->ptp.port.link_up != link_up will evaluate to false, leaving the non-owner
> PF's PHY timer stopped indefinitely.
I think this is correct. We need to ensure that we restart the PHY
somewhere in the chain after the CQ is active and the timer has been
reconfigured by the clock owner. Will investigate.
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index b8647a39db6d..8aa49dda90a2 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -1327,14 +1327,14 @@ void ice_ptp_link_change(struct ice_pf *pf, bool linkup)
> struct ice_ptp_port *ptp_port;
> struct ice_hw *hw = &pf->hw;
>
> - if (pf->ptp.state != ICE_PTP_READY)
> - return;
> -
> ptp_port = &pf->ptp.port;
>
> /* Update cached link status for this port immediately */
> ptp_port->link_up = linkup;
>
> + if (pf->ptp.state != ICE_PTP_READY)
> + return;
> +
Sashiko says:
> This is a pre-existing issue, but is there a Time-of-Check to Time-of-Use
> (TOCTOU) race between checking ICE_PTP_READY here and module unload?
> In ice_remove(), ice_unload() is called which invokes ice_ptp_release().
> This destroys the PTP port mutex and the kworker. However, the background
> service task is not stopped until ice_deinit_dev() is called much later.
> If the service task processes a link event concurrently, ice_ptp_link_change()
> checks ICE_PTP_READY without synchronization. If preempted immediately after
> this check, ice_ptp_release() can destroy the resources.
> When ice_ptp_link_change() resumes, it calls ice_ptp_port_phy_restart()
> which attempts to acquire the destroyed ps_lock and queues work on the freed
> kworker, potentially causing a use-after-free or NULL pointer dereference.
I think this is best fixed by having ice_ptp_link_change acquire a
reference using the kref in the first patch to ensure that the port
can't be removed until the function exits. Will fix this in the first patch.
next prev parent reply other threads:[~2026-08-24 23:48 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 0:13 [PATCH iwl-net 00/12] ice: E82x: timestamp processing logic fixes Jacob Keller
2026-08-22 0:13 ` [PATCH iwl-net 01/12] ice: use reference counting and RCU for PTP port access Jacob Keller
2026-08-22 4:11 ` Nowlin, Alexander
2026-08-24 23:36 ` Jacob Keller
2026-08-22 0:13 ` [PATCH iwl-net 02/12] ice: E822: keep Tx timestamps disabled during offset calibration Jacob Keller
2026-08-22 4:13 ` Nowlin, Alexander
2026-08-24 23:39 ` Jacob Keller
2026-08-22 0:13 ` [PATCH iwl-net 03/12] ice: E822: cancel offset verification work during reset preparation Jacob Keller
2026-08-22 4:14 ` Nowlin, Alexander
2026-08-22 0:13 ` [PATCH iwl-net 04/12] ice: call PTP link change only from link events Jacob Keller
2026-08-22 4:15 ` Nowlin, Alexander
2026-08-24 23:48 ` Jacob Keller [this message]
2026-08-22 0:13 ` [PATCH iwl-net 05/12] ice: E825: stop clearing PHY_REG_TX_OFFSET_READY Jacob Keller
2026-08-22 4:16 ` Nowlin, Alexander
2026-08-22 0:13 ` [PATCH iwl-net 06/12] ice: E825: clear PHY_REG_TX_MEMORY_STATUS prior to soft reset Jacob Keller
2026-08-22 4:16 ` Nowlin, Alexander
2026-08-24 9:29 ` Loktionov, Aleksandr
2026-08-24 23:51 ` Jacob Keller
2026-08-22 0:13 ` [PATCH iwl-net 07/12] ice: E825: perform a soft reset when starting the PHY timer Jacob Keller
2026-08-22 4:17 ` Nowlin, Alexander
2026-08-24 23:54 ` Jacob Keller
2026-08-22 0:13 ` [PATCH iwl-net 08/12] ice: wait for in-flight Tx timestamps before flushing the tracker Jacob Keller
2026-08-22 4:17 ` Nowlin, Alexander
2026-08-25 0:09 ` Jacob Keller
2026-08-22 0:13 ` [PATCH iwl-net 09/12] ice: keep Tx timestamp slots tracked until completion or timeout Jacob Keller
2026-08-22 4:18 ` Nowlin, Alexander
2026-08-25 0:11 ` Jacob Keller
[not found] ` <20260821-jk-e825c-minimized-fixes-v1-10-9d0731eb4858@intel.com>
2026-08-22 4:19 ` [PATCH iwl-net 10/12] ice: remove unnecessary discarding of timestamps after clock adjust Nowlin, Alexander
2026-08-25 0:17 ` Jacob Keller
[not found] ` <20260821-jk-e825c-minimized-fixes-v1-11-9d0731eb4858@intel.com>
2026-08-22 4:19 ` [PATCH iwl-net 11/12] ice: skip reading Tx ready bitmap on ports with no timestamps Nowlin, Alexander
2026-08-25 0:24 ` Jacob Keller
[not found] ` <20260821-jk-e825c-minimized-fixes-v1-12-9d0731eb4858@intel.com>
2026-08-22 4:20 ` [PATCH iwl-net 12/12] ice: don't clear in_use until HW clears ready bitmap Nowlin, Alexander
2026-08-24 10:09 ` Loktionov, Aleksandr
2026-08-25 0:36 ` 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=fe1d1e1f-be5f-40b8-8b2c-f3b13cb75309@intel.com \
--to=jacob.e.keller@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=alexander.nowlin@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=grzegorz.nitka@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=kevin.bross@intel.com \
--cc=maciej.machnikowski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=poros@redhat.com \
--cc=przemyslaw.korba@intel.com \
--cc=ranjit.cavatur@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