Netdev List
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Jakub Kicinski <kuba@kernel.org>, <anthony.l.nguyen@intel.com>
Cc: <davem@davemloft.net>, <pabeni@redhat.com>, <edumazet@google.com>,
	<andrew+netdev@lunn.ch>, <netdev@vger.kernel.org>,
	<maciej.machnikowski@intel.com>, <przemyslaw.korba@intel.com>,
	<grzegorz.nitka@intel.com>, <sergey.temerkhanov@intel.com>,
	<arkadiusz.kubalewski@intel.com>, <poros@redhat.com>,
	<richardcochran@gmail.com>, <horms@kernel.org>,
	<pmenzel@molgen.mpg.de>, <aleksandr.loktionov@intel.com>,
	<alexander.nowlin@intel.com>
Subject: Re: [PATCH net 05/15] ice: E822: cancel offset verification work during reset preparation
Date: Thu, 17 Sep 2026 09:31:56 -0700	[thread overview]
Message-ID: <098b8650-1c43-41d5-b0e5-bc8d73cadfc4@intel.com> (raw)
In-Reply-To: <20260916011216.1632452-1-kuba@kernel.org>

On 9/15/2026 6:12 PM, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> ice: E822: cancel offset verification work during reset preparation
> 
> This adds a kthread_cancel_delayed_work_sync() of the E82x offset
> verification work (ov_work) to ice_ptp_prepare_for_reset(), so that the
> work does not run while the PTP reset sequence executes.  A few questions
> about the changelog and about the placement of the new cancel.
> 
> First, on the described failure mechanism:
> 
>> Without this, ice_ptp_wait_for_offsets() can execute during a reset,
>> find that ice_is_reset_in_progress() is true, and re-queue itself in a
>> tight loop. Meanwhile, the reset path in ice_ptp_rebuild_owner() calls
>> ice_ptp_port_phy_restart(), which starts a new ov_work. This results in
>> two ov_work instances running simultaneously, racing over the PHY offset
>> registers and the calibrating flag.
> 
> [Severity: Medium]
> Can this sequence happen as described?  ov_work is a single
> struct kthread_delayed_work per port (ice_ptp.h, struct ice_ptp_port) run
> by one per-PF kworker, so the same work item cannot execute twice at once.
> 
> The re-queue in ice_ptp_wait_for_offsets() also does not look like a tight
> loop, and it returns before touching the PHY offset registers or
> port->tx.calibrating:
> 
> 	if (ice_is_reset_in_progress(pf->state)) {
> 		/* wait for device driver to complete reset */
> 		kthread_queue_delayed_work(pf->ptp.kworker,
> 					   &port->ov_work,
> 					   msecs_to_jiffies(100));
> 		return;
> 	}
> 
> And ice_ptp_port_phy_restart(), the only site that arms ov_work, already
> cancel-syncs it under ps_lock before queueing again:
> 
> 	kthread_cancel_delayed_work_sync(&ptp_port->ov_work);
> 	...
> 	kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0);
> 
> Could the changelog describe the actual window instead, for example a
> worker instance that already passed the reset-in-progress check and is
> mid-PHY-access when the reset starts, or one that gets re-armed after the
> new cancel?
> 

Hm. I'll update the commit message.

> Second, on the Fixes tag:
> 
>> Fixes: 4809671015a1 ("ice: Fix E810 PTP reset flow")
> 
> [Severity: Medium]
> Is this the right commit to reference?  git grep ov_work at 4809671015a1
> under drivers/net/ethernet/intel/ice/ returns no matches, so the E82x
> offset verification work did not exist yet at that commit, and the code
> being changed here is the ICE_MAC_GENERIC branch of the PTP reset flow
> rather than the E810 reset flow.  Stable tooling will use this tag to pick
> backport targets.
> 

I'll check. I'm not sure how the original author landed on this commit.

> Third, on the reference to an existing cancellation:
> 
>> Cancel ov_work in ice_ptp_prepare_for_reset() alongside the existing
>> cancellation of the Tx tracker. The comment in the existing code already
>> documents that ov_work interference during reset is a concern but only
>> cancels it during ice_ptp_release().
> 
> [Severity: Medium]
> Does ice_ptp_prepare_for_reset() still release the Tx tracker in this
> tree?  The ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx) call that used
> to be there was removed by the earlier patch in this series, "ice: fix
> removal of PTP timestamp tracker during reset", so there is nothing left
> in that function to cancel ov_work "alongside".
> 
> Which existing comment documents ov_work interference during reset?  At the
> series baseline the only ov_work-adjacent comments are "Start the PHY timer
> in Vernier mode" and "temporarily disable Tx timestamps while calibrating
> PHY offset", and neither mentions reset.
> 
>> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> index d018f02f700d7..9bf3bac552f11 100644
>> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
>> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
>> @@ -2998,6 +2998,14 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
>>  	if (reset_type == ICE_RESET_PFR)
>>  		return;
>>  
>> +	/* Cancel the offset verification work for E82x before releasing the
>> +	 * Tx tracker. If ov_work is running during reset, it may issue
>> +	 * sideband queue commands that will fail or timeout, and may
>> +	 * reference state that is being torn down.
>> +	 */
> 
> [Severity: Medium]
> Same point as above for the comment text itself: ice_ptp_prepare_for_reset()
> does not release the Tx tracker anymore, so "before releasing the Tx
> tracker" describes an ordering that does not exist here.  The only
> remaining ice_ptp_release_tx_tracker() call is in ice_ptp_release(), and
> there it runs before the ICE_MAC_GENERIC ov_work cancel reached via
> ice_ptp_port_phy_stop(), i.e. the reverse order.  Would it be clearer to
> drop that clause?
> 

Yes.

> The second sentence also mentions sideband queue commands, but
> ice_ptp_wait_for_offsets() returns as soon as ice_is_reset_in_progress() is
> true, before any sideband access.  Which state that is being torn down does
> the work reference?
> 
>> +	if (hw->mac_type == ICE_MAC_GENERIC)
>> +		kthread_cancel_delayed_work_sync(&ptp->port.ov_work);
> 
> [Severity: High]
> Should this cancel be taken under ptp->port.ps_lock?  Both existing
> ov_work cancel sites hold it, and ice_ptp_port_phy_restart() holds it
> across cancel, PHY start and re-queue:
> 
> 	mutex_lock(&ptp_port->ps_lock);
> 	...
> 	kthread_cancel_delayed_work_sync(&ptp_port->ov_work);
> 	...
> 	err = ice_start_phy_timer_e82x(hw, port);
> 	...
> 	kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0);
> 
> Without ps_lock here, can ov_work be armed again right after the sync
> cancel returns, so the reset sequence still runs with ov_work queued?
> 
> Two arming paths look reachable during the reset window.  One is the
> PTP_CLOCK_SETTIME ioctl, which has no ptp->state or reset-in-progress
> check:
> 
> ice_ptp_settime64()
> 	/* Recalibrate and re-enable timestamp blocks for E822/E823 */
> 	if (hw->mac_type == ICE_MAC_GENERIC)
> 		ice_ptp_restart_all_phy(pf);
> 
> The other is the clock-owner PF on a multi-PF E82x adapter, where
> ice_ptp_rebuild_owner() -> ice_ptp_restart_all_phy() walks the adapter port
> list and arms a peer PF's ov_work:
> 
> 	list_for_each_entry_rcu(port, &pf->adapter->ports.list, list_node) {
> 		...
> 		if (port->link_up)
> 			ice_ptp_port_phy_restart(port);
> 
> while that peer PF's own service task is inside
> ice_ptp_prepare_for_reset() on another CPU.  There is no cross-PF reset
> serialization for E82x, since ice_ptp_prepare_rebuild_sec() is gated on
> ICE_MAC_GENERIC_3K_E825 in the following hunk.
> 
> Would doing the cancel inside the ps_lock critical section, or simply
> reusing ice_ptp_port_phy_stop(), close that window?  The ov_work callback
> ice_ptp_wait_for_offsets() only takes port->tx.lock with
> spin_lock_irqsave(), never ps_lock, so taking ps_lock around the sync
> cancel should not deadlock.
> 

Makes sense.

> [Severity: Low]
> Separately, who re-arms ov_work for a non-owner PF after this cancel?
> ice_ptp_wait_for_offsets() is the only place that programs the vernier
> offsets and clears the calibrating flag:
> 
> 	port->tx.calibrating = false;
> 
> and ice_ptp_is_tx_tracker_up() gates every Tx timestamp on it:
> 
> 	return tx->init && !tx->calibrating;
> 
> At this commit the only re-arm during reset is ice_ptp_restart_all_phy()
> from ice_ptp_rebuild_owner(), which runs on the clock-owner PF only, for
> non-PFR only, for link-up ports only, and can arm a peer PF's ov_work just
> before that peer cancels it here.  Note this appears to be resolved by the
> next patch in the series, "ice: call PTP link change only from link
> events", which adds an unconditional per-PF ice_ptp_link_change() call at
> the end of ice_rebuild(); with that in place every PF re-arms its own
> ov_work after its own rebuild.  Worth mentioning in the changelog that this
> patch depends on that follow-up?
> 

Yes at a minimum we'll have to reference that, possibly re-ordering the
commits.

> [Severity: Medium]
> This isn't a bug introduced by this patch, but the state that
> ice_ptp_prepare_for_reset() leaves behind interacts with an incomplete
> teardown path.  ice_ptp_release() early-returns whenever
> pf->ptp.state is neither ICE_PTP_UNINIT nor ICE_PTP_READY:
> 
> 	if (pf->ptp.state != ICE_PTP_READY) {
> 		mutex_destroy(&pf->ptp.port.ps_lock);
> 		ice_ptp_cleanup_pf(pf);
> 		if (pf->ptp.clock) {
> 			ptp_clock_unregister(pf->ptp.clock);
> 			pf->ptp.clock = NULL;
> 		}
> 		return;
> 	}
> 
> ice_ptp_cleanup_pf() only removes the port from the adapter list and drops
> the kref, so unloading the driver while the state is ICE_PTP_RESETTING
> (set here) or ICE_PTP_ERROR (set on the ice_ptp_rebuild() failure path)
> leaks the kthread worker created by kthread_run_worker() in
> ice_ptp_init_work() and the tx->tstamps allocation from
> ice_ptp_alloc_tx_tracker(), and does not sync-cancel ptp->work or
> port.ov_work before the devm-allocated ice_pf embedding them goes away.
> That branch also leaves state non-UNINIT, unlike the invariant the comment
> above ice_ptp_release() describes.
> 

I believe this will be addressed by other changes in the series.

>>  	if (ice_pf_src_tmr_owned(pf) && hw->mac_type == ICE_MAC_GENERIC_3K_E825)
>>  		ice_ptp_prepare_rebuild_sec(pf, false, reset_type);
>>  
> 
> [ ... ]


  reply	other threads:[~2026-09-17 16:32 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  0:34 [PATCH net 00/15][pull request] ice: E82x: timestamp processing logic fixes Tony Nguyen
2026-09-11  0:34 ` [PATCH net 01/15] ice: use reference counting and RCU for PTP port access Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:13     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 02/15] ice: fix removal of PTP timestamp tracker during reset Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:19     ` Jacob Keller
2026-09-18  0:22     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 03/15] ice: set in_use only after preparing Tx timestamp index Tony Nguyen
2026-09-11  0:34 ` [PATCH net 04/15] ice: E822: keep Tx timestamps disabled during offset calibration Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:25     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 05/15] ice: E822: cancel offset verification work during reset preparation Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:31     ` Jacob Keller [this message]
2026-09-11  0:34 ` [PATCH net 06/15] ice: call PTP link change only from link events Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:37     ` Jacob Keller
2026-09-18  1:31     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 07/15] ice: E825: stop clearing PHY_REG_TX_OFFSET_READY Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:41     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 08/15] ice: E825: clear PHY_REG_TX_MEMORY_STATUS prior to soft reset Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:46     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 09/15] ice: E825: perform a soft reset when starting the PHY timer Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 16:58     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 10/15] ice: wait for in-flight Tx timestamps before flushing the tracker Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 17:00     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 11/15] ice: keep Tx timestamp slots tracked until completion or timeout Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 17:47     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 12/15] ice: remove unnecessary discarding of timestamps after clock adjust Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 17:53     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 13/15] ice: skip reading Tx ready bitmap on ports with no timestamps Tony Nguyen
2026-09-11  0:34 ` [PATCH net 14/15] ice: don't clear in_use until HW clears ready bitmap Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 17:56     ` Jacob Keller
2026-09-11  0:34 ` [PATCH net 15/15] ice: Recalibrate PHY after settime64 on E825-C Tony Nguyen
2026-09-16  1:12   ` Jakub Kicinski
2026-09-17 18:02     ` Jacob Keller
2026-09-16 21:46 ` [PATCH net 00/15][pull request] ice: E82x: timestamp processing logic fixes 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=098b8650-1c43-41d5-b0e5-bc8d73cadfc4@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=alexander.nowlin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=grzegorz.nitka@intel.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=maciej.machnikowski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pmenzel@molgen.mpg.de \
    --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