netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] ptp: ocp: have adjtime handle negative delta_ns correctly
@ 2022-05-13 22:52 Jonathan Lemon
  2022-05-15  2:16 ` Vadim Fedorenko
  2022-05-16 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jonathan Lemon @ 2022-05-13 22:52 UTC (permalink / raw)
  To: netdev, vfedorenko
  Cc: richardcochran, davem, kuba, pabeni, edumazet, kernel-team

delta_ns is a s64, but it was being passed ptp_ocp_adjtime_coarse
as an u64.  Also, it turns out that timespec64_add_ns() only handles
positive values, so perform the math with set_normalized_timespec().

Fixes: 90f8f4c0e3ce ("ptp: ocp: Add ptp_ocp_adjtime_coarse for large adjustments")
Suggested-by: Vadim Fedorenko <vfedorenko@novek.ru>
Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
v1->v2: Use set_normalized_timespec (Vadim)
---
 drivers/ptp/ptp_ocp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index dd45471f6780..36c0e188216b 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -841,7 +841,7 @@ __ptp_ocp_adjtime_locked(struct ptp_ocp *bp, u32 adj_val)
 }
 
 static void
-ptp_ocp_adjtime_coarse(struct ptp_ocp *bp, u64 delta_ns)
+ptp_ocp_adjtime_coarse(struct ptp_ocp *bp, s64 delta_ns)
 {
 	struct timespec64 ts;
 	unsigned long flags;
@@ -850,7 +850,8 @@ ptp_ocp_adjtime_coarse(struct ptp_ocp *bp, u64 delta_ns)
 	spin_lock_irqsave(&bp->lock, flags);
 	err = __ptp_ocp_gettime_locked(bp, &ts, NULL);
 	if (likely(!err)) {
-		timespec64_add_ns(&ts, delta_ns);
+		set_normalized_timespec64(&ts, ts.tv_sec,
+					  ts.tv_nsec + delta_ns);
 		__ptp_ocp_settime_locked(bp, &ts);
 	}
 	spin_unlock_irqrestore(&bp->lock, flags);
-- 
2.31.1


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

* Re: [PATCH net v2] ptp: ocp: have adjtime handle negative delta_ns correctly
  2022-05-13 22:52 [PATCH net v2] ptp: ocp: have adjtime handle negative delta_ns correctly Jonathan Lemon
@ 2022-05-15  2:16 ` Vadim Fedorenko
  2022-05-16 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2022-05-15  2:16 UTC (permalink / raw)
  To: Jonathan Lemon, netdev
  Cc: richardcochran, davem, kuba, pabeni, edumazet, kernel-team

On 13.05.2022 23:52, Jonathan Lemon wrote:
> delta_ns is a s64, but it was being passed ptp_ocp_adjtime_coarse
> as an u64.  Also, it turns out that timespec64_add_ns() only handles
> positive values, so perform the math with set_normalized_timespec().
> 
> Fixes: 90f8f4c0e3ce ("ptp: ocp: Add ptp_ocp_adjtime_coarse for large adjustments")
> Suggested-by: Vadim Fedorenko <vfedorenko@novek.ru>
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>

Acked-by: Vadim Fedorenko <vfedorenko@novek.ru>

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

* Re: [PATCH net v2] ptp: ocp: have adjtime handle negative delta_ns correctly
  2022-05-13 22:52 [PATCH net v2] ptp: ocp: have adjtime handle negative delta_ns correctly Jonathan Lemon
  2022-05-15  2:16 ` Vadim Fedorenko
@ 2022-05-16 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-16 20:20 UTC (permalink / raw)
  To: Jonathan Lemon
  Cc: netdev, vfedorenko, richardcochran, davem, kuba, pabeni,
	edumazet, kernel-team

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 13 May 2022 15:52:31 -0700 you wrote:
> delta_ns is a s64, but it was being passed ptp_ocp_adjtime_coarse
> as an u64.  Also, it turns out that timespec64_add_ns() only handles
> positive values, so perform the math with set_normalized_timespec().
> 
> Fixes: 90f8f4c0e3ce ("ptp: ocp: Add ptp_ocp_adjtime_coarse for large adjustments")
> Suggested-by: Vadim Fedorenko <vfedorenko@novek.ru>
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net,v2] ptp: ocp: have adjtime handle negative delta_ns correctly
    https://git.kernel.org/netdev/net/c/da2172a9bfec

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-05-16 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13 22:52 [PATCH net v2] ptp: ocp: have adjtime handle negative delta_ns correctly Jonathan Lemon
2022-05-15  2:16 ` Vadim Fedorenko
2022-05-16 20:20 ` patchwork-bot+netdevbpf

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