ice: fix timestamping in reset process
Subsystems (3)
v5 cover ice: fix timestamping in reset process
PTP reset process has multiple places where timestamping can end up in an incorrect state.
This series introduces a proper state machine for PTP and refactors a large part of the code to ensure that timestamping does not break.
Jacob Keller (5):
ice: pass reset type to PTP reset functions
ice: rename verify_cached to has_ready_bitmap
ice: rename ice_ptp_tx_cfg_intr
ice: factor out ice_ptp_rebuild_owner()
ice: stop destroying and reinitalizing Tx tracker during reset
Karol Kolacinski (1):
ice: introduce PTP state machine
V4 -> V5: rebased the series
V2 -> V3: rebased the series and fixed Tx timestamps missing V1 -> V2: rebased the series and dropped already merged patches
drivers/net/ethernet/intel/ice/ice.h | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_main.c | 4 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 231 +++++++++++-------- drivers/net/ethernet/intel/ice/ice_ptp.h | 34 ++- 5 files changed, 166 insertions(+), 106 deletions(-)
base-commit: 006c8fe67ee86e7810f2aa3b365ab6de65cf2299
Signature · 1 line
2.40.1
PATCH v5 1/6 ice: introduce PTP state machine
Add PTP state machine so that the driver can correctly identify PTP state around resets.
When the driver got information about ungraceful reset, PTP was not prepared for reset and it returned error. When this situation occurs, prepare PTP before rebuilding its structures.
---
V3 -> V4: removed merge conflict leftovers
V2 -> V3: fixed Tx timestamps missing by moving ICE_PTP_READY before
ice_ptp_init_work()
drivers/net/ethernet/intel/ice/ice.h | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 112 +++++++++++-------- drivers/net/ethernet/intel/ice/ice_ptp.h | 10 ++ 4 files changed, 76 insertions(+), 49 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +0 -1
@@ -493,7 +493,6 @@ enum ice_pf_flags {ICE_FLAG_DCB_ENA ,ICE_FLAG_FD_ENA ,ICE_FLAG_PTP_SUPPORTED ,/* PTP is supported by NVM */ -ICE_FLAG_PTP ,/* PTP is enabled by software */ ICE_FLAG_ADV_FEATURES ,ICE_FLAG_TC_MQPRIO ,/* support for Multi queue TC */ ICE_FLAG_CLS_FLOWER,
drivers/net/ethernet/intel/ice/ice_ethtool.c +1 -1
@@ -3361,7 +3361,7 @@ ice_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)struct ice_pf *pf =ice_netdev_to_pf (dev);/* only report timestamping if PTP is enabled */ -if (!test_bit (ICE_FLAG_PTP , pf->flags)) +if (pf->ptp.state !=ICE_PTP_READY )return ethtool_op_get_ts_info (dev, info); info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE |
drivers/net/ethernet/intel/ice/ice_ptp.c +65 -47
212 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp.h +10 -0
@@ -203,8 +203,17 @@ struct ice_ptp_port_owner {#define GLTSYN_TGT_H_IDX_MAX 4 +enum ice_ptp_state { +ICE_PTP_UNINIT =0 , +ICE_PTP_INITIALIZING , +ICE_PTP_READY , +ICE_PTP_RESETTING , +ICE_PTP_ERROR , +}; +/** * struct ice_ptp - data used for integrating with CONFIG_PTP_1588_CLOCK +* @state: current state of PTP state machine * @tx_interrupt_mode: the TX interrupt mode for the PTP clock * @port: data for the PHY port initialization procedure * @ports_owner: data for the auxiliary driver owner
@@ -227,6 +236,7 @@ struct ice_ptp_port_owner {* @late_cached_phc_updates: number of times cached PHC update is late */ struct ice_ptp { +enum ice_ptp_state state;enum ice_ptp_tx_interrupt tx_interrupt_mode;struct ice_ptp_port port;struct ice_ptp_port_owner ports_owner;
Signature · 1 line
2.40.1
RE: [Intel-wired-lan] [PATCH v5 iwl-next 1/6] ice: introduce PTP state machine
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Karol Kolacinski
Sent: Monday, January 8, 2024 6:17 PM
To: [email protected]
Cc: Keller, Jacob E <[email protected]>; [email protected]; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: [Intel-wired-lan] [PATCH v5 iwl-next 1/6] ice: introduce PTP state machineAdd PTP state machine so that the driver can correctly identify PTP state around resets.
When the driver got information about ungraceful reset, PTP was not prepared for reset and it returned error. When this situation occurs, prepare PTP before rebuilding its structures.Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>---
V3 -> V4: removed merge conflict leftovers
V2 -> V3: fixed Tx timestamps missing by movingICE_PTP_READYbefore
Quoted 8 lines
ice_ptp_init_work()drivers/net/ethernet/intel/ice/ice.h | 1 - drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 112 +++++++++++-------- drivers/net/ethernet/intel/ice/ice_ptp.h | 10 ++ 4 files changed, 76 insertions(+), 49 deletions(-)
Re: [PATCH v5 iwl-next 1/6] ice: introduce PTP state machine
In reply to Karol KolacinskiOn Mon, Jan 08, 2024 at 01:47:12PM +0100, Karol Kolacinski wrote:
Should there be a "From: Jacob" line here to
match the Signed-off-by below?
Quoted 9 lines
Add PTP state machine so that the driver can correctly identify PTP state around resets.
When the driver got information about ungraceful reset, PTP was not prepared for reset and it returned error. When this situation occurs, prepare PTP before rebuilding its structures.Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>
Hi Karol and Jacob,
FWIIW, The combination of both a Signed-off-by and Reviewed-by tag from Jacob seems a little odd to me. If he authored the patch then I would have gone with the following (along with the From line mentioned above):
Otherwise, if he reviewed the patch I would have gone with:
...
Quoted 1 line
drivers/net/ethernet/intel/ice/ice_ptp.c +0
-0
...
drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_reset(struct ice_pf *pf) · line 2687
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +9
-0@@ -2640,6 +2676,16 @@ void ice_ptp_reset(struct ice_pf *pf)int err, itr =1 ;u64 time_diff; +if (ptp->state !=ICE_PTP_RESETTING ) { +if (ptp->state ==ICE_PTP_READY ) { +ice_ptp_prepare_for_reset (pf); + }else { + err = -EINVAL ; +dev_err (ice_pf_to_dev (pf),"PTP was not initialized\n" ); + goto err; + } + }
nit: perhaps this following is slightly nicer?
(completely untested!)
if (ptp->state == ICE_PTP_READY) {
ice_ptp_prepare_for_reset(pf);
} else if (ptp->state != ICE_PTP_RESETTING) {
err = -EINVAL;
dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n");
goto err;
}Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1
-0+if (test_bit (ICE_PFR_REQ , pf->state) || !ice_pf_src_tmr_owned (pf)) goto pfr;
...
RE: [PATCH v5 iwl-next 1/6] ice: introduce PTP state machine
Quoted 32 lines
-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Monday, January 15, 2024 2:33 AM
To: Kolacinski, Karol <[email protected]>
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>; Keller, Jacob E <[email protected]>
Subject: Re: [PATCH v5 iwl-next 1/6] ice: introduce PTP state machineOn Mon, Jan 08, 2024 at 01:47:12PM +0100, Karol Kolacinski wrote:
Should there be a "From: Jacob" line here to
match the Signed-off-by below?Quoted 9 lines
Add PTP state machine so that the driver can correctly identify PTP state around resets.
When the driver got information about ungraceful reset, PTP was not prepared for reset and it returned error. When this situation occurs, prepare PTP before rebuilding its structures.Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>Hi Karol and Jacob,
FWIIW, The combination of both a Signed-off-by and Reviewed-by tag from Jacob seems a little odd to me. If he authored the patch then I would have gone with the following (along with the From line mentioned above):
Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Otherwise, if he reviewed the patch I would have gone with:
Reviewed-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>
It's a bit odd, because I authored the initial code and patches some time ago, and Karol has been working to rebase and re-organize the code, so in some sense he authored part of this. I think a Co-authored would be suitable here. Additionally, I reviewed the result before it was published here.
Thanks,
Jake
Quoted 38 lines
...
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/net/ethernet/intel/ice/ice_ptp.c...
drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_reset(struct ice_pf *pf) · line 2687
Quoted 13 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +9
-0@@ -2640,6 +2676,16 @@ void ice_ptp_reset(struct ice_pf *pf)int err, itr =1 ;u64 time_diff; +if (ptp->state !=ICE_PTP_RESETTING ) { +if (ptp->state ==ICE_PTP_READY ) { +ice_ptp_prepare_for_reset (pf); + }else { + err = -EINVAL ; +dev_err (ice_pf_to_dev (pf),"PTP was not initialized\n" ); + goto err; + } + }nit: perhaps this following is slightly nicer?
(completely untested!) if (ptp->state == ICE_PTP_READY) { ice_ptp_prepare_for_reset(pf); } else if (ptp->state != ICE_PTP_RESETTING) { err = -EINVAL; dev_err(ice_pf_to_dev(pf), "PTP was not initialized\n"); goto err; }Quoted 4 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +1
-0+if (test_bit (ICE_PFR_REQ , pf->state) || !ice_pf_src_tmr_owned (pf)) goto pfr;...
Simon Horman
reviewerRe: [PATCH v5 iwl-next 1/6] ice: introduce PTP state machine
Quoted 35 lines · Jacob E
Quoted 35 lines
-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Monday, January 15, 2024 2:33 AM
To: Kolacinski, Karol <[email protected]>
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>; Keller, Jacob E <[email protected]>
Subject: Re: [PATCH v5 iwl-next 1/6] ice: introduce PTP state machineOn Mon, Jan 08, 2024 at 01:47:12PM +0100, Karol Kolacinski wrote:
Should there be a "From: Jacob" line here to
match the Signed-off-by below?Quoted 9 lines
Add PTP state machine so that the driver can correctly identify PTP state around resets.
When the driver got information about ungraceful reset, PTP was not prepared for reset and it returned error. When this situation occurs, prepare PTP before rebuilding its structures.Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>Hi Karol and Jacob,
FWIIW, The combination of both a Signed-off-by and Reviewed-by tag from Jacob seems a little odd to me. If he authored the patch then I would have gone with the following (along with the From line mentioned above):
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>
Quoted 7 lines
Quoted 5 lines
Otherwise, if he reviewed the patch I would have gone with:
Reviewed-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>It's a bit odd, because I authored the initial code and patches some time ago, and Karol has been working to rebase and re-organize the code, so in some sense he authored part of this. I think a Co-authored would be suitable here. Additionally, I reviewed the result before it was published here.
Understood. I agree Co-authored might be useful here.
PATCH v5 2/6 ice: pass reset type to PTP reset functions
In reply to Karol KolacinskiFrom: Jacob Keller <[email protected]>
The ice_ptp_prepare_for_reset() and ice_ptp_reset() functions currently check the pf->flags ICE_FLAG_PFR_REQ bit to determine if the current reset is a PF reset or not.
This is problematic, because it is possible that a PF reset and a higher level reset (CORE reset, GLOBAL reset, EMP reset) are requested simultaneously. In that case, the driver performs the highest level reset requested. However, the ICE_FLAG_PFR_REQ flag will still be set.
The main driver reset functions take an enum ice_reset_req indicating which reset is actually being performed. Pass this data into the PTP functions and rely on this instead of relying on the driver flags.
This ensures that the PTP code performs the proper level of reset that the driver is actually undergoing.
---
V4 -> V5: added missing ice_ptp_reset() definition
drivers/net/ethernet/intel/ice/ice_main.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_ptp.c | 13 +++++++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +2 -2
@@ -613,7 +613,7 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)ice_pf_dis_all_vsi (pf, false);if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags)) -ice_ptp_prepare_for_reset (pf); +ice_ptp_prepare_for_reset (pf, reset_type);if (ice_is_feature_supported (pf,ICE_F_GNSS ))ice_gnss_exit (pf);
@@ -7554,7 +7554,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)* fail. */ if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags)) -ice_ptp_reset (pf); +ice_ptp_reset (pf, reset_type);if (ice_is_feature_supported (pf,ICE_F_GNSS ))ice_gnss_init (pf);
drivers/net/ethernet/intel/ice/ice_ptp.c +7 -6
@@ -2631,8 +2631,9 @@ static void ice_ptp_periodic_work(struct kthread_work *work)/** * ice_ptp_prepare_for_reset - Prepare PTP for reset * @pf: Board private structure +* @reset_type: the reset type being performed */ -void ice_ptp_prepare_for_reset (struct ice_pf *pf) +void ice_ptp_prepare_for_reset (struct ice_pf *pf,enum ice_reset_req reset_type) {struct ice_ptp *ptp = &pf->ptp;u8 src_tmr;
@@ -2647,7 +2648,7 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf)kthread_cancel_delayed_work_sync (&ptp->work); -if (test_bit (ICE_PFR_REQ , pf->state)) +if (reset_type ==ICE_RESET_PFR )return ;ice_ptp_release_tx_tracker (pf, &pf->ptp.port.tx);
@@ -2667,8 +2668,9 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf)/** * ice_ptp_reset - Initialize PTP hardware clock support after reset * @pf: Board private structure +* @reset_type: the reset type being performed */ -void ice_ptp_reset (struct ice_pf *pf) +void ice_ptp_reset (struct ice_pf *pf,enum ice_reset_req reset_type) {struct ice_ptp *ptp = &pf->ptp;struct ice_hw *hw = &pf->hw;
@@ -2678,7 +2680,7 @@ void ice_ptp_reset(struct ice_pf *pf)if (ptp->state !=ICE_PTP_RESETTING ) {if (ptp->state ==ICE_PTP_READY ) { -ice_ptp_prepare_for_reset (pf); +ice_ptp_prepare_for_reset (pf, reset_type); }else { err = -EINVAL ;dev_err (ice_pf_to_dev (pf),"PTP was not initialized\n" );
@@ -2686,8 +2688,7 @@ void ice_ptp_reset(struct ice_pf *pf) } } -if (test_bit (ICE_PFR_REQ , pf->state) || - !ice_pf_src_tmr_owned (pf)) +if (reset_type ==ICE_RESET_PFR || !ice_pf_src_tmr_owned (pf)) goto pfr; err =ice_ptp_init_phc (hw);
drivers/net/ethernet/intel/ice/ice_ptp.h +12 -4
@@ -314,8 +314,9 @@ enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);u64 ice_ptp_get_rx_hwts (const union ice_32b_rx_flex_desc *rx_desc,const struct ice_pkt_ctx *pkt_ctx); -void ice_ptp_reset (struct ice_pf *pf); -void ice_ptp_prepare_for_reset (struct ice_pf *pf); +void ice_ptp_reset (struct ice_pf *pf,enum ice_reset_req reset_type); +void ice_ptp_prepare_for_reset (struct ice_pf *pf, +enum ice_reset_req reset_type);void ice_ptp_init (struct ice_pf *pf);void ice_ptp_release (struct ice_pf *pf);void ice_ptp_link_change (struct ice_pf *pf,u8 port,bool linkup);
@@ -355,8 +356,15 @@ ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,return 0 ; } -static inline void ice_ptp_reset (struct ice_pf *pf) { } -static inline void ice_ptp_prepare_for_reset (struct ice_pf *pf) { } +static inline void ice_ptp_reset (struct ice_pf *pf, +enum ice_reset_req reset_type) +{ +} + +static inline void ice_ptp_prepare_for_reset (struct ice_pf *pf, +enum ice_reset_req reset_type) +{ +}static inline void ice_ptp_init (struct ice_pf *pf) { }static inline void ice_ptp_release (struct ice_pf *pf) { }static inline void ice_ptp_link_change (struct ice_pf *pf,u8 port,bool linkup)
Signature · 1 line
2.40.1
RE: [Intel-wired-lan] [PATCH v5 iwl-next 2/6] ice: pass reset type to PTP reset functions
Quoted 28 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Karol Kolacinski
Sent: Monday, January 8, 2024 6:17 PM
To: [email protected]
Cc: Keller, Jacob E <[email protected]>; [email protected]; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: [Intel-wired-lan] [PATCH v5 iwl-next 2/6] ice: pass reset type to PTP reset functionsFrom: Jacob Keller <[email protected]>
The
ice_ptp_prepare_for_reset()andice_ptp_reset()functions currently check thepf->flagsICE_FLAG_PFR_REQbit to determine if the current reset is a PF reset or not.This is problematic, because it is possible that a PF reset and a higher level reset (CORE reset, GLOBAL reset, EMP reset) are requested simultaneously. In that case, the driver performs the highest level reset requested. However, the
ICE_FLAG_PFR_REQflag will still be set.The main driver reset functions take an enum
ice_reset_reqindicating which reset is actually being performed. Pass this data into the PTP functions and rely on this instead of relying on the driver flags.This ensures that the PTP code performs the proper level of reset that the driver is actually undergoing.
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>
Quoted 8 lines
---
V4 -> V5: added missingice_ptp_reset()definitiondrivers/net/ethernet/intel/ice/ice_main.c | 4 ++-- drivers/net/ethernet/intel/ice/ice_ptp.c | 13 +++++++------ drivers/net/ethernet/intel/ice/ice_ptp.h | 16 ++++++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-)
PATCH v5 3/6 ice: rename verify_cached to has_ready_bitmap
In reply to Karol KolacinskiFrom: Jacob Keller <[email protected]>
The tx->verify_cached flag is used to inform the Tx timestamp tracking code whether it needs to verify the cached Tx timestamp value against a previous captured value. This is necessary on E810 hardware which does not have a Tx timestamp ready bitmap.
In addition, we currently rely on the fact that the ice_get_phy_tx_tstamp_ready() function returns all 1s for E810 hardware. Instead of introducing a brand new flag, rename and verify_cached to has_ready_bitmap, inverting the relevant checks.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 31 ++++++++++++------------ drivers/net/ethernet/intel/ice/ice_ptp.h | 8 +++--- 2 files changed, 20 insertions(+), 19 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +15 -16
@@ -601,17 +601,13 @@ void ice_ptp_complete_tx_single_tstamp(struct ice_ptp_tx *tx)/* Read the low 32 bit value */ raw_tstamp |= (u64 )rd32 (&pf->hw,PF_SB_ATQBAH ); -/* For PHYs which don't implement a proper timestamp ready bitmap, -* verify that the timestamp value is different from the last cached -* timestamp. If it is not, skip this for now assuming it hasn't yet -* been captured by hardware. +/* Devices using this interface always verify the timestamp differs +* relative to the last cached timestamp value. */ -if (!drop_ts && tx->verify_cached && - raw_tstamp == tx->tstamps[idx].cached_tstamp) +if (raw_tstamp == tx->tstamps[idx].cached_tstamp)return ; -if (tx->verify_cached && raw_tstamp) - tx->tstamps[idx].cached_tstamp = raw_tstamp; + tx->tstamps[idx].cached_tstamp = raw_tstamp;clear_bit (idx, tx->in_use); skb = tx->tstamps[idx].skb; tx->tstamps[idx].skb =NULL ;
@@ -701,9 +697,11 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) hw = &pf->hw;/* Read the Tx ready status first */ - err =ice_get_phy_tx_tstamp_ready (hw, tx->block, &tstamp_ready); -if (err) -return ; +if (tx->has_ready_bitmap) { + err =ice_get_phy_tx_tstamp_ready (hw, tx->block, &tstamp_ready); +if (err) +return ; + }/* Drop packets if the link went down */ link_up = ptp_port->link_up;
@@ -731,7 +729,8 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx)* If we do not, the hardware logic for generating a new * interrupt can get stuck on some devices. */ -if (!(tstamp_ready &BIT_ULL (phy_idx))) { +if (tx->has_ready_bitmap && + !(tstamp_ready &BIT_ULL (phy_idx))) {if (drop_ts) goto skip_ts_read;
@@ -751,7 +750,7 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx)* from the last cached timestamp. If it is not, skip this for * now assuming it hasn't yet been captured by hardware. */ -if (!drop_ts && tx->verify_cached && +if (!drop_ts && !tx->has_ready_bitmap && raw_tstamp == tx->tstamps[idx].cached_tstamp)continue ;
@@ -761,7 +760,7 @@ static void ice_ptp_process_tx_tstamp(struct ice_ptp_tx *tx) skip_ts_read:spin_lock_irqsave (&tx->lock, flags); -if (tx->verify_cached && raw_tstamp) +if (!tx->has_ready_bitmap && raw_tstamp) tx->tstamps[idx].cached_tstamp = raw_tstamp;clear_bit (idx, tx->in_use); skb = tx->tstamps[idx].skb;
@@ -1014,7 +1013,7 @@ ice_ptp_init_tx_e82x(struct ice_pf *pf, struct ice_ptp_tx *tx, u8 port) tx->block = port /ICE_PORTS_PER_QUAD ; tx->offset = (port %ICE_PORTS_PER_QUAD ) *INDEX_PER_PORT_E82X ; tx->len =INDEX_PER_PORT_E82X ; - tx->verify_cached =0 ; + tx->has_ready_bitmap =1 ;return ice_ptp_alloc_tx_tracker (tx); }
@@ -1037,7 +1036,7 @@ ice_ptp_init_tx_e810(struct ice_pf *pf, struct ice_ptp_tx *tx)* verify new timestamps against cached copy of the last read * timestamp. */ - tx->verify_cached =1 ; + tx->has_ready_bitmap =0 ;return ice_ptp_alloc_tx_tracker (tx); }
drivers/net/ethernet/intel/ice/ice_ptp.h +5 -3
@@ -100,7 +100,7 @@ struct ice_perout_channel {* the last timestamp we read for a given index. If the current timestamp * value is the same as the cached value, we assume a new timestamp hasn't * been captured. This avoids reporting stale timestamps to the stack. This is -* only done if the verify_cached flag is set in ice_ptp_tx structure. +* only done if the has_ready_bitmap flag is not set in ice_ptp_tx structure. */ struct ice_tx_tstamp {struct sk_buff *skb;
@@ -130,7 +130,9 @@ enum ice_tx_tstamp_work {* @init: if true, the tracker is initialized; * @calibrating: if true, the PHY is calibrating the Tx offset. During this * window, timestamps are temporarily disabled. -* @verify_cached: if true, verify new timestamp differs from last read value +* @has_ready_bitmap: if true, the hardware has a valid Tx timestamp ready +* bitmap register. If false, fall back to verifying new +* timestamp values against previously cached copy. * @last_ll_ts_idx_read: index of the last LL TS read by the FW */ struct ice_ptp_tx {
@@ -143,7 +145,7 @@ struct ice_ptp_tx {u8 len; u8 init : 1; u8 calibrating : 1; - u8 verify_cached : 1; + u8 has_ready_bitmap : 1;s8 last_ll_ts_idx_read; };
Signature · 1 line
2.40.1
RE: [Intel-wired-lan] [PATCH v5 iwl-next 3/6] ice: rename verify_cached to has_ready_bitmap
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Karol Kolacinski
Sent: Monday, January 8, 2024 6:17 PM
To: [email protected]
Cc: Keller, Jacob E <[email protected]>; [email protected]; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: [Intel-wired-lan] [PATCH v5 iwl-next 3/6] ice: renameverify_cachedtohas_ready_bitmapFrom: Jacob Keller <[email protected]>
The
tx->verify_cachedflag is used to inform the Tx timestamp tracking code whether it needs to verify the cached Tx timestamp value against a previous captured value. This is necessary on E810 hardware which does not have a Tx timestamp ready bitmap.In addition, we currently rely on the fact that the
ice_get_phy_tx_tstamp_ready()function returns all 1s for E810 hardware. Instead of introducing a brand new flag, rename andverify_cachedtohas_ready_bitmap, inverting the relevant checks.
Quoted 8 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ptp.c | 31 ++++++++++++------------ drivers/net/ethernet/intel/ice/ice_ptp.h | 8 +++--- 2 files changed, 20 insertions(+), 19 deletions(-)
Simon Horman
reviewerRe: [PATCH v5 iwl-next 3/6] ice: rename verify_cached to has_ready_bitmap
In reply to Karol KolacinskiQuoted 11 lines · Karol Kolacinski
From: Jacob Keller <[email protected]>
The
tx->verify_cachedflag is used to inform the Tx timestamp tracking code whether it needs to verify the cached Tx timestamp value against a previous captured value. This is necessary on E810 hardware which does not have a Tx timestamp ready bitmap.In addition, we currently rely on the fact that the
ice_get_phy_tx_tstamp_ready()function returns all 1s for E810 hardware. Instead of introducing a brand new flag, rename andverify_cachedtohas_ready_bitmap, inverting the relevant checks.
From the above I understand what this patch does. But not why this change is desirable.
I think it would be useful to state that.
Also, perhaps it just me, but it seems that renaming verify_cached and weeding out assumptions about the return value of ice_get_phy_tx_tstamp_ready() are separate, albeit related changes:
I might have gone for two patches instead of one.
Quoted 3 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>
...
RE: [PATCH v5 iwl-next 3/6] ice: rename verify_cached to has_ready_bitmap
Quoted 20 lines
-----Original Message-----
From: Simon Horman <[email protected]>
Sent: Monday, January 15, 2024 2:37 AM
To: Kolacinski, Karol <[email protected]>
Cc: [email protected]; [email protected]; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>; Keller, Jacob E <[email protected]>
Subject: Re: [PATCH v5 iwl-next 3/6] ice: renameverify_cachedtohas_ready_bitmapQuoted 7 lines · Karol Kolacinski
From: Jacob Keller <[email protected]>
The
tx->verify_cachedflag is used to inform the Tx timestamp tracking code whether it needs to verify the cached Tx timestamp value against a previous captured value. This is necessary on E810 hardware which does not have a Tx timestamp ready bitmap.
Quoted 9 lines
Quoted 4 lines
In addition, we currently rely on the fact that the
ice_get_phy_tx_tstamp_ready()function returns all 1s for E810 hardware. Instead of introducing a brand new flag, rename andverify_cachedtohas_ready_bitmap, inverting the relevant checks.From the above I understand what this patch does. But not why this change is desirable.
I think it would be useful to state that.
The main motivation is that it is easier to understand the resulting behavior than to rely on a hidden assumption of how ice_get_phy_tx_stamp_ready() works.
Quoted 6 lines
Also, perhaps it just me, but it seems that renaming
verify_cachedand weeding out assumptions about the return value ofice_get_phy_tx_tstamp_ready()are separate, albeit related changes:
I might have gone for two patches instead of one.
It could possibly be split up. The motivation was to stop relying on the fact that ice_get_phy_tx_tstamp_ready() returns all 1s, since we already know whether we can safely check it or not. But then using "verify_cached" to do so reads weird with the code because its name no longer clearly indicates its purpose. Instead, we rename it to better reflect its intention.
Thanks,
Jake
Quoted 5 lines
Quoted 3 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>...
PATCH v5 4/6 ice: rename ice_ptp_tx_cfg_intr
In reply to Karol KolacinskiFrom: Jacob Keller <[email protected]>
The ice_ptp_tx_cfg_intr() function sends a control queue message to configure the PHY timestamp interrupt block. This is a very similar name to a function which is used to configure the MAC Other Interrupt Cause Enable register.
Rename this function to ice_ptp_cfg_phy_interrupt in order to make it more obvious to the reader what action it performs, and distinguish it from other similarly named functions.
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +6 -6
@@ -1455,14 +1455,14 @@ void ice_ptp_link_change(struct ice_pf *pf, u8 port, bool linkup) }/** -* ice_ptp_tx_ena_intr - Enable or disable the Tx timestamp interrupt +* ice_ptp_cfg_phy_interrupt - Configure PHY interrupt settings * @pf: PF private structure * @ena: bool value to enable or disable interrupt * @threshold: Minimum number of packets at which intr is triggered * * Utility function to enable or disable Tx timestamp interrupt and threshold */ -static int ice_ptp_tx_ena_intr (struct ice_pf *pf,bool ena,u32 threshold) +static int ice_ptp_cfg_phy_interrupt (struct ice_pf *pf,bool ena,u32 threshold) {struct ice_hw *hw = &pf->hw;int err =0 ;
@@ -2674,8 +2674,8 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)struct ice_ptp *ptp = &pf->ptp;struct ice_hw *hw = &pf->hw;struct timespec64 ts; -int err, itr =1 ;u64 time_diff; +int err;if (ptp->state !=ICE_PTP_RESETTING ) {if (ptp->state ==ICE_PTP_READY ) {
@@ -2728,7 +2728,7 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)if (!ice_is_e810 (hw)) {/* Enable quad interrupts */ - err =ice_ptp_tx_ena_intr (pf, true, itr); + err =ice_ptp_cfg_phy_interrupt (pf, true,1 );if (err) goto err; }
@@ -2981,7 +2981,7 @@ static int ice_ptp_init_owner(struct ice_pf *pf) {struct ice_hw *hw = &pf->hw;struct timespec64 ts; -int err, itr =1 ; +int err; err =ice_ptp_init_phc (hw);if (err) {
@@ -3016,7 +3016,7 @@ static int ice_ptp_init_owner(struct ice_pf *pf)if (!ice_is_e810 (hw)) {/* Enable quad interrupts */ - err =ice_ptp_tx_ena_intr (pf, true, itr); + err =ice_ptp_cfg_phy_interrupt (pf, true,1 );if (err) goto err_exit; }
Signature · 1 line
2.40.1
RE: [Intel-wired-lan] [PATCH v5 iwl-next 4/6] ice: rename ice_ptp_tx_cfg_intr
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Karol Kolacinski
Sent: Monday, January 8, 2024 6:17 PM
To: [email protected]
Cc: Keller, Jacob E <[email protected]>; [email protected]; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: [Intel-wired-lan] [PATCH v5 iwl-next 4/6] ice: renameice_ptp_tx_cfg_intrFrom: Jacob Keller <[email protected]>
The
ice_ptp_tx_cfg_intr()function sends a control queue message to configure the PHY timestamp interrupt block. This is a very similar name to a function which is used to configure the MAC Other Interrupt Cause Enable register.Rename this function to
ice_ptp_cfg_phy_interruptin order to make it more obvious to the reader what action it performs, and distinguish it from other similarly named functions.
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ptp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
PATCH v5 5/6 ice: factor out ice_ptp_rebuild_owner()
In reply to Karol KolacinskiFrom: Jacob Keller <[email protected]>
The ice_ptp_reset() function uses a goto to skip past clock owner operations if performing a PF reset or if the device is not the clock owner. This is a bit confusing. Factor this out into ice_ptp_rebuild_owner() instead.
The ice_ptp_reset() function is called by ice_rebuild() to restore PTP functionality after a device reset. Follow the convention set by the ice_main.c file and rename this function to ice_ptp_rebuild(), in the same way that we have ice_prepare_for_reset() and ice_ptp_prepare_for_reset().
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 66 ++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 6 +-- 3 files changed, 44 insertions(+), 30 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -7554,7 +7554,7 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)* fail. */ if (test_bit (ICE_FLAG_PTP_SUPPORTED , pf->flags)) -ice_ptp_reset (pf, reset_type); +ice_ptp_rebuild (pf, reset_type);if (ice_is_feature_supported (pf,ICE_F_GNSS ))ice_gnss_init (pf);
drivers/net/ethernet/intel/ice/ice_ptp.c +40 -26
114 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ptp.h +3 -3
@@ -316,7 +316,7 @@ enum ice_tx_tstamp_work ice_ptp_process_ts(struct ice_pf *pf);u64 ice_ptp_get_rx_hwts (const union ice_32b_rx_flex_desc *rx_desc,const struct ice_pkt_ctx *pkt_ctx); -void ice_ptp_reset (struct ice_pf *pf,enum ice_reset_req reset_type); +void ice_ptp_rebuild (struct ice_pf *pf,enum ice_reset_req reset_type);void ice_ptp_prepare_for_reset (struct ice_pf *pf,enum ice_reset_req reset_type);void ice_ptp_init (struct ice_pf *pf);
@@ -358,8 +358,8 @@ ice_ptp_get_rx_hwts(const union ice_32b_rx_flex_desc *rx_desc,return 0 ; } -static inline void ice_ptp_reset (struct ice_pf *pf, -enum ice_reset_req reset_type) +static inline void ice_ptp_rebuild (struct ice_pf *pf, +enum ice_reset_req reset_type) { }
Signature · 1 line
2.40.1
RE: [Intel-wired-lan] [PATCH v5 iwl-next 5/6] ice: factor out ice_ptp_rebuild_owner()
Quoted 20 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Karol Kolacinski
Sent: Monday, January 8, 2024 6:17 PM
To: [email protected]
Cc: Keller, Jacob E <[email protected]>; [email protected]; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: [Intel-wired-lan] [PATCH v5 iwl-next 5/6] ice: factor outice_ptp_rebuild_owner()From: Jacob Keller <[email protected]>
The
ice_ptp_reset()function uses a goto to skip past clock owner operations if performing a PF reset or if the device is not the clock owner. This is a bit confusing. Factor this out intoice_ptp_rebuild_owner()instead.The
ice_ptp_reset()function is called byice_rebuild()to restore PTP functionality after a device reset. Follow the convention set by theice_main.cfile and rename this function toice_ptp_rebuild(), in the same way that we haveice_prepare_for_reset()andice_ptp_prepare_for_reset().
Quoted 9 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 66 ++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 6 +-- 3 files changed, 44 insertions(+), 30 deletions(-)
Simon Horman
reviewerRe: [PATCH v5 iwl-next 5/6] ice: factor out ice_ptp_rebuild_owner()
In reply to Karol KolacinskiQuoted 7 lines · Karol Kolacinski
From: Jacob Keller <[email protected]>
The
ice_ptp_reset()function uses a goto to skip past clock owner operations if performing a PF reset or if the device is not the clock owner. This is a bit confusing. Factor this out intoice_ptp_rebuild_owner()instead.
Quoted 5 lines
The
ice_ptp_reset()function is called byice_rebuild()to restore PTP functionality after a device reset. Follow the convention set by theice_main.cfile and rename this function toice_ptp_rebuild(), in the same way that we haveice_prepare_for_reset()andice_ptp_prepare_for_reset().
nit: This feels more like two changes than one,
which I might have put into two patches.
Quoted 3 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>
...
Quoted 69 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +9
-20@@ -2665,11 +2665,13 @@ void ice_ptp_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type) }/** -* ice_ptp_reset - Initialize PTP hardware clock support after reset +* ice_ptp_rebuild_owner - Initialize PTP clock owner after reset * @pf: Board private structure -* @reset_type: the reset type being performed +* +* Companion function for ice_ptp_rebuild() which handles tasks that only the +* PTP clock owner instance should perform. */ -void ice_ptp_reset (struct ice_pf *pf,enum ice_reset_req reset_type) +static int ice_ptp_rebuild_owner (struct ice_pf *pf) {struct ice_ptp *ptp = &pf->ptp;struct ice_hw *hw = &pf->hw;@@ -2677,34 +2679,21 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)u64 time_diff;int err; -if (ptp->state !=ICE_PTP_RESETTING ) { -if (ptp->state ==ICE_PTP_READY ) { -ice_ptp_prepare_for_reset (pf, reset_type); - }else { - err = -EINVAL ; -dev_err (ice_pf_to_dev (pf),"PTP was not initialized\n" ); - goto err; - } - } - -if (reset_type ==ICE_RESET_PFR || !ice_pf_src_tmr_owned (pf)) - goto pfr; - err =ice_ptp_init_phc (hw);if (err) - goto err; +return err;/* Acquire the global hardware lock */ if (!ice_ptp_lock (hw)) { err = -EBUSY ; - goto err; +return err; }/* Write the increment time value to PHY and LAN */ err =ice_ptp_write_incval (hw,ice_base_incval (pf));if (err) {ice_ptp_unlock (hw); - goto err; +return err; }/* Write the initial Time value to PHY and LAN using the cached PHC @@ -2720,7 +2709,7 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) err =ice_ptp_write_init (pf, &ts);if (err) {ice_ptp_unlock (hw); - goto err; +return err; }/* Release the global hardware lock */
drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) · line 2724
Quoted 7 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +4
-0@@ -2729,11 +2718,41 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type)if (!ice_is_e810 (hw)) {/* Enable quad interrupts */ err =ice_ptp_cfg_phy_interrupt (pf, true,1 ); +if (err) +return err; + +ice_ptp_restart_all_phy (pf);
The conditions for calling ice_ptp_restart_all_phy() seem to have changed (though perhaps in practice they are the same). And the ordering of this operation relative to the following code has changed:
/* Init Tx structures */
if (ice_is_e810(&pf->hw)) {
err = ice_ptp_init_tx_e810(pf, &ptp->port.tx);
} else {
kthread_init_delayed_work(&ptp->port.ov_work,
ice_ptp_wait_for_offsets);
err = ice_ptp_init_tx_e82x(pf, &ptp->port.tx,
ptp->port.port_num);
}
ptp->state = ICE_PTP_READY;Is this intentional?
I do see that the above code is removed in the following patch, and replaced by a call to ice_ptp_flush_all_tx_tracker() in ice_ptp_rebuild_owner(). But perhaps this patch should move this code block code to that location?
Quoted 47 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +27
-6+ } + +return 0 ; +} + +/** +* ice_ptp_rebuild - Initialize PTP hardware clock support after reset +* @pf: Board private structure +* @reset_type: the reset type being performed +*/ +void ice_ptp_rebuild (struct ice_pf *pf,enum ice_reset_req reset_type) +{ +struct ice_ptp *ptp = &pf->ptp; +int err; + +if (ptp->state !=ICE_PTP_RESETTING ) { +if (ptp->state ==ICE_PTP_READY ) { +ice_ptp_prepare_for_reset (pf, reset_type); + }else { + err = -EINVAL ; +dev_err (ice_pf_to_dev (pf),"PTP was not initialized\n" ); + goto err; + } + } + +if (ice_pf_src_tmr_owned (pf) && reset_type !=ICE_RESET_PFR ) { + err =ice_ptp_rebuild_owner (pf);if (err) goto err; } -pfr:/* Init Tx structures */ if (ice_is_e810 (&pf->hw)) { err =ice_ptp_init_tx_e810 (pf, &ptp->port.tx);@@ -2748,11 +2767,6 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) ptp->state =ICE_PTP_READY ; -/* Restart the PHY timestamping block */ -if (!test_bit (ICE_PFR_REQ , pf->state) && -ice_pf_src_tmr_owned (pf)) -ice_ptp_restart_all_phy (pf); -/* Start periodic work going */ kthread_queue_delayed_work (ptp->kworker, &ptp->work,0 );
...
Re: [PATCH v5 iwl-next 5/6] ice: factor out ice_ptp_rebuild_owner()
Quoted 24 lines · Simon Horman
drivers/net/ethernet/intel/ice/ice_ptp.c void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) · line 2724
Quoted 8 lines
drivers/net/ethernet/intel/ice/ice_ptp.c +4
-0@@ -2729,11 +2718,41 @@ void ice_ptp_reset(struct ice_pf *pf, enum ice_reset_req reset_type) if (!ice_is_e810(hw)) { /* Enable quad interrupts */ err = ice_ptp_cfg_phy_interrupt(pf, true, 1); + if (err) + return err; + + ice_ptp_restart_all_phy(pf);The conditions for calling
ice_ptp_restart_all_phy()seem to have changed (though perhaps in practice they are the same). And the ordering of this operation relative to the following code has changed:/* Init Tx structures */
if (ice_is_e810(&pf->hw)) {
err =ice_ptp_init_tx_e810(pf, &ptp->port.tx); } else {kthread_init_delayed_work(&ptp->port.ov_work, ice_ptp_wait_for_offsets); err =ice_ptp_init_tx_e82x(pf, &ptp->port.tx, ptp->port.port_num); }
Quoted 8 lines
ptp->state=ICE_PTP_READY;Is this intentional?
I do see that the above code is removed in the following patch, and replaced by a call to
ice_ptp_flush_all_tx_tracker()inice_ptp_rebuild_owner(). But perhaps this patch should move this code block code to that location?
ice_ptp_restart_all_phy() was previously done for clock owner on non-PF reset. This patch adds only a check if the device is not E810, because only E82X devices need PHY restart.
ice_ptp_init_tx_<dev> location does not matter as long as it's done before setting ICE_PTP_READY.
Thanks,
Karol
PATCH v5 6/6 ice: stop destroying and reinitalizing Tx tracker during reset
In reply to Karol KolacinskiFrom: Jacob Keller <[email protected]>
The ice driver currently attempts to destroy and re-initialize the Tx timestamp tracker during the reset flow. The release of the Tx tracker only happened during CORE reset or GLOBAL reset. The ice_ptp_rebuild() function always calls the ice_ptp_init_tx function which will allocate a new tracker data structure, resulting in memory leaks during PF reset.
Certainly the driver should not be allocating a new tracker without removing the old tracker data, as this results in a memory leak. Additionally, there's no reason to remove the tracker memory during a reset. Remove this logic from the reset and rebuild flow. Instead of releasing the Tx tracker, flush outstanding timestamps just before we reset the PHY timestamp block in ice_ptp_cfg_phy_interrupt().
--- drivers/net/ethernet/intel/ice/ice_ptp.c | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +21 -12
@@ -963,6 +963,22 @@ ice_ptp_mark_tx_tracker_stale(struct ice_ptp_tx *tx)spin_unlock_irqrestore (&tx->lock, flags); } +/** +* ice_ptp_flush_all_tx_tracker - Flush all timestamp trackers on this clock +* @pf: Board private structure +* +* Called by the clock owner to flush all the Tx timestamp trackers associated +* with the clock. +*/ +static void +ice_ptp_flush_all_tx_tracker (struct ice_pf *pf) +{ +struct ice_ptp_port *port; + +list_for_each_entry (port, &pf->ptp.ports_owner.ports, list_member) +ice_ptp_flush_tx_tracker (ptp_port_to_pf (port), &port->tx); +} +/** * ice_ptp_release_tx_tracker - Release allocated memory for Tx tracker * @pf: Board private structure
@@ -2715,6 +2731,11 @@ static int ice_ptp_rebuild_owner(struct ice_pf *pf)/* Release the global hardware lock */ ice_ptp_unlock (hw); +/* Flush software tracking of any outstanding timestamps since we're +* about to flush the PHY timestamp block. +*/ +ice_ptp_flush_all_tx_tracker (pf); +if (!ice_is_e810 (hw)) {/* Enable quad interrupts */ err =ice_ptp_cfg_phy_interrupt (pf, true,1 );
@@ -2753,18 +2774,6 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) goto err; } -/* Init Tx structures */ -if (ice_is_e810 (&pf->hw)) { - err =ice_ptp_init_tx_e810 (pf, &ptp->port.tx); - }else { -kthread_init_delayed_work (&ptp->port.ov_work, - ice_ptp_wait_for_offsets); - err =ice_ptp_init_tx_e82x (pf, &ptp->port.tx, - ptp->port.port_num); - } -if (err) - goto err; - ptp->state =ICE_PTP_READY ;/* Start periodic work going */
Signature · 1 line
2.40.1
RE: [Intel-wired-lan] [PATCH v5 iwl-next 6/6] ice: stop destroying and reinitalizing Tx tracker during reset
Quoted 22 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Karol Kolacinski
Sent: Monday, January 8, 2024 6:17 PM
To: [email protected]
Cc: Keller, Jacob E <[email protected]>; [email protected]; Kolacinski, Karol <[email protected]>; Nguyen, Anthony L <[email protected]>; Brandeburg, Jesse <[email protected]>
Subject: [Intel-wired-lan] [PATCH v5 iwl-next 6/6] ice: stop destroying and reinitalizing Tx tracker during resetFrom: Jacob Keller <[email protected]>
The ice driver currently attempts to destroy and re-initialize the Tx timestamp tracker during the reset flow. The release of the Tx tracker only happened during CORE reset or GLOBAL reset. The
ice_ptp_rebuild()function always calls theice_ptp_init_txfunction which will allocate a new tracker data structure, resulting in memory leaks during PF reset.Certainly the driver should not be allocating a new tracker without removing the old tracker data, as this results in a memory leak. Additionally, there's no reason to remove the tracker memory during a reset. Remove this logic from the reset and rebuild flow. Instead of releasing the Tx tracker, flush outstanding timestamps just before we reset the PHY timestamp block in
ice_ptp_cfg_phy_interrupt().
Quoted 7 lines
Signed-off-by Jacob Keller <[email protected]>Signed-off-by Karol Kolacinski <[email protected]>Reviewed-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/ice/ice_ptp.c | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-)