Skip to content

Commit 4a104e4

Browse files
hthierygregkh
authored andcommitted
net: fec: ptp: avoid register access when ipg clock is disabled
[ Upstream commit 6a4d723 ] 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 <heiko.thiery@gmail.com> Acked-by: Richard Cochran <richardcochran@gmail.com> Link: https://lore.kernel.org/r/20210225211514.9115-1-heiko.thiery@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 50c7568 commit 4a104e4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

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)