> -----Original Message-----
> From: Intel-wired-lan <[email protected]> On Behalf Of Anton 
> Nadezhdin
> Sent: 16 December 2024 20:24
> To: [email protected]
> Cc: [email protected]; Nguyen, Anthony L <[email protected]>; 
> Kitszel, Przemyslaw <[email protected]>; [email protected]; 
> Keller, Jacob E <[email protected]>; Olech, Milena 
> <[email protected]>; Nadezhdin, Anton <[email protected]>
> Subject: [Intel-wired-lan] [PATCH iwl-next v2 3/5] ice: add lock to protect 
> low latency interface
>
> From: Jacob Keller <[email protected]>
>
> 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 <[email protected]>
> Reviewed-by: Milena Olech <[email protected]>
> Signed-off-by: Anton Nadezhdin <[email protected]>
> ---
> 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 <[email protected]> (A Contingent worker at Intel)

Reply via email to