From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C06AA2F2619 for ; Fri, 11 Sep 2026 00:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789086890; cv=none; b=pE1DmfUkr1y9ai8kakYKojwtSjNr1F+mdI+O1/stjU98JxVvgrhNsWx5QXV5Cfgiimo3mn9S85mv8oHDjuEZJ2H328X2paEE5Xss+nWJBFaxZuPE72v0WSpPyOQW3A6C3V5r3a3e+ow8qFxPRDkZg5PLGgptCSrUMKKjcoen2wA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789086890; c=relaxed/simple; bh=Gh4xHgtf8ncje4Iv+Fe16WQRtZ4MRLVeaL09gjLhrJo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dANdE4cGxywpt8LtKbvgghYvJ5bKXwY1rBYPaepyhpwWu/J2T5M7usvCJhmXHLxWynoYuMvKKlytXPQ9Jzr6h5v3CTiuxAxfwvLDe4aF8d/OR+A95Pzy05+StxjoVsiwwVOhYgmFK9YOv15sTyg+lAhFEzOrUtQVyg/tvpuC8PE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=gowhZc6/; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gowhZc6/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789086889; x=1820622889; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gh4xHgtf8ncje4Iv+Fe16WQRtZ4MRLVeaL09gjLhrJo=; b=gowhZc6/KeTmgScmwLPWesn+aGrdkLREIiEaGhemDa6ASbcFMWNr+l5+ ZAF9d0Qb70edevKn9x8xk7aFKC97zcHYH82x4pBtru0x2o0mNNGsgAE2p 1N1LzHxq3poCShjwYwFI3CQmAkmr56Dd2TWtvNW2acRdLTSHYEct+seaq 6heDwjtwycHHzueVaaOISytw59gB17twXILSxJcF3p/GIr9+MmI2Oq+Pw FYFlCahkgVih+mDOk4wgXxVw1nCSMTAYQrfYWz+UozfF/wQw+s6GVMYLr HPq/iy+T3cIu8yVXXSbyHrIJywCjaxyJyjJk9gvahzFIfM2s6Vi7Ve1Nu g==; X-CSE-ConnectionGUID: TDZgCivhTByWLiG+qPFcig== X-CSE-MsgGUID: qOs+QFWySMu/aaIntqkhrQ== X-IronPort-AV: E=McAfee;i="6800,10657,11901"; a="89564704" X-IronPort-AV: E=Sophos;i="6.27,96,1787036400"; d="scan'208";a="89564704" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Sep 2026 17:34:44 -0700 X-CSE-ConnectionGUID: BHNkSY8YQFepNtM0ucN+cw== X-CSE-MsgGUID: hh9rLUksSzuF4+dXHSPfMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,96,1787036400"; d="scan'208";a="272291058" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orviesa009.jf.intel.com with ESMTP; 10 Sep 2026 17:34:44 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, andrew+netdev@lunn.ch, netdev@vger.kernel.org Cc: Arkadiusz Kubalewski , anthony.l.nguyen@intel.com, jacob.e.keller@intel.com, maciej.machnikowski@intel.com, przemyslaw.korba@intel.com, grzegorz.nitka@intel.com, sergey.temerkhanov@intel.com, poros@redhat.com, richardcochran@gmail.com, horms@kernel.org, Aleksandr Loktionov , Alexander Nowlin Subject: [PATCH net 06/15] ice: call PTP link change only from link events Date: Thu, 10 Sep 2026 17:34:15 -0700 Message-ID: <20260911003430.3386340-7-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20260911003430.3386340-1-anthony.l.nguyen@intel.com> References: <20260911003430.3386340-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Arkadiusz Kubalewski 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 Signed-off-by: Arkadiusz Kubalewski Signed-off-by: Przemyslaw Korba Signed-off-by: Petr Oros Reviewed-by: Maciek Machnikowski Tested-by: Alexander Nowlin Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_main.c | 10 ++++-- drivers/net/ethernet/intel/ice/ice_ptp.c | 38 +++++++++++++++++------ 2 files changed, 36 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..f32041dd8b27 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6745,7 +6745,6 @@ static int ice_up_complete(struct ice_vsi *vsi) ice_print_link_msg(vsi, true); netif_tx_start_all_queues(vsi->netdev); netif_carrier_on(vsi->netdev); - ice_ptp_link_change(pf, true); } /* Perform an initial read of the statistics registers now to @@ -7273,7 +7272,6 @@ int ice_down(struct ice_vsi *vsi) if (vsi->netdev) { vlan_err = ice_vsi_del_vlan_zero(vsi); - ice_ptp_link_change(vsi->back, false); netif_carrier_off(vsi->netdev); netif_tx_disable(vsi->netdev); } @@ -7794,6 +7792,14 @@ 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); + ice_ptp_link_change(pf, link_up); + } + /* tell the firmware we are up */ err = ice_send_version(pf); if (err) { diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 9bf3bac552f1..4dec728e219d 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -1323,9 +1323,6 @@ 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; if (!kref_get_unless_zero(&ptp_port->ref)) @@ -1334,6 +1331,9 @@ void ice_ptp_link_change(struct ice_pf *pf, bool linkup) /* Update cached link status for this port immediately */ ptp_port->link_up = linkup; + if (pf->ptp.state != ICE_PTP_READY) + goto exit_kref_put; + /* Skip HW writes if reset is in progress */ if (pf->hw.reset_ongoing) goto exit_kref_put; @@ -3298,9 +3298,13 @@ static int ice_ptp_init_owner(struct ice_pf *pf) } /** - * ice_ptp_init_work - Initialize PTP work threads + * ice_ptp_init_work - Initialize the PTP kworker * @pf: Board private structure * @ptp: PF PTP structure + * + * Allocate the kworker and initialize the periodic work function. The + * periodic work is not queued here; the caller starts it once the PTP + * state is ICE_PTP_READY. */ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) { @@ -3319,9 +3323,6 @@ static int ice_ptp_init_work(struct ice_pf *pf, struct ice_ptp *ptp) ptp->kworker = kworker; - /* Start periodic work going */ - kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); - return 0; } @@ -3443,6 +3444,22 @@ void ice_ptp_init(struct ice_pf *pf) if (err) goto err_clean_pf; + /* Seed link_up from current PHY status, since link may already be up + * (e.g. after PXE boot) with no link-change edge to catch it later. + */ + if (pf->hw.port_info) + ptp->port.link_up = + !!(pf->hw.port_info->phy.link_info.link_info & + ICE_AQ_LINK_UP); + + /* Create the kworker before restarting the PHY, which queues work on + * it in the E82x restart path. This prevents concurrent link events + * from reaching ice_ptp_port_phy_restart() while kworker is still NULL + */ + err = ice_ptp_init_work(pf, ptp); + if (err) + goto err_clean_pf; + /* Start the PHY timestamping block */ ice_ptp_reset_phy_timestamping(pf); @@ -3451,9 +3468,10 @@ void ice_ptp_init(struct ice_pf *pf) ptp->state = ICE_PTP_READY; - err = ice_ptp_init_work(pf, ptp); - if (err) - goto err_exit; + /* Start periodic work only after the state is READY; the worker + * returns without rescheduling while the state is not READY. + */ + kthread_queue_delayed_work(ptp->kworker, &ptp->work, 0); dev_info(ice_pf_to_dev(pf), "PTP init successful\n"); return; -- 2.47.1