ice_dpll_tspll_state_on_dpll_set() notifies the TSPLL device from a callback of the TIME_REF pin. This pin belongs to an external DPLL and the DPLL core is going to run its callbacks under a lock of the pin's owner, which does not cover the TSPLL device.
Only update dpll_state in the callback, so a device get reports the new state right away, and leave prev_dpll_state to ice_dpll_periodic_work_e825(), which then sends the notification. It now arrives up to 500 ms later and after the reply to the request. Refresh dpll_state on every run of the work, as the state written by the callback can be transient and the lock status can return to prev_dpll_state before the next run. No notification is sent in this case. Reviewed-by: Petr Oros <[email protected]> Signed-off-by: Ivan Vecera <[email protected]> --- Changes in v2: - Merged the two comments in ice_dpll_tspll_state_on_dpll_set() (Sashiko) --- drivers/net/ethernet/intel/ice/ice_dpll.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c index ade1fb3dd06743..0877827a6521cc 100644 --- a/drivers/net/ethernet/intel/ice/ice_dpll.c +++ b/drivers/net/ethernet/intel/ice/ice_dpll.c @@ -2914,7 +2914,6 @@ ice_dpll_tspll_state_on_dpll_set(const struct dpll_pin *pin, void *pin_priv, struct ice_dpll_pin *p = pin_priv; struct ice_pf *pf = p->pf; enum ice_clk_src clk_src; - bool changed = false; struct ice_dpll *tp; int ret; @@ -2939,23 +2938,16 @@ ice_dpll_tspll_state_on_dpll_set(const struct dpll_pin *pin, void *pin_priv, new_state = ice_dpll_tspll_lock_status_get(pf, false); - /* Sync the cached lock state to what we just observed from HW - * so ice_dpll_periodic_work_e825() (cached path) does not emit - * a spurious UNLOCKED notification between now and the next - * PTP monitor tick. + /* Sync the cached lock state to what we just observed from HW. + * ice_dpll_periodic_work_e825() reads it (cached path), + * compares it with prev_dpll_state and sends the notification. + * dpll_state lets a device get report it right away. */ WRITE_ONCE(pf->ptp.tspll_locked, new_state == DPLL_LOCK_STATUS_LOCKED); - - if (tp->prev_dpll_state != new_state) { - tp->dpll_state = new_state; - tp->prev_dpll_state = new_state; - changed = true; - } + tp->dpll_state = new_state; } mutex_unlock(&pf->dplls.lock); - if (changed) - __dpll_device_change_ntf(tp->dpll); /* TSPLL reconfiguration may complete before lock is reacquired. * PTP periodic monitoring tracks and restores the final lock state. */ @@ -3372,8 +3364,8 @@ static void ice_dpll_periodic_work_e825(struct ice_pf *pf) mutex_lock(&pf->dplls.lock); new_state = ice_dpll_tspll_lock_status_get(pf, true); + tp->dpll_state = new_state; if (tp->prev_dpll_state != new_state) { - tp->dpll_state = new_state; tp->prev_dpll_state = new_state; changed = true; } -- 2.56.0
