Skip to contentSkip to conversation

i40e: fix i40e_ptp_adjtime when given a negative delta

PATCH New Jacob Keller 4 participants 7 messages Feb 25, 2019 – Mar 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers.

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior.

This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it.

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

---
 drivers/net/ethernet/intel/i40e/i40e_ptp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ptp.c +3 -2
index 66147c3f5f2c..439c35f0c581 100644
@@ -146,12 +146,13 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
 static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 {
 	struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
-	struct timespec64 now;
+	struct timespec64 now, then;
 
+	then = ns_to_timespec64(delta);
 	mutex_lock(&pf->tmreg_lock);
 
 	i40e_ptp_read(pf, &now, NULL);
-	timespec64_add_ns(&now, delta);
+	now = timespec64_add(now, then);
 	i40e_ptp_write(pf, (const struct timespec64 *)&now);
 
 	mutex_unlock(&pf->tmreg_lock);
Signature · 1 line
2.18.0.219.gaf81d287a9da
#1 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 9 lines · Jacob Keller

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers.

Quoted 8 lines

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior.

This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it.

Ah, this is not the bug I was referring to but actually worse. I was only worried about hogging the CPU while doing billions of additions in a loop, and had not realized it also changes the result.

Quoted 2 lines

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

#2 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 24 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Monday, February 25, 2019 11:47 AM
To: Keller, Jacob E <[email protected]>
Cc: Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>
Subject: Re: [PATCH] i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 15 lines · Jacob Keller

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers.

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior.

Quoted 8 lines
Quoted 2 lines

This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it.

Ah, this is not the bug I was referring to but actually worse. I was only worried about hogging the CPU while doing billions of additions in a loop, and had not realized it also changes the result.

Yep. That's what I figured out last Friday.

Regards,
Jake

Quoted 4 lines
Quoted 2 lines

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

#3 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

In reply to Arnd Bergmann
Quoted 25 lines · Arnd Bergmann
Quoted 9 lines · Jacob Keller

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers.

Quoted 8 lines

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior.

This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it.

Ah, this is not the bug I was referring to but actually worse. I was only worried about hogging the CPU while doing billions of additions in a loop, and had not realized it also changes the result.

Quoted 4 lines
Quoted 2 lines

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

Any update on this? Your patch doesn't seem to have made it in as a bugfix, or into linux-next yet.

Arnd

#4 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 37 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Monday, March 25, 2019 9:45 AM
To: Keller, Jacob E <[email protected]>
Cc: Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T <[email protected]>
Subject: Re: [PATCH] i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 28 lines · Arnd Bergmann
Quoted 9 lines · Jacob Keller

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers.

Quoted 8 lines

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior.

This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it.

Ah, this is not the bug I was referring to but actually worse. I was only worried about hogging the CPU while doing billions of additions in a loop, and had not realized it also changes the result.

Quoted 2 lines

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

Quoted 6 lines
Quoted 1 line

Any update on this? Your patch doesn't seem to have made it in as a bugfix, or into linux-next yet.

Arnd

It's still marked as under review on patchworks. It was marked as tested by Andrew Bowers, so I am not sure what else holdup is.

Jeff?

I think this patch could/should go through net because it's a bug fix.

Thanks,
Jake

#5 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 54 lines · Jacob E
Quoted 47 lines

-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]
Sent: Monday, March 25, 2019 9:45 AM
To: Keller, Jacob E <[email protected]>
Cc: Intel Wired LAN <[email protected]>; Kirsher, Jeffrey T
<[email protected]>
Subject: Re: [PATCH] i40e: fix i40e_ptp_adjtime when given a negative delta

Quoted 35 lines · Arnd Bergmann
Quoted 20 lines · Jacob Keller

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call
to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the
change was documented in the commit message, and (b) timespec64_add_ns
supported negative numbers.

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in
a regression where i40e_ptp_adjtime would interpret small negative
adjustments as large positive additions, resulting in incorrect behavior.

Quoted 3 lines

This commit doesn't appear to fix anything, is not well explained, and
introduces a bug, so lets just revert it.

Ah, this is not the bug I was referring to but actually worse. I was only worried about hogging the CPU while doing billions of additions in a loop, and had not realized it also changes the result.

Quoted 3 lines

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

Quoted 6 lines
Quoted 1 line

Any update on this? Your patch doesn't seem to have made it in as a bugfix, or into linux-next yet.

Arnd

Quoted 7 lines

It's still marked as under review on patchworks. It was marked as tested by Andrew Bowers, so I am not sure what else holdup is.

Jeff?

I think this patch could/should go through net because it's a bug fix.

I apologize, I got bogged down with ice driver patches. I will push
the fix to Dave's net tree now.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20190326/c5a8fc4f/attachment.asc>

#6 lore raw

PATCH 1/1 i40e: fix i40e_ptp_adjtime when given a negative delta

In reply to Jacob Keller
Quoted 22 lines

-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 25, 2019 11:20 AM
To: Intel Wired LAN <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Subject: [Intel-wired-lan] [PATCH] i40e: fix i40e_ptp_adjtime when given a negative delta

Commit 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26) claims to be cleaning up references to 32-bit timespecs.

The actual contents of the commit make no sense, as it converts a call to timespec64_add into timespec64_add_ns. This would seem ok, if (a) the change was documented in the commit message, and (b) timespec64_add_ns supported negative numbers.

timespec64_add_ns doesn't work with signed deltas, because the implementation is based around iter_div_u64_rem. This change resulted in a regression where i40e_ptp_adjtime would interpret small negative adjustments as large positive additions, resulting in incorrect behavior.

Quoted 8 lines

This commit doesn't appear to fix anything, is not well explained, and introduces a bug, so lets just revert it.

Reverts: 0ac30ce43323 ("i40e: fix up 32 bit timespec references", 2017-07-26)

---
 drivers/net/ethernet/intel/i40e/i40e_ptp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)