From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385228; b=a54DMA0PUvHKwzyIxiGpIhMRb2Sgo7jlWi09WY5IGiu9zpMcEqoLwQB6dL8wDYijhF57 eyjDpdkSIyaAKOBYEMQTHf96hFxhS+L8RGDpopaZlbwiTdTOXCiECRmTok/Ow12zdopeR 3ZvcpF6xeqaKgFkOoSaGvtlySHIj9qV4o7YxGZ4MfnNUZU9fXMyAXmZB+57R9SD1Mu+ac 0Caj+d8wtqYAyViN4qbmTW77zEKD4iS1sd3C1uqZpYNstccpj1J2rU0v9l/eEB8InJPc7 uvP7GaChLZhcv4F0WIx+lFpI5u/HNahs2P9L8hHXd6B7GhGZjbTpUL3Pa/lpuTc+nKw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385228; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=OaRguT/4oVwl+6V8h6ZiJvOz20CV1wm6WWrLLclBRIg=; b=WXCxG44FwBhlWJEVInTR54fzt2yooMktk8Im1Q8hD4adJk8WRJBvGLfbfFdjCPCh4xxP uPh7uHxY7L0/6sGyyZubVotRVk4kFndmw6cnhJdsMAGc5DgdZbjq+4fV3GToREvegASVB R462hFiOA/9o466VR5AuMR5rEcOz1Nu0bET2Mmo9+aEZeG1vx5bKfQveZg6uN/XtmZeSu ARmnZogLcG5BKxhobsMsYs532/7ODQLehapux63IrlHbPRsDRE+ftbZ0g8M84rYxVZ2G6 gLKoSqhaIzPfibh0E98IdiB05wnnNngWEgTG+NNfGAVG5WsG0LfoUE9q/KVWs63Tk0A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Sq7jwmwY; arc=none smtp.remote-ip=100.103.45.18 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 E1F79606A322; Fri, 4 Dec 2026 11:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=Sq7jwmwY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C5E81F00931; Fri, 4 Dec 2026 11:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385227; bh=OaRguT/4oVwl+6V8h6ZiJvOz20CV1wm6WWrLLclBRIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Sq7jwmwYsUnRqcyBdBokGVYwckMUBmJhqUROhUK9Bkvfc0Oo2jw+/mBSt0wQpjhgX qFzaHI3s5Hc2vYjN5Oyf72CWzDlUWmX6w5qcc/az/CtmP2dEgrtqJPZIuuJuC3wrEz HvzZ/rp96YKpM0PKpkcKA/j0odrpWxeimoA4PpBI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karol Kolacinski , Aleksandr Loktionov , Arkadiusz Kubalewski , Przemyslaw Korba , Jacob Keller , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.6 0472/1167] ice: E822: keep Tx timestamps disabled during offset calibration Date: Fri, 4 Dec 2026 18:58:19 +0900 Message-ID: <20261204100714.316249886@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karol Kolacinski [ Upstream commit 56af436b90acce7eaa7531189c827773983f7d07 ] Do not clear the tx.calibrating flag immediately after starting the PHY timer in ice_ptp_port_phy_restart(). Instead, keep Tx timestamps disabled until the offset verification work (ice_ptp_wait_for_offsets) has confirmed that the Tx PHY offset is properly configured. Previously, tx.calibrating was set to true, then immediately back to false right after ice_start_phy_timer_e82x() returned. This allowed Tx timestamp requests to be served during the window where offset verification was still pending. Timestamps produced during this window should have their valid bit cleared, but it is better to prevent requests until the driver has confirmed calibration is complete. Rename the tx.calibrating field to tx.disabled, and change where it is cleared. Only clear it in ice_ptp_wait_for_offsets(), and only after Tx offset configuration has completed successfully. This ensures that new Tx timestamp requests are only accepted after the PHY has properly calibrated the Tx offset. If ice_start_phy_timer_e82x() fails, do not restore disabled to false. The device is in a state where timestamps cannot succeed properly anyways. A dev_err message is already logged on failure to start the timer at the end of the function. Renaming the field improves clarity and will better reflect the nature of the flag in a future change that also applies disabling Tx timestamps in software in a following commit. Log a debug message while offset calibration is still pending, including the specific Tx/Rx error codes to aid debugging stalled calibration. This path is expected on every routine link-up: ov_work is first queued with no delay and the vernier offset cannot be computed until at least one packet has been transmitted, so the first several invocations normally land here. Use dev_dbg() rather than a rate-limited warning to avoid emitting KERN_WARNING on every link-up during normal operation. Log a debug message when calibration completes successfully. Note that sashiko review has previously complained that leaving the disabled flag set "permanently" disables Tx timestamps if vernier calibration never completes. This is true, but its important to realize that timestamps would still fail regardless of whether the flag is set. Until vernier calibration completes the device will not report valid timestamps regardless. Thus, keeping the calibrating flag set simply prevents new timestamp requests from software while it is known that the hardware will not complete them. Fixes: 3a7496234d17 ("ice: implement basic E822 PTP support") Signed-off-by: Karol Kolacinski Reviewed-by: Aleksandr Loktionov Signed-off-by: Arkadiusz Kubalewski Signed-off-by: Przemyslaw Korba Signed-off-by: Jacob Keller Link: https://patch.msgid.link/20261027-reduction-v1-3-81237c67a361@intel.com Signed-off-by: Jakub Kicinski [ sashal: Adapted to the older tree: the e82x helper names became e822, the restart function's flat control flow got the same edit as upstream's loop, and header doc context differs. ] Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice_ptp.c | 35 ++++++++++++++++++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 6 ++-- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 8427b36bd8b55..843ce309630af 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -613,7 +613,7 @@ ice_ptp_is_tx_tracker_up(struct ice_ptp_tx *tx) { lockdep_assert_held(&tx->lock); - return tx->init && !tx->calibrating; + return tx->init && !tx->disabled; } /** @@ -1250,6 +1250,7 @@ static int ice_ptp_check_tx_fifo(struct ice_ptp_port *port) static void ice_ptp_wait_for_offsets(struct kthread_work *work) { struct ice_ptp_port *port; + unsigned long flags; struct ice_pf *pf; struct ice_hw *hw; int tx_err; @@ -1270,9 +1271,26 @@ static void ice_ptp_wait_for_offsets(struct kthread_work *work) tx_err = ice_ptp_check_tx_fifo(port); if (!tx_err) tx_err = ice_phy_cfg_tx_offset_e822(hw, port->port_num); + if (!tx_err) { + /* Tx offset has been configured, re-enable Tx timestamps */ + spin_lock_irqsave(&port->tx.lock, flags); + if (port->tx.disabled) { + port->tx.disabled = false; + dev_dbg(ice_pf_to_dev(pf), "PTP Tx offset valid for port %u, Tx timestamps enabled\n", + port->port_num); + } + spin_unlock_irqrestore(&port->tx.lock, flags); + } + rx_err = ice_phy_cfg_rx_offset_e822(hw, port->port_num); if (tx_err || rx_err) { - /* Tx and/or Rx offset not yet configured, try again later */ + /* Tx and/or Rx offset not yet configured, try again later. + * This is expected during normal link-up: the vernier offset + * calibration cannot complete until at least one packet has + * been transmitted, so the first retries routinely land here. + */ + dev_dbg(ice_pf_to_dev(pf), "PTP offset not yet valid for port %u (tx_err=%d rx_err=%d)\n", + port->port_num, tx_err, rx_err); kthread_queue_delayed_work(pf->ptp.kworker, &port->ov_work, msecs_to_jiffies(100)); @@ -1335,9 +1353,9 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port) kthread_cancel_delayed_work_sync(&ptp_port->ov_work); - /* temporarily disable Tx timestamps while calibrating PHY offset */ + /* Disable Tx timestamps until PHY calibration completes */ spin_lock(&ptp_port->tx.lock); - ptp_port->tx.calibrating = true; + ptp_port->tx.disabled = true; spin_unlock(&ptp_port->tx.lock); ptp_port->tx_fifo_busy_cnt = 0; @@ -1346,11 +1364,10 @@ ice_ptp_port_phy_restart(struct ice_ptp_port *ptp_port) if (err) goto out_unlock; - /* Enable Tx timestamps right away */ - spin_lock(&ptp_port->tx.lock); - ptp_port->tx.calibrating = false; - spin_unlock(&ptp_port->tx.lock); - + /* Do not clear disabled flag here. Tx timestamp requests + * remain disabled until ice_ptp_wait_for_offsets() has + * verified that the Tx offset calibration has completed. + */ kthread_queue_delayed_work(pf->ptp.kworker, &ptp_port->ov_work, 0); out_unlock: diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 3dd7584be0fa8..43b30be6d929f 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -134,8 +134,8 @@ enum ice_tx_tstamp_work { * @offset: offset into timestamp block to get the real index * @len: length of the tstamps and in_use fields. * @init: if true, the tracker is initialized; - * @calibrating: if true, the PHY is calibrating the Tx offset. During this - * window, timestamps are temporarily disabled. + * @disabled: set to true when new Tx timestamp requests are disabled, such as + * while the PHY Tx offset configuration has not yet completed. * @verify_cached: if true, verify new timestamp differs from last read value */ struct ice_ptp_tx { @@ -147,7 +147,7 @@ struct ice_ptp_tx { u8 offset; u8 len; u8 init : 1; - u8 calibrating : 1; + u8 disabled : 1; u8 verify_cached : 1; }; -- 2.53.0