lkml.org 
[lkml]   [2021]   [Feb]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] net: fec: ptp: avoid register access when ipg clock is disabled
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.

> + 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?

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

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