[Intel-wired-lan] [PATCH iwl-next v2 3/5] ice: add lock to protect low latency interface
Rinitha, SX
sx.rinitha at intel.com
Mon Dec 23 17:12:48 UTC 2024
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces at osuosl.org> On Behalf Of Anton Nadezhdin
> Sent: 16 December 2024 20:24
> To: intel-wired-lan at lists.osuosl.org
> Cc: netdev at vger.kernel.org; Nguyen, Anthony L <anthony.l.nguyen at intel.com>; Kitszel, Przemyslaw <przemyslaw.kitszel at intel.com>; richardcochran at gmail.com; Keller, Jacob E <jacob.e.keller at intel.com>; Olech, Milena <milena.olech at intel.com>; Nadezhdin, Anton <anton.nadezhdin at intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next v2 3/5] ice: add lock to protect low latency interface
>
> From: Jacob Keller <jacob.e.keller at intel.com>
>
> Newer firmware for the E810 devices support a 'low latency' interface to interact with the PHY without using the Admin Queue. This is interacted with via the REG_LL_PROXY_L and REG_LL_PROXY_H registers.
>
> Currently, this interface is only used for Tx timestamps. There are two different mechanisms, including one which uses an interrupt for firmware to signal completion. However, these two methods are mutually exclusive, so no synchronization between them was necessary.
>
> This low latency interface is being extended in future firmware to support also programming the PHY timers. Use of the interface for PHY timers will need synchronization to ensure there is no overlap with a Tx timestamp.
>
> The interrupt-based response complicates the locking somewhat. We can't use a simple spinlock. This would require being acquired in ice_ptp_req_tx_single_tstamp, and released in ice_ptp_complete_tx_single_tstamp. The ice_ptp_req_tx_single_tstamp function is called from the threaded IRQ, and the ice_ptp_complete_tx_single_stamp is called from the low latency IRQ, so we would need to acquire the lock with IRQs disabled.
>
> To handle this, we'll use a wait queue along with wait_event_interruptible_locked_irq in the update flows which don't use the interrupt.
>
> The interrupt flow will acquire the wait queue lock, set the ATQBAL_FLAGS_INTR_IN_PROGRESS, and then initiate the firmware low latency request, and unlock the wait queue lock.
>
> Upon receipt of the low latency interrupt, the lock will be acquired, the ATQBAL_FLAGS_INTR_IN_PROGRESS bit will be cleared, and the firmware response will be captured, and wake_up_locked() will be called on the wait queue.
>
> The other flows will use wait_event_interruptible_locked_irq() to wait until the ATQBAL_FLAGS_INTR_IN_PROGRESS is clear. This function checks the condition under lock, but does not hold the lock while waiting. On return, the lock is held, and a return of zero indicates we hold the lock and the in-progress flag is not set.
>
> This will ensure that threads which need to use the low latency interface will sleep until they can acquire the lock without any pending low latency interrupt flow interfering.
>
> Signed-off-by: Jacob Keller <jacob.e.keller at intel.com>
> Reviewed-by: Milena Olech <milena.olech at intel.com>
> Signed-off-by: Anton Nadezhdin <anton.nadezhdin at intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_ptp.c | 42 +++++++++++++++++----
> drivers/net/ethernet/intel/ice/ice_ptp_hw.c | 18 +++++++++
> drivers/net/ethernet/intel/ice/ice_type.h | 10 +++++
> 3 files changed, 62 insertions(+), 8 deletions(-)
>
Tested-by: Rinitha S <sx.rinitha at intel.com> (A Contingent worker at Intel)
More information about the Intel-wired-lan
mailing list