[PATCH net] net: stmmac: keep est_lock across PTP clock adjustment
Lorenzo Bianconi
lorenzo.bianconi at oss.qualcomm.com
Mon Nov 2 09:37:56 PST 2026
stmmac_adjust_time() disables EST, drops est_lock to step the PTP clock,
and then reacquires the lock to reprogram EST using a base time computed
from the new clock value.
That leaves a window where a concurrent tc_taprio_configure() can program
EST enabled with a base time derived from the pre-step clock. The gate
schedule then runs across the PTP step with a stale base time until
stmmac_adjust_time() reprograms it.
Keep est_lock held for the whole disable/step/reprogram sequence so no
other EST user can program the block while the clock is being stepped.
This does not introduce a new lock ordering: __stmmac_setup_est() already
takes ptp_lock through gettimex64() while holding est_lock, and
stmmac_adjust_systime() uses readl_poll_timeout_atomic(), so it does not
sleep under ptp_lock.
Fixes: 23d96de472f7 ("net: stmmac: re-apply taprio offload in __stmmac_open() and stmmac_resume()")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at oss.qualcomm.com>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index a37405534beb..6ad6c2f52a0d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -73,14 +73,12 @@ static int stmmac_adjust_time(struct ptp_clock_info *ptp, s64 delta)
if (priv->est && priv->est->enable)
stmmac_est_configure(priv, priv, priv->est,
priv->plat->clk_ptp_rate, false);
- mutex_unlock(&priv->est_lock);
write_lock_irqsave(&priv->ptp_lock, flags);
stmmac_adjust_systime(priv, priv->ptpaddr, sec, nsec, neg_adj, xmac);
write_unlock_irqrestore(&priv->ptp_lock, flags);
/* Calculate new basetime and re-configured EST after PTP time adjust. */
- mutex_lock(&priv->est_lock);
if (priv->est && priv->est->enable)
__stmmac_setup_est(priv);
mutex_unlock(&priv->est_lock);
---
base-commit: 7308ef8b4a6779a39f68d053c19b53a5c584a663
change-id: 20261102-stmmac-ptp-est-lock-725f8c72ff1a
Best regards,
--
Lorenzo Bianconi <lorenzo.bianconi at oss.qualcomm.com>
More information about the linux-arm-kernel
mailing list