Re: [PATCH net-next v2 09/11] net: dsa: microchip: ksz9477: add hardware time stamping support

Richard Cochran
2020-11-13T03:31:46Z

On Fri, Nov 13, 2020 at 04:40:20AM +0200, Vladimir Oltean wrote:
> > @@ -103,6 +108,10 @@ static int ksz9477_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> > if (ret)
> > goto error_return;
> >
> > + spin_lock_irqsave(&dev->ptp_clock_lock, flags);
>
> I believe that spin_lock_irqsave is unnecessary, since there is no code
> that runs in hardirq context.

The .adjtime method is in a system call context. If all of the code
that manipulates dev->ptp_clock_time can sleep, then you can use a
mutex. Otherwise spin_lock_irqsave is the safe choice.

Thanks,
Richard