Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 91c0d987a9788dcc5fe26baafd73bf9242b68900
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>

authored by

Heiko Thiery and committed by
Jakub Kicinski
6a4d7234 7f654157

+7
+7
drivers/net/ethernet/freescale/fec_ptp.c
··· 377 377 u64 ns; 378 378 unsigned long flags; 379 379 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 + } 380 386 spin_lock_irqsave(&adapter->tmreg_lock, flags); 381 387 ns = timecounter_read(&adapter->tc); 382 388 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); 389 + mutex_unlock(&adapter->ptp_clk_mutex); 383 390 384 391 *ts = ns_to_timespec64(ns); 385 392