[PATCH iwl-net 00/12] ice: E82x: timestamp processing logic fixes
Jacob Keller <[email protected]>
| Newsgroups | org.osuosl.intel-wired-lan,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
This series contains several related fixes for the ice driver PTP logic relating to timestamp handling and device (re)initialization. Of particular note is some changes around the handling of timestamps that are requested near device state changes such as administrative up/down cycles and link change events. The E825 device logic in the PHY has an internal counter which is used as part of the "threshold" logic which determines when the device will trigger an interrupt signal from a given PHY port to the MAC. This internal counter requires some precise handling to ensure that the internal device state remains in sync with software expectations. Otherwise, the device can be finagled into a state where the PHY stops producing new timestamp interrupt notifications to the MAC indefinitely. This in turn degrades the timestamp processing latency and results in application failures for common timestamping applications such as ptp4l. There are four major categories of problem resolved by this series: * Timestamp requests made while the PHY_REG_TX_OFFSET_READY bit is cleared will increment the internal counter, but leave their valid bit set to 0. Upon read, the counter is not decremented. This leads to a desync of the counter and blocks the PHY interrupt. * Software logic for tracking timestamps incorrectly cleared in-use bits without waiting for completion in certain cases. If the timestamp *does* later complete, it leaves an "orphaned" ready bit which is not tracked by software. This results in the internal counter becoming desynced if that index is re-used. * The PHY timestamp memory region lacks pull-down zero-initialization at power on, resulting in uninitialized random data in the memory region. If software reads these values, an entry with its valid bit set to 1 can trigger a counter decrement and cause an underflow which results in the counter becoming desynced. * Timestamp request which complete near the beginning of the PHY losing link can become "stuck" such that the hardware logic triggered by a timestamp read does not activate. The memory status bit and the valid bit in the the timestamp index are not cleared. This window where this may occur begins *before* the firmware notifies the driver of link loss. When this occurs, the driver may accidentally re-use a stale timestamp, and the IRQ re-trigger logic triggers a repeated IRQ "storm" that can consume significant excess CPU time. The series' primary focus is towards preventing driver flows that can trigger the above sequences. It is based on work from Przemyslaw Korba which was previously posted at [1]. During that series development, Petr from RedHat reported the 3rd issue mentioned above. While attempting to root cause that issue, several other issues were uncovered and those fixes have also been included in this series. First, the locking around the PTP ports list in the adapter structure is converted to use RCU primitives and a spinlock, resolving a couple of reports from Petr about places where the original list was accessed without lock protection. Note that an older version of this fix used an xarray instead of the list. The xarray has more overhead and results in an increase of ~25 microseconds to the average latency for processing Tx timestamps. The list is simpler and avoids this overhead. Next, come two fixes for E822 hardware that were originally posted as part of Przemyslaw Korba's work [1]. The E822-only "vernier" offset validation work task is properly canceled during device reset, and new timestamp requests are kept disabled until the validation task completes. Next, Arkadiusz modifies the driver to stop pretending that the link has gone down during ice_down(). This removes "virtual" PTP link changes that occurred on several flows including MTU change, Eswitch setup, and others. Now, the driver only triggers a PTP PHY timer reinitialization when the physical PHY link has changed instead of during many other actions. Next, the driver is modified to stop clearing the PHY_REG_TX_OFFSET_READY bit. This bits only purpose is to tell hardware to mark any captured timestamps as invalid. Since this also disables the necessary side effects on read it is problematic to have cleared. According to hardware engineers, keeping it enabled should not have any other side effects. Next, the driver is modified to clear the PHY_REG_TX_MEMORY_STATUS by reading each index *prior* to the PHY soft reset. This ensures that any stale or invalid data left in the memory array is cleared, followed by the counter being reset via the PHY soft reset procedure. Next, the E825 timer start procedure is modified to first include a soft reset. This ensures that upon link up the device is reconfigured from a known-good state with its internal counter reset and everything cleared. Next, Petr modifies the ice_ptp_flush_tx_tracker() function to wait a little bit for any outstanding timestamps before flushing. Next, Petr modifies the ice_ptp_process_tx_tstamp() function to avoid releasing any index from software unless either a) it is actually completed by hardware or b) it is timed out waiting for a full two seconds. This closes the final gap from the second issue mentioned above. Instead of immediately releasing the index, the software now waits until hardware has completed it or the driver has waited long enough to be sufficiently sure that no such timestamp will be done. Next, the driver is modified to no longer mark timestamps as "stale" during a clock adjust event. This avoids marking timestamps as stale unnecessarily. Finally, the ice_ptp_process_tx_tstamp() function is modified to verify that hardware actually cleared the ready bitmap. This ensures that we do not report false timestamps near a link down event. Link: [1] https://lore.kernel.org/intel-wired-lan/[email protected]/ Signed-off-by: Jacob Keller <[email protected]> --- Arkadiusz Kubalewski (1): ice: call PTP link change only from link events Jacob Keller (7): ice: use reference counting and RCU for PTP port access ice: E825: stop clearing PHY_REG_TX_OFFSET_READY ice: E825: clear PHY_REG_TX_MEMORY_STATUS prior to soft reset ice: E825: perform a soft reset when starting the PHY timer ice: remove unnecessary discarding of timestamps after clock adjust ice: skip reading Tx ready bitmap on ports with no timestamps ice: don't clear in_use until HW clears ready bitmap Karol Kolacinski (2): ice: E822: keep Tx timestamps disabled during offset calibration ice: E822: cancel offset verification work during reset preparation Petr Oros (2): ice: wait for in-flight Tx timestamps before flushing the tracker ice: keep Tx timestamp slots tracked until completion or timeout drivers/net/ethernet/intel/ice/ice_adapter.h | 6 +- drivers/net/ethernet/intel/ice/ice_ptp.h | 12 +- drivers/net/ethernet/intel/ice/ice_adapter.c | 7 +- drivers/net/ethernet/intel/ice/ice_main.c | 13 +- drivers/net/ethernet/intel/ice/ice_ptp.c | 348 ++++++++++++++++++--------- drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 105 ++++---- 6 files changed, 318 insertions(+), 173 deletions(-) --- base-commit: 564973a259ec76f2dad0853420e7034cc43994c4 change-id: 20260819-jk-e825c-minimized-fixes-8559addec172 Best regards, -- Jacob Keller <[email protected]>