All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.9 01/16] net: fec: ptp: avoid register access when ipg clock is disabled
@ 2021-03-17  0:59 Sasha Levin
  2021-03-17  0:59   ` Sasha Levin
                   ` (14 more replies)
  0 siblings, 15 replies; 21+ messages in thread
From: Sasha Levin @ 2021-03-17  0:59 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Heiko Thiery, Richard Cochran, Jakub Kicinski, Sasha Levin, netdev

From: Heiko Thiery <heiko.thiery@gmail.com>

[ Upstream commit 6a4d7234ae9a3bb31181f348ade9bbdb55aeb5c5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/freescale/fec_ptp.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index f9e74461bdc0..123181612595 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -396,9 +396,16 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	u64 ns;
 	unsigned long flags;
 
+	mutex_lock(&adapter->ptp_clk_mutex);
+	/* Check the ptp clock */
+	if (!adapter->ptp_clk_on) {
+		mutex_unlock(&adapter->ptp_clk_mutex);
+		return -EINVAL;
+	}
 	spin_lock_irqsave(&adapter->tmreg_lock, flags);
 	ns = timecounter_read(&adapter->tc);
 	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
+	mutex_unlock(&adapter->ptp_clk_mutex);
 
 	*ts = ns_to_timespec64(ns);
 
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-03-17  1:20 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17  0:59 [PATCH AUTOSEL 4.9 01/16] net: fec: ptp: avoid register access when ipg clock is disabled Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 02/16] powerpc/4xx: Fix build errors from mfdcr() Sasha Levin
2021-03-17  0:59   ` Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 03/16] atm: eni: dont release is never initialized Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 04/16] atm: lanai: dont run lanai_dev_close if not open Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 05/16] ixgbe: Fix memleak in ixgbe_configure_clsu32 Sasha Levin
2021-03-17  0:59   ` [Intel-wired-lan] " Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 06/16] net: tehuti: fix error return code in bdx_probe() Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 07/16] sun/niu: fix wrong RXMAC_BC_FRM_CNT_COUNT count Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 08/16] nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 09/16] NFS: Correct size calculation for create reply length Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 10/16] net: wan: fix error return code of uhdlc_init() Sasha Levin
2021-03-17  0:59   ` Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 11/16] atm: uPD98402: fix incorrect allocation Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 12/16] atm: idt77252: fix null-ptr-dereference Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 13/16] u64_stats,lockdep: Fix u64_stats_init() vs lockdep Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 14/16] nfs: we don't support removing system.nfs4_acl Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 15/16] ia64: fix ia64_syscall_get_set_arguments() for break-based syscalls Sasha Levin
2021-03-17  0:59   ` Sasha Levin
2021-03-17  0:59 ` [PATCH AUTOSEL 4.9 16/16] ia64: fix ptrace(PTRACE_SYSCALL_INFO_EXIT) sign Sasha Levin
2021-03-17  0:59   ` Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.