netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: macb: Fix ptp time adjustment for large negative delta
@ 2018-06-20 11:34 Harini Katakam
  2018-06-20 14:04 ` Nicolas Ferre
  2018-06-21  6:01 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Harini Katakam @ 2018-06-20 11:34 UTC (permalink / raw)
  To: nicolas.ferre, davem
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux,
	harini.katakam

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 <harini.katakam@xilinx.com>
---
 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

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

* Re: [PATCH] net: macb: Fix ptp time adjustment for large negative delta
  2018-06-20 11:34 [PATCH] net: macb: Fix ptp time adjustment for large negative delta Harini Katakam
@ 2018-06-20 14:04 ` Nicolas Ferre
  2018-06-21  6:01 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2018-06-20 14:04 UTC (permalink / raw)
  To: Harini Katakam, davem
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux,
	Claudiu Beznea - M18063

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 <harini.katakam@xilinx.com>

Makes sense:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>   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

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

* Re: [PATCH] net: macb: Fix ptp time adjustment for large negative delta
  2018-06-20 11:34 [PATCH] net: macb: Fix ptp time adjustment for large negative delta Harini Katakam
  2018-06-20 14:04 ` Nicolas Ferre
@ 2018-06-21  6:01 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-06-21  6:01 UTC (permalink / raw)
  To: harini.katakam
  Cc: nicolas.ferre, netdev, linux-kernel, michal.simek,
	harinikatakamlinux

From: Harini Katakam <harini.katakam@xilinx.com>
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 <harini.katakam@xilinx.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2018-06-21  6:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-20 11:34 [PATCH] net: macb: Fix ptp time adjustment for large negative delta Harini Katakam
2018-06-20 14:04 ` Nicolas Ferre
2018-06-21  6:01 ` David Miller

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).