🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #7264

Re: [PATCH net v5 01/13] ice: fix removal of PTP timestamp tracker during reset

#7264
From: netdev-bot+sashiko
Date: Sun, 25 Oct 2026 23:43
181 lines
15440 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 (1) · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The new error unwind in ice_ptp_init() destroys the PTP
  kworker while the owner's PTP clock is still registered.
- [Medium] On E810 (has_ready_bitmap == 0), the Tx tracker now survives
  CORE/GLOBAL/EMP resets.

Pre-existing issues:
- [Medium] Concern: ice_ptp_flush_all_tx_tracker(),
  ice_ptp_restart_all_phy() and ice_ptp_prepare_rebuild_sec() walk…

--

ice: fix removal of PTP timestamp tracker during reset

This patch stops ice_ptp_prepare_for_reset() from releasing the Tx
timestamp tracker, so timestamping works again after CORE, GLOBAL or EMP
resets. It also reorders ice_ptp_init() so the kworker and tracker are set
up before the port is added to the port list, with a matching error
unwind. The non-READY branch of ice_ptp_release() now frees the tracker
and kworker.

Closes: https://sashiko.dev/#/patchset/20260821-jk-e825c-minimized-fixes-v1-0-9d0731eb4858%40intel.com?part=8
Closes: https://lore.kernel.org/netdev/20260916011213.1632286-1-kuba@kernel.org/

> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index eaec36ab6ae3..e1c66cd0f94f 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -2939,8 +2939,6 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
>  	if (ice_pf_src_tmr_owned(pf) && hw->mac_type == ICE_MAC_GENERIC_3K_E825)
>  		ice_ptp_prepare_rebuild_sec(pf, false, reset_type);
>  
> -	ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx);
> -
>  	/* Disable periodic outputs */
>  	ice_ptp_disable_all_perout(pf);

[Severity: Medium]
The tracker now survives CORE/GLOBAL/EMP resets. On E810, can the
cached_tstamp values then drift from the PHY state after the post-reset
flush?

The rebuild path runs after hw->reset_ongoing has already been set back
to false:

ice_rebuild()->ice_ptp_rebuild()->ice_ptp_rebuild_owner()
  ->ice_ptp_flush_all_tx_tracker()->ice_ptp_flush_tx_tracker()

On E810, ice_get_phy_tx_tstamp_ready_e810() reports every slot as ready:

	*tstamp_ready = 0xFFFFFFFFFFFFFFFF;

So ice_ptp_flush_tx_tracker() clears every in_use slot in hardware:

	if (!hw->reset_ongoing && (tstamp_ready & BIT_ULL(phy_idx)))
		ice_clear_phy_tstamp(hw, tx->block, phy_idx);

That writes 0 to the PHY slot. However, tx->tstamps[idx].cached_tstamp
keeps its old non-zero value.

E810 has has_ready_bitmap == 0, so ice_ptp_process_tx_tstamp() treats any
raw value that differs from the cache as captured:

	if (!drop_ts && !tx->has_ready_bitmap &&
	    raw_tstamp == tx->tstamps[idx].cached_tstamp)
		continue;

	/* Discard any timestamp value without the valid bit set */
	if (!(raw_tstamp & ICE_PTP_TS_VALID))
		drop_ts = true;

The next request on that slot might be processed before hardware captures
it, for example because another slot raised the TSYN_TX interrupt. In that
case raw is 0, which does not match the stale cache. The skb then
completes without a timestamp and in_use is cleared. The cache is not
updated, because raw is 0.

The real capture for that packet then lands in the slot that was just
freed. Could the next request that reuses the slot read this leftover
value and report it as its own timestamp?

Would resetting cached_tstamp when the flush clears the PHY slot keep the
software and hardware state in sync?

[ ... ]

> @@ -3363,16 +3366,19 @@ void ice_ptp_init(struct ice_pf *pf)

[ ... ]

>  	dev_info(ice_pf_to_dev(pf), "PTP init successful\n");
>  	return;
>  
> -err_clean_pf:
> +err_release_tx_tracker:
> +	ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx);
> +err_release_kworker:
> +	kthread_cancel_delayed_work_sync(&ptp->work);
> +	kthread_destroy_worker(ptp->kworker);
> +	ptp->kworker = NULL;
>  	mutex_destroy(&ptp->port.ps_lock);
> -	ice_ptp_cleanup_pf(pf);
>  err_exit:
>  	/* If we registered a PTP clock, release it */
>  	if (pf->ptp.clock) {

[Severity: Medium]
Is the PTP clock still registered while the kworker is torn down here?

On the clock owner, ice_ptp_init_owner() has already registered the
clock. /dev/ptpN stays live until err_exit calls ptp_clock_unregister().

The settime64 and adjtime ops do not check ptp->state, and they call
ice_ptp_reset_cached_phctime(). Suppose ice_ptp_update_cached_phctime()
returns -EAGAIN because ICE_CFG_BUSY is held, for example by a concurrent
adjtime on the same PHC. That function then does:

	kthread_queue_delayed_work(pf->ptp.kworker, &pf->ptp.work,
				   msecs_to_jiffies(10));

If this runs after kthread_cancel_delayed_work_sync() but before or during
kthread_destroy_worker(), a timer is left pending. Could
kthread_delayed_work_timer_fn() later touch the freed worker?

If it runs after ptp->kworker = NULL, would it dereference NULL?

One way to reach this window: ice_ptp_init_port() fails with -ENOMEM from
ice_ptp_alloc_tx_tracker() while a process with /dev/ptpN open calls
clock_settime() or clock_adjtime().

In this same patch, the non-READY branch of ice_ptp_release() unregisters
the clock before tearing down the worker. Should the init error path use
the same order? This ordering is still present at the end of the series.

> @@ -3399,12 +3405,22 @@ void ice_ptp_release(struct ice_pf *pf)
>  		return;
>  
>  	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;
>  		}
> +		ice_ptp_cleanup_pf(pf);
> +		ice_ptp_release_tx_tracker(pf, &pf->ptp.port.tx);

[Severity: Medium]
This is a pre-existing issue and was not introduced by this patch.
ice_ptp_flush_all_tx_tracker(), ice_ptp_restart_all_phy() and
ice_ptp_prepare_rebuild_sec() walk the adapter port list without holding
ports.lock:

	list_for_each_entry(port, &pf->adapter->ports.ports, list_node)
		ice_ptp_flush_tx_tracker(ptp_port_to_pf(port), &port->tx);

At the same time, a peer PF's ice_ptp_release() can remove its port from
the list and free the tracker, kworker and ps_lock. Since trackers are now
kept across resets, the owner's flush walks memory that belongs to live
peers.

The next patch in the series, "ice: use reference counting and SRCU for
PTP port access", fixes this. It converts these walkers to
srcu_read_lock() with list_for_each_entry_srcu() and
kref_get_unless_zero(). It also makes ice_ptp_cleanup_pf() wait for the
references and SRCU readers to finish before the tracker and worker are
freed. The race is gone by the end of the series.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-0-72289a4ac8eb%40intel.com
Technical Details
Message-ID: <179297183411.3134.15060779235779250719@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351629-linux-kernel-netdev=dewy.ru
References: <20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-1-72289a4ac8eb@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351629-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5 01/13] ice: fix removal of PTP timestamp tracker
 during reset
Date: Sun, 25 Oct 2026 23:43:54 +0000
Organization: Usenet Network
Message-ID: <179297183411.3134.15060779235779250719@kernel.org>
References: <20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-1-72289a4ac8eb@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1172937"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:ocZEUDzYlO128+Bx2MzvS62j3iU= sha256:XUD1Npq/ceu4BEDm4i1PGkPSbJpxubXzM3OE1dbsy08=
	sha1:+38ooRzzBtDXZjFA1mgl2Nec/iI= sha256:jjuUz983oBo+pt8Tu7g8hh3wxcy5MWFBHcSsGQ3z2Ss=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id CDFC0125B86; Mon, 26 Oct 2026 02:44:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.739
X-Spam-Status: No, score=-3.739 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.339, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id R1sr5006GY1R;
	Mon, 26 Oct 2026 02:44:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-351629-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 77E66125B85; Mon, 26 Oct 2026 02:44:10 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 566D22E6B4; Sun, 25 Oct 2026 23:43:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792971837;
	b=UV1I5Slno8O7PkPR4cGjq8wUmUkgARpLUSYmzAjTJCnVO08gXsIcy44z9Ii4WOPJWEss
	 DgKBLN2fkDySnOL3ZZ2gC9G3ugDAyORnzbm4QimHrIZSYWBdd0aPCVOOUexuNM60SasWo
	 +SYf00sqIiCj4DPqLuqLcLKEdndH5helQkzMkvhrL/RXjLI+YwltPNFV+S7/Mb9pAuEIW
	 6VWu+tnJEfI/6PgiUahhS31KIq6jh54tLEeQG03GW2lRdTlb1kb5UfW3B71SrQg/4Pgui
	 kymHVNMJ1ii4EZ2tuZ18yuP47eLD11/SrCWgVCFAI4C9Wnv0HsqLs8V1o221iyBS0eQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792971837;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=zLTTZuRlp6EimEh8SBZmZz7gt+9H0C46ju7PufG8QTY=;
	b=zk5LVe1VcqOjEFQzy7eJvtVaR1Hwt6ja19aGB6Lp9jLyQCLFUlEIn48cuPfOXgn+X907
	 JwMmifEkpzyazQRq8dHE3ucg1BK4DCHSgOFkhxoMmlbqmbptIgkG6u2rR8iPgfPuSJUvb
	 i4Sn4OatEpzEGOhhEby9pyxnoMsmh3151LpcrMBUY+rURh3lLwd+CAL6OZ/XG+/lg46AC
	 lVmZiO0obzqOakz4Q/w9Eug7Qz+clXdaHDfUq2YQqm0JL9g8bn+ilvdXl8YvcaTuKug+8
	 JtcHY6Ce/vGRNK3XYnUnxXiTJDF/EZ1w5PYPD3kxzNgECX8WkpuH4rVt6LAFI+4jwEg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fur9zyp6;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 29486606A321;
	Sun, 25 Oct 2026 23:43:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fur9zyp6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792971836;
	b=0CMUGZufDth4AG+u34RUs0uuKSSHo4cGJSMc1cALy3u8NjJSZv7ZR5M6fkUI1qvuxMWg
	 Bxm/4ReEHz5rQr82eocXx7dp+Z5yGJDK/PdiW8aXLp0iZ4kMlpd9RtBE3C7Hr1nxRAxoi
	 a+amCt1vJpnsRHqTgXM3nKyVs4XYN+UqQN2433yZS5+pAzPRX23diDW1dTAaganxyZdIN
	 abwzqytnWVNG5O13SDrNflXJzA2NcpKgMgJFGy6LCVUpvnj+5wFkKoYd1tyaaPaxEhcoW
	 viGoOUklfGUfKM3JXciDv5Ec51TYLEivtWNHbB4tKe7sgQqm4C5mbgUEHqQyJUiq6kw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792971836;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=zLTTZuRlp6EimEh8SBZmZz7gt+9H0C46ju7PufG8QTY=;
	b=uOJ/rsK1CWHAKCHlnYD29TEuv+ae12Dz23gJj40ZZPj2cwC+dv7e1eZo2smzBRQjr2uT
	 0jwLamsllcdysg6ZnLi+Aq3s4U5U7c/ibLrapvOkO7ZOIxhaSUiQ7VG485IwJkbKFOsIO
	 iHt1CjTXS5OH4oKxf79f8KP68QhMAyrZtCE3zP0yoDXUV8M7QAZiZbqStbrGQ6biP1bJa
	 H98PVl7lBVxHS/0ruqgrU+hGitYgtfZuD8KqcuZk1S86jY8BaQmQRcY/HK5Ko9s/faNV1
	 JMfMfZPGPf7WK1ETcdOVcz4hAshC/sGaEc0zYLvZQkmb5LN/m2DQ+ThEw7/QgYcUU6A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Fur9zyp6;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3BD2606A31A
	for <netdev@vger.kernel.org>; Sun, 25 Oct 2026 23:43:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A7B81F01825;
	Sun, 25 Oct 2026 23:43:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792971835;
	bh=zLTTZuRlp6EimEh8SBZmZz7gt+9H0C46ju7PufG8QTY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=Fur9zyp69fqhoXhrpvaDhAMlIO6aABjZ1rjX+zo7y4vnDYpHqFwKGWE9WpJTZVrMF
	 d4v3lyX0xy5lV2/kNSXwStQR+Sx15aSdcsDaFsMIOhhQJBDBu5ZQQ9fPgv4PPl3/p5
	 4nL56gYip3TJsf6R1mHiC6JQ10PfzQJXoAggdgiXIdz4XeQ1kLZVuwYxr+Ne0T0o0x
	 QmKDljQjnc1ne/D6J11kguQ6U/HMdbqIhJbt/BUNnzcmZ43iRwyEdHIhyZ8xUNNAO1
	 Sy8XpLuDqrjJOsuue7B/kjYBlf6mUYZVMDZdChQnlfy/GOBGFM762JrrSh7tmETYmd
	 1e5zwFVsuJ8ww==
X-Cc: przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, poros@redhat.com,
 netdev@vger.kernel.org, grzegorz.nitka@intel.com,
 aleksandr.loktionov@intel.com, alexander.nowlin@intel.com,
 anthony.l.nguyen@intel.com, maciej.machnikowski@intel.com,
 przemyslaw.korba@intel.com, sergey.temerkhanov@intel.com,
 arkadiusz.kubalewski@intel.com, richardcochran@gmail.com, horms@kernel.org
X-In-Reply-To: <20261021-jk-e825c-timestamp-processing-logic-fixes-srcu-v5-1-72289a4ac8eb@intel.com>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list