diff mbox series

[iwl-next,4/4] ice: Initialize source timer before driving sync for single-PHY commands

Message ID 20230719220525.3153469-4-jacob.e.keller@intel.com
State Changes Requested
Headers show
Series [iwl-next,1/4] ice: PTP: Cleanup timestamp registers correctly | expand

Commit Message

Jacob Keller July 19, 2023, 10:05 p.m. UTC
The ice hardware has a synchronization mechanism used to drive the
simultaneous application of commands on both PHY ports and the source timer
in the MAC.

When issuing a sync via ice_ptp_exec_tmr_cmd(), the hardware will
simultaneously apply the commands programmed for the main timer and each
PHY port.

If the driver has previously programmed the main timer, it may still have
leftover configuration and could accidentally re-apply that command. We do
use ice_ptp_clean_cmd() to cleanup after executing a timer command.
However, it is good practice to also initialize the main timer in all cases
where we are calling ice_ptp_exec_tmr_cmd().

In order to avoid any side effects, introduce a new ICE_PTP_NOP command
which simply leaves the cmd_val bits set to 0, indicating no command is
requested. This is important because we want to ensure that the timer index
value is still set ensuring that the full timer command will be executed on
the proper timer in the hardware. It is not expected to ever need
ICE_PTP_NOP for PHY port commands. However for completeness, the value is
checked anyways.

Use this new command to initialize the main timer command in
ice_sync_phy_timer_e822 and ice_start_phy_timer_e822, both functions which
operate only on a single PHY port at a time.

This makes it clear that these flows do not affect the main timer, and
ensure that we do not rely on the behavior of previous executions clearing
the main command via ice_ptp_clean_cmd().

Signed-off-by: Siddaraju DH <siddaraju.dh@intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
I chose not to target net here since I don't think this is strictly fixing a
known issue or report. We already call ice_ptp_clean_cmd() to clear the old
timer commands so I think there isn't a strict bug being fixed. However I
think its still good practice to ensure that we initialize the main timer
anyways.

 drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 12 ++++++++++++
 drivers/net/ethernet/intel/ice/ice_ptp_hw.h |  1 +
 2 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
index 168e72de06d7..474bb4b2c839 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
@@ -131,6 +131,8 @@  void ice_ptp_src_cmd(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)
 	case ICE_PTP_READ_TIME:
 		cmd_val |= GLTSYN_CMD_READ_TIME;
 		break;
+	case ICE_PTP_NOP:
+		break;
 	}
 
 	wr32(hw, GLTSYN_CMD, cmd_val);
@@ -1275,6 +1277,8 @@  ice_ptp_one_port_cmd(struct ice_hw *hw, u8 port, enum ice_ptp_tmr_cmd cmd)
 	case ICE_PTP_ADJ_TIME_AT_TIME:
 		cmd_val |= PHY_CMD_ADJ_TIME_AT_TIME;
 		break;
+	case ICE_PTP_NOP:
+		break;
 	}
 
 	/* Tx case */
@@ -2267,6 +2271,9 @@  static int ice_sync_phy_timer_e822(struct ice_hw *hw, u8 port)
 	if (err)
 		goto err_unlock;
 
+	/* Do not perform any action on the main timer */
+	ice_ptp_src_cmd(hw, ICE_PTP_NOP);
+
 	/* Issue the sync to activate the time adjustment */
 	ice_ptp_exec_tmr_cmd(hw);
 	ice_ptp_clean_cmd(hw);
@@ -2389,6 +2396,9 @@  int ice_start_phy_timer_e822(struct ice_hw *hw, u8 port)
 	if (err)
 		return err;
 
+	/* Do not perform any action on the main timer */
+	ice_ptp_src_cmd(hw, ICE_PTP_NOP);
+
 	ice_ptp_exec_tmr_cmd(hw);
 
 	err = ice_read_phy_reg_e822(hw, port, P_REG_PS, &val);
@@ -2875,6 +2885,8 @@  static int ice_ptp_port_cmd_e810(struct ice_hw *hw, enum ice_ptp_tmr_cmd cmd)
 	case ICE_PTP_ADJ_TIME_AT_TIME:
 		cmd_val = GLTSYN_CMD_ADJ_INIT_TIME;
 		break;
+	case ICE_PTP_NOP:
+		return 0;
 	}
 
 	/* Read, modify, write */
diff --git a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
index ba4ab96073e0..28e0afb06d54 100644
--- a/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
+++ b/drivers/net/ethernet/intel/ice/ice_ptp_hw.h
@@ -10,6 +10,7 @@  enum ice_ptp_tmr_cmd {
 	ICE_PTP_ADJ_TIME,
 	ICE_PTP_ADJ_TIME_AT_TIME,
 	ICE_PTP_READ_TIME,
+	ICE_PTP_NOP,
 };
 
 enum ice_ptp_serdes {