mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shmuel Hazan <shmuel.h@siklu.com>
To: "andrew@lunn.ch" <andrew@lunn.ch>
Cc: "linux@armlinux.org.uk" <linux@armlinux.org.uk>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"mw@semihalf.com" <mw@semihalf.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"richardcochran@gmail.com" <richardcochran@gmail.com>,
	"horatiu.vultur@microchip.com" <horatiu.vultur@microchip.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>
Subject: Re: [PATCH v2 1/3] net: mvpp2: tai: add refcount for ptp worker
Date: Tue, 18 Apr 2023 08:54:41 +0000	[thread overview]
Message-ID: <3cfbdcc1836d4569daf976221914464c305823d7.camel@siklu.com> (raw)
In-Reply-To: <cab62ad6-c495-48f3-91c8-5c27c43582ba@lunn.ch>

On Tue, 2023-04-18 at 02:44 +0200, Andrew Lunn wrote:
> Caution: This is an external email. Please take care when clicking links or opening attachments.
> 
> 
> On Mon, Apr 17, 2023 at 08:07:39PM +0300, Shmuel Hazan wrote:
> > In some configurations, a single TAI can be responsible for multiple
> > mvpp2 interfaces. However, the mvpp2 driver will call mvpp22_tai_stop
> > and mvpp22_tai_start per interface RX timestamp disable/enable.
> > 
> > As a result, disabling timestamping for one interface would stop the
> > worker and corrupt the other interface's RX timestamps.
> > 
> > This commit solves the issue by introducing a simpler ref count for each
> > TAI instance.
> > 
> > Fixes: ce3497e2072e ("net: mvpp2: ptp: add support for receive timestamping")
> > Signed-off-by: Shmuel Hazan <shmuel.h@siklu.com>
> > ---
> >  .../net/ethernet/marvell/mvpp2/mvpp2_tai.c    | 30 ++++++++++++++++---
> >  1 file changed, 26 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
> > index 95862aff49f1..2e3d43b1bac1 100644
> > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
> > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
> > @@ -61,6 +61,7 @@ struct mvpp2_tai {
> >       u64 period;             // nanosecond period in 32.32 fixed point
> >       /* This timestamp is updated every two seconds */
> >       struct timespec64 stamp;
> > +     u16 poll_worker_refcount;
> >  };
> > 
> >  static void mvpp2_tai_modify(void __iomem *reg, u32 mask, u32 set)
> > @@ -368,18 +369,39 @@ void mvpp22_tai_tstamp(struct mvpp2_tai *tai, u32 tstamp,
> >       hwtstamp->hwtstamp = timespec64_to_ktime(ts);
> >  }
> > 
> > +static void mvpp22_tai_start_unlocked(struct mvpp2_tai *tai)
> > +{
> > +     tai->poll_worker_refcount++;
> > +     if (tai->poll_worker_refcount > 1)
> > +             return;
> > +
> > +     ptp_schedule_worker(tai->ptp_clock, 0);
> 
> So the old code used to have delay here, not 0. And delay would be
> returned by mvpp22_tai_aux_work() and have a value of 2000ms. So this
> is a clear change in behaviour. Why is it O.K. not to delay for 2
> seconds?  Should you actually still have the delay, pass it as a
> parameter into this function?


Hi Andrew,

Thanks for your feedback. I will add more context about this change in
the next version. 

Before of this change, we ran the first iteration internally (on
mvpp22_tai_start), and then schedule another iteration in a delay to
run on the worker context. Howver, since the iteration itself locks
tai->lock, it is not possible to run it from mvpp22_tai_start anymore
as tai->lock is already locked. 

So, to summarize, from my point of view, this change should not
introduce any change in behavior as we will still run the first
iteration immediately, and then run it each 2s, as we did before. The
only change is that the first iteration will also be done from the
worker thread. However, I let me know if I am missing anything. 

---
Thanks,
Shmuel. 

> 
>      Andrew


  reply	other threads:[~2023-04-18  8:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-17 17:07 [PATCH v2 0/3] net: mvpp2: tai: add extts support Shmuel Hazan
2023-04-17 17:07 ` [PATCH v2 1/3] net: mvpp2: tai: add refcount for ptp worker Shmuel Hazan
2023-04-18  0:44   ` Andrew Lunn
2023-04-18  8:54     ` Shmuel Hazan [this message]
2023-04-17 17:07 ` [PATCH v2 2/3] net: mvpp2: tai: add extts support Shmuel Hazan
2023-04-18  9:37   ` Horatiu Vultur
2023-04-18 10:09     ` Shmuel Hazan
2023-04-17 17:07 ` [PATCH v2 3/3] dt-bindings: net: marvell,pp2: add extts docs Shmuel Hazan
2023-04-17 17:47   ` Krzysztof Kozlowski
2023-04-18  8:32     ` Shmuel Hazan
2023-04-17 19:01 ` [PATCH v2 0/3] net: mvpp2: tai: add extts support Jakub Kicinski
2023-04-18  8:36   ` Shmuel Hazan
2023-04-18  0:36 ` Andrew Lunn
2023-04-18  8:43   ` Shmuel Hazan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3cfbdcc1836d4569daf976221914464c305823d7.camel@siklu.com \
    --to=shmuel.h@siklu.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mw@semihalf.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®