[PATCH iwl-net 08/12] ice: wait for in-flight Tx timestamps before flushing the tracker
Jacob Keller <[email protected]>
| Newsgroups | org.osuosl.intel-wired-lan,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
From: Petr Oros <[email protected]> ice_ptp_flush_tx_tracker() frees every tracked request, but a request whose timestamp is still being captured by the PHY at that moment is freed without touching the PHY entry. The ready bit published shortly after has no tracked owner, and the PHY does not raise another Tx timestamp interrupt until every outstanding ready bit is read, so delivery for the whole quad degrades to the periodic work. Wait up to 10 ms for in-flight captures to publish their ready bits before flushing, so the flush clears them together with the rest. Fixes: ea9b847cda64 ("ice: enable transmit timestamps for E810 devices") Signed-off-by: Petr Oros <[email protected]> Signed-off-by: Jacob Keller <[email protected]> Reviewed-by: Maciek Machnikowski <[email protected]> --- drivers/net/ethernet/intel/ice/ice_ptp.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index 8aa49dda90a2..a049dc7a2241 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -740,6 +740,37 @@ ice_ptp_alloc_tx_tracker(struct ice_ptp_tx *tx) return 0; } +static void +ice_ptp_wait_for_tracker_drain(struct ice_pf *pf, struct ice_ptp_tx *tx) +{ + unsigned long deadline = jiffies + msecs_to_jiffies(10); + struct ice_hw *hw = &pf->hw; + u64 tstamp_ready; + bool pending; + u8 idx; + + if (hw->reset_ongoing) + return; + + do { + if (ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready)) + return; + + pending = false; + for_each_set_bit(idx, tx->in_use, tx->len) { + if (!(tstamp_ready & BIT_ULL(idx + tx->offset))) + pending = true; + } + if (!pending) + return; + + usleep_range(500, 1000); + } while (time_before(jiffies, deadline)); + + dev_dbg(ice_pf_to_dev(pf), "Timed out waiting for in-flight Tx timestamps on block %u\n", + tx->block); +} + /** * ice_ptp_flush_tx_tracker - Flush any remaining timestamps from the tracker * @pf: Board private structure @@ -756,6 +787,8 @@ ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx) int err; u8 idx; + ice_ptp_wait_for_tracker_drain(pf, tx); + err = ice_get_phy_tx_tstamp_ready(hw, tx->block, &tstamp_ready); if (err) { dev_dbg(ice_pf_to_dev(pf), "Failed to get the Tx tstamp ready bitmap for block %u, err %d\n", -- 2.55.0.814.gc42f45431d0f