lkml.org 
[lkml]   [2021]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 1/1] net: fec: ptp: avoid register access when ipg clock is disabled
HI Jakub,

Am Di., 23. Feb. 2021 um 04:00 Uhr schrieb Jakub Kicinski <kuba@kernel.org>:
>
> On Sat, 20 Feb 2021 07:56:55 +0100 Heiko Thiery wrote:
> > 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>
>
> Please widen the CC list, you should CC Richard on PTP patches.
>
> > diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
> > index 2e344aada4c6..c9882083da02 100644
> > --- a/drivers/net/ethernet/freescale/fec_ptp.c
> > +++ b/drivers/net/ethernet/freescale/fec_ptp.c
> > @@ -377,6 +377,9 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
> > u64 ns;
> > unsigned long flags;
> >
> > + /* Check the ptp clock */
>
> Comment is rather redundant. Drop it or say _when_ ptp_clk_on may not
> be true.

I just used the same comment as the one in the fec_ptp_settime() function.

>
> > + if (!adapter->ptp_clk_on)
> > + return -EINVAL;
>
> Why is the PTP interface registered when it can't be accessed?
>
> Perhaps the driver should unregister the PTP clock when it's brought
> down?

Good question, but I do not know what happens e.g. with linuxptp when
the device that was opened before will be gone.

Maybe Richard can give a hint.

>
> > spin_lock_irqsave(&adapter->tmreg_lock, flags);
> > ns = timecounter_read(&adapter->tc);
> > spin_unlock_irqrestore(&adapter->tmreg_lock, flags);

--
Heiko

\
 
 \ /
  Last update: 2021-02-23 09:03    [W:0.045 / U:1.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site