netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: mvpp2: tai: warn once if we fail to update our timestamp
@ 2024-12-10 12:38 Russell King
  2024-12-11 10:56 ` Russell King (Oracle)
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King @ 2024-12-10 12:38 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Marcin Wojtas, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, netdev

The hardware timestamps for packets contain a truncated seconds field,
only containing two bits of seconds. In order to provide the full
number of seconds, we need to keep track of the full hardware clock by
reading it every two seconds.

However, if we fail to read the clock, we silently ignore the error.
Print a warning indicating that the PP2 TAI clock timestamps have
become unreliable.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
index 95862aff49f1..4a2da9277e05 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_tai.c
@@ -54,6 +54,7 @@
 #define TCSR_CAPTURE_0_VALID		BIT(0)
 
 struct mvpp2_tai {
+	struct device *dev;
 	struct ptp_clock_info caps;
 	struct ptp_clock *ptp_clock;
 	void __iomem *base;
@@ -303,7 +304,8 @@ static long mvpp22_tai_aux_work(struct ptp_clock_info *ptp)
 {
 	struct mvpp2_tai *tai = ptp_to_tai(ptp);
 
-	mvpp22_tai_gettimex64(ptp, &tai->stamp, NULL);
+	if (mvpp22_tai_gettimex64(ptp, &tai->stamp, NULL) < 0)
+		  dev_warn_once(tai->dev, "PTP timestamps are unreliable");
 
 	return msecs_to_jiffies(2000);
 }
@@ -401,6 +403,7 @@ int mvpp22_tai_probe(struct device *dev, struct mvpp2 *priv)
 
 	spin_lock_init(&tai->lock);
 
+	tai->dev = dev;
 	tai->base = priv->iface_base;
 
 	/* The step size consists of three registers - a 16-bit nanosecond step
-- 
2.30.2


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

* Re: [PATCH net-next] net: mvpp2: tai: warn once if we fail to update our timestamp
  2024-12-10 12:38 [PATCH net-next] net: mvpp2: tai: warn once if we fail to update our timestamp Russell King
@ 2024-12-11 10:56 ` Russell King (Oracle)
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King (Oracle) @ 2024-12-11 10:56 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Marcin Wojtas, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran, netdev

On Tue, Dec 10, 2024 at 12:38:21PM +0000, Russell King wrote:
> @@ -303,7 +304,8 @@ static long mvpp22_tai_aux_work(struct ptp_clock_info *ptp)
>  {
>  	struct mvpp2_tai *tai = ptp_to_tai(ptp);
>  
> -	mvpp22_tai_gettimex64(ptp, &tai->stamp, NULL);
> +	if (mvpp22_tai_gettimex64(ptp, &tai->stamp, NULL) < 0)
> +		  dev_warn_once(tai->dev, "PTP timestamps are unreliable");

I see nipbot spotted an issue with indentation here. v2 sent.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

end of thread, other threads:[~2024-12-11 10:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-10 12:38 [PATCH net-next] net: mvpp2: tai: warn once if we fail to update our timestamp Russell King
2024-12-11 10:56 ` 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).