Skip to content

Commit 6a4d723

Browse files
hthierykuba-moo
authored andcommitted
net: fec: ptp: avoid register access when ipg clock is disabled
When accessing the timecounter register on an i.MX8MQ the kernel hangs. This is only the case when the interface is down. This can be reproduced by reading with 'phc_ctrl eth0 get'. Like described in the change in 91c0d98 the igp clock is disabled when the interface is down and leads to a system hang. So we check if the ptp clock status before reading the timecounter register. Signed-off-by: Heiko Thiery <[email protected]> Acked-by: Richard Cochran <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7f65415 commit 6a4d723

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/net/ethernet/freescale/fec_ptp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,16 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
377377
u64 ns;
378378
unsigned long flags;
379379

380+
mutex_lock(&adapter->ptp_clk_mutex);
381+
/* Check the ptp clock */
382+
if (!adapter->ptp_clk_on) {
383+
mutex_unlock(&adapter->ptp_clk_mutex);
384+
return -EINVAL;
385+
}
380386
spin_lock_irqsave(&adapter->tmreg_lock, flags);
381387
ns = timecounter_read(&adapter->tc);
382388
spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
389+
mutex_unlock(&adapter->ptp_clk_mutex);
383390

384391
*ts = ns_to_timespec64(ns);
385392

0 commit comments

Comments
 (0)