netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] net: mvpp2: tai: add refcount for ptp worker
@ 2023-04-16 14:30 Shmuel Hazan
  2023-04-16 14:52 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Shmuel Hazan @ 2023-04-16 14:30 UTC (permalink / raw)
  To: linux@armlinux.org.uk
  Cc: mw@semihalf.com, netdev@vger.kernel.org, davem@davemloft.net

From bd7fb292219e6b64a650a6c79d09822dbef662d3 Mon Sep 17 00:00:00 2001

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>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
index 95862aff49f1..1b57573dd866 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)
@@ -372,6 +373,10 @@ void mvpp22_tai_start(struct mvpp2_tai *tai)
 {
 	long delay;
 
+	tai->poll_worker_refcount++;
+	if (tai->poll_worker_refcount > 1)
+		return;
+
 	delay = mvpp22_tai_aux_work(&tai->caps);
 
 	ptp_schedule_worker(tai->ptp_clock, delay);
@@ -379,6 +384,9 @@ void mvpp22_tai_start(struct mvpp2_tai *tai)
 
 void mvpp22_tai_stop(struct mvpp2_tai *tai)
 {
+	tai->poll_worker_refcount--;
+	if (tai->poll_worker_refcount)
+		return;
 	ptp_cancel_worker_sync(tai->ptp_clock);
 }
 
-- 
2.40.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-05-02  8:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-16 14:30 [RFC PATCH] net: mvpp2: tai: add refcount for ptp worker Shmuel Hazan
2023-04-16 14:52 ` Andrew Lunn
2023-04-16 15:25   ` Shmuel Hazan
2023-04-16 15:40     ` Andrew Lunn
2023-05-02  8:44       ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).