🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24875

[PATCH net v2 1/3] ice: ptp: serialize E825 PHY timer start with PTP lock and incval

#24875
From: Tony Nguyen
Date: Tue, 01 Dec 2026 00:52
161 lines
14911 bytes
From: Maciek Machnikowski <maciej.machnikowski@intel.com>

ice_start_phy_timer_eth56g() programmed the PHY increment value and
performed the PHY-to-PHC phase synchronization in two separate PTP
semaphore critical sections, and touched the shared source command
register (GLTSYN_CMD via ice_ptp_src_cmd()) and read the source incval
before acquiring the semaphore at all.

Because GLTSYN_CMD is a single global register latched for the source
timer and all PHY ports by GLTSYN_CMD_SYNC, a concurrent adjtime (small
offset, <= S32_MAX) or adjfine could clobber the source command between
the incval-init and the phase-sync steps. In the worst case the source
timer command written by ice_ptp_adj_clock() (ICE_PTP_ADJ_TIME) was
overwritten by the unlocked ICE_PTP_NOP from ice_start_phy_timer_eth56g(),
so the adjustment was applied to the PHY ports but not to the PHC. This
left the E825 PHY clock permanently offset from the PHC, showing up as an
intermittent clock drift.

Hold the PTP semaphore across the entire start sequence: acquire it before
the first shared-register access (ice_ptp_src_cmd()), keep it held through
the incval read, PHY incval init, and the phase synchronization, then
release it once. Modify the ice_sync_phy_timer_eth66g() to assume the PTP
semaphore is held, instead of trying to acquire the lock itself.

Fixes: 781ff8f2d575 ("ice: ptp: serialize E825 PHY timer start with PTP lock")
Signed-off-by: Maciek Machnikowski <maciej.machnikowski@intel.com>
Co-developed-by: Grzegorz Nitka <grzegorz.nitka@intel.com>
Signed-off-by: Grzegorz Nitka <grzegorz.nitka@intel.com>
Suggested-by: Marc Neustadter <marc.neustadter@intel.com>
Reviewed-by: Sergey Temerkhanov <sergey.temerkhanov@intel.com>
Reviewed-by: Milena Olech <milena.olech@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Tested-by: Ayush Singh <ayush1x.singh@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 42 +++++++++------------
 1 file changed, 18 insertions(+), 24 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index 3a41c711e751..c5a86ae66130 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -2039,9 +2039,10 @@ static int ice_read_phy_and_phc_time_eth56g(struct ice_hw *hw, u8 port,
  * to the PHY timer in order to ensure it reads the same value as the
  * primary PHC timer.
  *
+ * Context: The caller must acquire the PTP semaphore lock.
+ *
  * Return:
  * * %0     - success
- * * %-EBUSY- failed to acquire PTP semaphore
  * * %other - PHY read/write failed
  */
 static int ice_sync_phy_timer_eth56g(struct ice_hw *hw, u8 port)
@@ -2049,14 +2050,9 @@ static int ice_sync_phy_timer_eth56g(struct ice_hw *hw, u8 port)
 	u64 phc_time, phy_time, difference;
 	int err;
 
-	if (!ice_ptp_lock(hw)) {
-		ice_debug(hw, ICE_DBG_PTP, "Failed to acquire PTP semaphore\n");
-		return -EBUSY;
-	}
-
 	err = ice_read_phy_and_phc_time_eth56g(hw, port, &phy_time, &phc_time);
 	if (err)
-		goto err_unlock;
+		return err;
 
 	/* Calculate the amount required to add to the port time in order for
 	 * it to match the PHC time.
@@ -2072,11 +2068,11 @@ static int ice_sync_phy_timer_eth56g(struct ice_hw *hw, u8 port)
 
 	err = ice_ptp_prep_port_adj_eth56g(hw, port, (s64)difference);
 	if (err)
-		goto err_unlock;
+		return err;
 
 	err = ice_ptp_one_port_cmd(hw, port, ICE_PTP_ADJ_TIME);
 	if (err)
-		goto err_unlock;
+		return err;
 
 	/* Issue the sync to activate the time adjustment */
 	ice_ptp_exec_tmr_cmd(hw);
@@ -2086,15 +2082,13 @@ static int ice_sync_phy_timer_eth56g(struct ice_hw *hw, u8 port)
 	 */
 	err = ice_read_phy_and_phc_time_eth56g(hw, port, &phy_time, &phc_time);
 	if (err)
-		goto err_unlock;
+		return err;
 
 	dev_info(ice_hw_to_dev(hw),
 		 "Port %u PHY time synced to PHC: 0x%016llX, 0x%016llX\n",
 		 port, phy_time, phc_time);
 
-err_unlock:
-	ice_ptp_unlock(hw);
-	return err;
+	return 0;
 }
 
 /**
@@ -2155,19 +2149,24 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port)
 	if (err)
 		return err;
 
+	if (!ice_ptp_lock(hw)) {
+		dev_err(ice_hw_to_dev(hw), "Failed to acquire PTP semaphore\n");
+		return -EBUSY;
+	}
+
 	ice_ptp_src_cmd(hw, ICE_PTP_NOP);
 
 	err = ice_phy_cfg_parpcs_eth56g(hw, port);
 	if (err)
-		return err;
+		goto err_ptp_unlock;
 
 	err = ice_phy_cfg_ptp_1step_eth56g(hw, port);
 	if (err)
-		return err;
+		goto err_ptp_unlock;
 
 	err = ice_phy_cfg_mac_eth56g(hw, port);
 	if (err)
-		return err;
+		goto err_ptp_unlock;
 
 	if (ice_is_primary(hw)) {
 		lo = rd32(hw, GLTSYN_INCVAL_L(tmr_idx));
@@ -2178,11 +2177,6 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port)
 	}
 	incval = (u64)hi << 32 | lo;
 
-	if (!ice_ptp_lock(hw)) {
-		dev_err(ice_hw_to_dev(hw), "Failed to acquire PTP semaphore\n");
-		return -EBUSY;
-	}
-
 	err = ice_write_40b_ptp_reg_eth56g(hw, port, PHY_REG_TIMETUS_L, incval);
 	if (err)
 		goto err_ptp_unlock;
@@ -2193,11 +2187,11 @@ int ice_start_phy_timer_eth56g(struct ice_hw *hw, u8 port)
 
 	ice_ptp_exec_tmr_cmd(hw);
 
-	ice_ptp_unlock(hw);
-
 	err = ice_sync_phy_timer_eth56g(hw, port);
 	if (err)
-		return err;
+		goto err_ptp_unlock;
+
+	ice_ptp_unlock(hw);
 
 	err = ice_write_ptp_reg_eth56g(hw, port, PHY_REG_TX_OFFSET_READY, 1);
 	if (err)
-- 
2.47.1
Technical Details
Message-ID: <20261201005258.1323948-2-anthony.l.nguyen@intel.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374567-linux-kernel-netdev=dewy.ru
References: <20261201005258.1323948-1-anthony.l.nguyen@intel.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374567-linux-kernel-netdev=dewy.ru
From: anthony.l.nguyen@intel.com (Tony Nguyen)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v2 1/3] ice: ptp: serialize E825 PHY timer start with PTP lock and incval
Date: Mon, 30 Nov 2026 16:52:54 -0800
Organization: Usenet Network
Message-ID: <20261201005258.1323948-2-anthony.l.nguyen@intel.com>
References: <20261201005258.1323948-1-anthony.l.nguyen@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1578277"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:2z1KTTJnSh0+kCLf0WtlXpQRc3Q= sha256:i5yR2y46Z8xa1oy2WI/DngYZrf6IpZnCHfAEhf9XWMc=
	sha1:YFgAYSYq6pXA8HJ2MOYTbH6Nn1o= sha256:XHFMefz5op9d5a7BmJghvJidZJ3pm0b5lAXu9EK9HjA=
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 A842012601A; Tue,  1 Dec 2026 03:53:28 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=intel.com
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 CXqbLk8yLcpV;
	Tue,  1 Dec 2026 03:53:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374567-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=intel.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 06B22126018; Tue,  1 Dec 2026 03:53:16 +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 113BF26C28; Tue,  1 Dec 2026 00:53:12 +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=1796086391;
	b=3o8t0U+NUE4WprTtfPqPrX1RvuS7nTdIk7qSziwyXHjVkzeySSRk6+qpfo/90625o6pt
	 jeeCpgHgPXLZcZyiSPDel149I6nCn8FDHehq4uv0zaYQhhxQB2GlaypjlMTFz1Wp2ZqmP
	 r5iMdianMMaCgMVb+Z90EMQ5QUPRwZ4l4sbbB3WLJCuxzfMnqLgUeXjIfXdx9x2fpaZn2
	 Rq/xgDI/BBAhmKFxHEmG6z04jznV+slpfE3hkjyOL/fVKyRQN2szGPXONS+DBaWPy8XQS
	 y5sVrjw4OxGZOiFA8YEXMTcvObcLclO+Lw+AbKM8HYZLbDCpOKii0HrGixd3NK2D3xw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796086391;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:
	 X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-IronPort-AV:X-IronPort-AV:
	 Received:X-CSE-ConnectionGUID:X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=OInWwL82EXeln6OTD6crB3NNKrS9YLQJo7QQsSh6Vkk=;
	b=ZWpgTGTOFBvL37Lfj2SOjETMzXzlOPo0zgNYxblx+KxObIbXhQClkAPByY6e6pfscrFC
	 I4dYBM73AD67viz4ZKDonjHnu4Le5pK2V/BvSElcz2Yt40ZtMd0Rt/QnNviB+qZ4l78oh
	 YCWQnMtwyy5oVJLoloq9j5aW9ngfMpQhfUl+rA9Qd7fC4bHNxVrosPcoVk4x4pSovegtU
	 TTfM6ydQA2J1ZaOws6B2Kh/Wxyesfypa3rIXCqtTdtwwGV/tBo4q13/dnUMdWvX6fgRDy
	 Qnd+U1tVni0xoDyxsNFrF0+VkPyp5KikfFX9XeKzp8vf+y+5XesN2njbi8Y7JjMeyTA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KDRry4lp;
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	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 E2EB0606A33D;
	Tue,  1 Dec 2026 00:53:10 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KDRry4lp
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.17
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796086390;
	b=FXGXj8Ygy+oCQzrs7dRmYVFBGa6IdCEhnpKUi4Pi5aFEk3MCkfV2ULfz4HpH2FybVAWl
	 /QVvPqitK79QeS5gcytPIyBUmMlAZin08GmG63EAUZvJq5hMrPEbj+ufTGJOtD5OwXeJt
	 6D77Ul5Jt3kUSw9rgGbOQdnyHQPf8vkh+SI5xr6Me7FPDWQG01oxK6s1T4A7pOM3V23UI
	 Lt/YAVsJ0nR/6wPeQrhJM/BH5aX7+fs0siqV3aPKTiibUpsWrIhTTEAgB6UwEX+FprgtN
	 AA1LMWwS3KJunJHC6pcUq3xoGJCBkbLcw1guTe2TaFUnjDf8xEpvDbmZwo082wJlaqg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796086390;
	h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID:
	 X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID:
	 X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=OInWwL82EXeln6OTD6crB3NNKrS9YLQJo7QQsSh6Vkk=;
	b=Q9jaqBXqDVPqO9F/RsHHr9iFx09MMdqxXEQJdjs07amXrV50erTiiiLHeuW5MLkB3KNF
	 9NYG1za2rh50imDIvK8oUCNmYfmr82OmkjvJaoxtZiwhXVRobqHtArE/b2KkJbGY0DbAu
	 NDoVuaK9OJIsYZ/EsJZbRicGlGhFrhShAdLAllP2tcpXmgyifA1qtz79S/6F1EqaTQLeC
	 P+rl6mnaxVOeZkvEQl4KVOEK4e71zDASmIHX8xxcJeE9pqQVSri8Jy1dCgxOTrnxkbqxs
	 0LL06akpGgV/vIdlcPKCZfRqryF5Q7gau4v93iLvEz59YoQ4YFIUxE+wybo32rT2kfQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=intel.com;
	spf=pass smtp.mailfrom=intel.com;
	dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KDRry4lp;
	arc=none smtp.remote-ip=198.175.65.17
X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17])
	(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8FD9606A320
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 00:53:09 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8FD9606A320
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
  t=1796086390; x=1827622390;
  h=from:to:cc:subject:date:message-id:in-reply-to:
   references:mime-version:content-transfer-encoding;
  bh=OInWwL82EXeln6OTD6crB3NNKrS9YLQJo7QQsSh6Vkk=;
  b=KDRry4lpeA8iR6ccoR2eX4Knfis+nI1C2s+n+Vt/shM7IqYQRLdw+4u5
   q+nuqdLPSx/VZiJDM2rJhEa/XIHNTdmBdfNQukR1aTiRgx+NSjzGX9NEQ
   zcFsiKTQl6dKUS74P2yh74erLv4k/FGR5uwUiPbCZwCzrS6yVrQCMKVAG
   kOCRcnvyTseHkqRuMxhUzX5OE4gQycMWdJMEf/HUC5UPDiOLRYiDT01cx
   ColZ19YoOUZfBVjR5YlqdJi9TuZGMIEiozxIhXWqBfSEVZG4/uNk/dUWC
   uT/RQO2TC+pH7wZpWYj+f0Zse8PP93a7GdqKzhGJp98z8ZXctxHQZ+CKS
   g==;
X-CSE-ConnectionGUID: 3PDfRYKbSYeIsmPycPxvew==
X-CSE-MsgGUID: 5buQp2hqSwOlP1ZnXKsuug==
X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4941438"
X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; 
   d="scan'208";a="4941438"
X-Received: from fmviesa011.fm.intel.com ([10.60.135.151])
  by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 16:53:08 -0800
X-CSE-ConnectionGUID: OTDRiOFzQfeE1rdYnXT3tA==
X-CSE-MsgGUID: 5n+AThVwTq26VHMxx8Iz7A==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; 
   d="scan'208";a="14837743"
X-Received: from anguy11-upstream.jf.intel.com ([10.166.9.133])
  by fmviesa011.fm.intel.com with ESMTP; 30 Nov 2026 16:53:08 -0800
X-Cc: Maciek Machnikowski <maciej.machnikowski@intel.com>,
	anthony.l.nguyen@intel.com,
	przemyslaw.kitszel@intel.com,
	grzegorz.nitka@intel.com,
	jacob.e.keller@intel.com,
	richardcochran@gmail.com,
	Marc Neustadter <marc.neustadter@intel.com>,
	Sergey Temerkhanov <sergey.temerkhanov@intel.com>,
	Milena Olech <milena.olech@intel.com>,
	Simon Horman <horms@kernel.org>,
	Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Ayush Singh <ayush1x.singh@intel.com>
X-Mailer: git-send-email 2.47.1
X-In-Reply-To: <20261201005258.1323948-1-anthony.l.nguyen@intel.com>
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