From 9c5c2f52c0be24d7dbd4cba9e53c039539efd089 Mon Sep 17 00:00:00 2001 From: Chaitanya Vadrevu Date: Wed, 23 Jul 2025 13:45:16 -0500 Subject: [PATCH] Revert "ptp: remove ptp->n_vclocks check logic in ptp_vclock_in_use()" This reverts commit 259119595227fd20f6aa29d85abe086b6fdd9eb1 as it causes clock_adjtime to fail with "ptp: physical clock is free running" in kernel log. Signed-off-by: Chaitanya Vadrevu --- drivers/ptp/ptp_private.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/ptp/ptp_private.h b/drivers/ptp/ptp_private.h index d0eb4555720eb..b8d4f61f14be4 100644 --- a/drivers/ptp/ptp_private.h +++ b/drivers/ptp/ptp_private.h @@ -89,7 +89,17 @@ static inline int queue_cnt(const struct timestamp_event_queue *q) /* Check if ptp virtual clock is in use */ static inline bool ptp_vclock_in_use(struct ptp_clock *ptp) { - return !ptp->is_virtual_clock; + bool in_use = false; + + if (mutex_lock_interruptible(&ptp->n_vclocks_mux)) + return true; + + if (!ptp->is_virtual_clock && ptp->n_vclocks) + in_use = true; + + mutex_unlock(&ptp->n_vclocks_mux); + + return in_use; } /* Check if ptp clock shall be free running */