[PATCH] net: macb: Fix ptp time adjustment for large negative delta

Subsystems: atmel macb ethernet driver, networking drivers, the rest

STALE2962d

3 messages, 3 authors, 2018-06-21 · open the first message on its own page

[PATCH] net: macb: Fix ptp time adjustment for large negative delta

From: Harini Katakam <hidden>
Date: 2018-06-20 11:34:47

When delta passed to gem_ptp_adjtime is negative, the sign is
maintained in the ns_to_timespec64 conversion. Hence timespec_add
should be used directly. timespec_sub will just subtract the negative
value thus increasing the time difference.

Signed-off-by: Harini Katakam <redacted>
---
 drivers/net/ethernet/cadence/macb_ptp.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 2220c77..6788351 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -170,10 +170,7 @@ static int gem_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 
 	if (delta > TSU_NSEC_MAX_VAL) {
 		gem_tsu_get_time(&bp->ptp_clock_info, &now);
-		if (sign)
-			now = timespec64_sub(now, then);
-		else
-			now = timespec64_add(now, then);
+		now = timespec64_add(now, then);
 
 		gem_tsu_set_time(&bp->ptp_clock_info,
 				 (const struct timespec64 *)&now);
-- 
2.7.4

Re: [PATCH] net: macb: Fix ptp time adjustment for large negative delta

From: Nicolas Ferre <nicolas.ferre@microchip.com>
Date: 2018-06-20 14:04:45

On 20/06/2018 at 13:34, Harini Katakam wrote:
When delta passed to gem_ptp_adjtime is negative, the sign is
maintained in the ns_to_timespec64 conversion. Hence timespec_add
should be used directly. timespec_sub will just subtract the negative
value thus increasing the time difference.

Signed-off-by: Harini Katakam <redacted>
Makes sense:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
quoted hunk
---
  drivers/net/ethernet/cadence/macb_ptp.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_ptp.c b/drivers/net/ethernet/cadence/macb_ptp.c
index 2220c77..6788351 100644
--- a/drivers/net/ethernet/cadence/macb_ptp.c
+++ b/drivers/net/ethernet/cadence/macb_ptp.c
@@ -170,10 +170,7 @@ static int gem_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
  
  	if (delta > TSU_NSEC_MAX_VAL) {
  		gem_tsu_get_time(&bp->ptp_clock_info, &now);
-		if (sign)
-			now = timespec64_sub(now, then);
-		else
-			now = timespec64_add(now, then);
+		now = timespec64_add(now, then);
  
  		gem_tsu_set_time(&bp->ptp_clock_info,
  				 (const struct timespec64 *)&now);

-- 
Nicolas Ferre

Re: [PATCH] net: macb: Fix ptp time adjustment for large negative delta

From: David Miller <davem@davemloft.net>
Date: 2018-06-21 06:01:48

From: Harini Katakam <redacted>
Date: Wed, 20 Jun 2018 17:04:20 +0530
When delta passed to gem_ptp_adjtime is negative, the sign is
maintained in the ns_to_timespec64 conversion. Hence timespec_add
should be used directly. timespec_sub will just subtract the negative
value thus increasing the time difference.

Signed-off-by: Harini Katakam <redacted>
Applied and queued up for -stable.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help