Skip to content

Commit b774ab5

Browse files
hthierysmb49
authored andcommitted
net: fec: ptp: avoid register access when ipg clock is disabled
BugLink: https://bugs.launchpad.net/bugs/1923220 [ 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> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent 5e3cb66 commit b774ab5

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
@@ -382,9 +382,16 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
382382
u64 ns;
383383
unsigned long flags;
384384

385+
mutex_lock(&adapter->ptp_clk_mutex);
386+
/* Check the ptp clock */
387+
if (!adapter->ptp_clk_on) {
388+
mutex_unlock(&adapter->ptp_clk_mutex);
389+
return -EINVAL;
390+
}
385391
spin_lock_irqsave(&adapter->tmreg_lock, flags);
386392
ns = timecounter_read(&adapter->tc);
387393
spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
394+
mutex_unlock(&adapter->ptp_clk_mutex);
388395

389396
*ts = ns_to_timespec64(ns);
390397

0 commit comments

Comments
 (0)