[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <6806f01c8a6281a15495f5ead08c8b4403b1a581.camel@siklu.com>
Date: Sun, 16 Apr 2023 14:30:18 +0000
From: Shmuel Hazan <shmuel.h@...lu.com>
To: "linux@...linux.org.uk" <linux@...linux.org.uk>
CC: "mw@...ihalf.com" <mw@...ihalf.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"davem@...emloft.net" <davem@...emloft.net>
Subject: [RFC PATCH] net: mvpp2: tai: add refcount for ptp worker
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@...lu.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
Powered by blists - more mailing lists