Re: [PATCH v3 1/3] net: mvpp2: tai: add refcount for ptp worker

From: Shmuel Hazan
Date: Sun Apr 30 2023 - 13:09:50 EST


On Thu, 2023-04-20 at 20:20 -0700, Jakub Kicinski wrote:
> > Caution: This is an external email. Please take care when clicking
> > links or opening attachments.
> >
> >
> > On Wed, 19 Apr 2023 18:14:55 +0300 Shmuel Hazan wrote:
> > > > +static void mvpp22_tai_stop_unlocked(struct mvpp2_tai *tai)
> > > > +{
> > > > + tai->poll_worker_refcount--;
> > > > + if (tai->poll_worker_refcount)
> > > > + return;
> > > > + ptp_cancel_worker_sync(tai->ptp_clock);
> >
> > How can you cancel it _sync() when the work takes the same
> > lock you're already holding?
> >
> > https://elixir.bootlin.com/linux/v6.3-rc7/source/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c#L246


Hi Jakub,

Thanks for finding that. Strange that I have not encountered any
deadlocks while testing; I will apply a fix and resend after testing
it.

> >
> > > >  void mvpp22_tai_stop(struct mvpp2_tai *tai)
> > > >  {
> > > > - ptp_cancel_worker_sync(tai->ptp_clock);
> > > > + unsigned long flags;
> > > > +
> > > > + spin_lock_irqsave(&tai->lock, flags);
> > > > + mvpp22_tai_stop_unlocked(tai);
> >
> > --
> > pw-bot: cr