netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] i40e: fix the wrong PTP frequency calculation
@ 2023-09-26  7:10 Yajun Deng
  2023-10-07 11:33 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Yajun Deng @ 2023-09-26  7:10 UTC (permalink / raw)
  To: jesse.brandeburg, anthony.l.nguyen, jacob.e.keller, gregkh
  Cc: netdev, linux-kernel, stable, Yajun Deng

The new adjustment should be based on the base frequency, not the
I40E_PTP_40GB_INCVAL in i40e_ptp_adjfine().

This issue was introduced in commit 3626a690b717 ("i40e: use
mul_u64_u64_div_u64 for PTP frequency calculation"), frequency is left
just as base I40E_PTP_40GB_INCVAL before the commit. After the commit,
frequency is the I40E_PTP_40GB_INCVAL times the ptp_adj_mult value.
But then the diff is applied on the wrong value, and no multiplication
is done afterwards.

It was accidentally fixed in commit 1060707e3809 ("ptp: introduce helpers
to adjust by scaled parts per million"). It uses adjust_by_scaled_ppm
correctly performs the calculation and uses the base adjustment, so
there's no error here. But it is a new feature and doesn't need to
backported to the stable releases.

This issue affects both v6.0 and v6.1, and the v6.1 version is an LTS
release. Therefore, the patch only needs to be applied to v6.1 stable.

Fixes: 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation")
Cc: <stable@vger.kernel.org> # 6.1
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index ffea0c9c82f1..97a9efe7b713 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -361,9 +361,9 @@ static int i40e_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
 				   1000000ULL << 16);
 
 	if (neg_adj)
-		adj = I40E_PTP_40GB_INCVAL - diff;
+		adj = freq - diff;
 	else
-		adj = I40E_PTP_40GB_INCVAL + diff;
+		adj = freq + diff;
 
 	wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF);
 	wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32);
-- 
2.25.1


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

* Re: [PATCH RESEND] i40e: fix the wrong PTP frequency calculation
  2023-09-26  7:10 [PATCH RESEND] i40e: fix the wrong PTP frequency calculation Yajun Deng
@ 2023-10-07 11:33 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-10-07 11:33 UTC (permalink / raw)
  To: Yajun Deng
  Cc: jesse.brandeburg, anthony.l.nguyen, jacob.e.keller, netdev,
	linux-kernel, stable

On Tue, Sep 26, 2023 at 03:10:59PM +0800, Yajun Deng wrote:
> The new adjustment should be based on the base frequency, not the
> I40E_PTP_40GB_INCVAL in i40e_ptp_adjfine().
> 
> This issue was introduced in commit 3626a690b717 ("i40e: use
> mul_u64_u64_div_u64 for PTP frequency calculation"), frequency is left
> just as base I40E_PTP_40GB_INCVAL before the commit. After the commit,
> frequency is the I40E_PTP_40GB_INCVAL times the ptp_adj_mult value.
> But then the diff is applied on the wrong value, and no multiplication
> is done afterwards.
> 
> It was accidentally fixed in commit 1060707e3809 ("ptp: introduce helpers
> to adjust by scaled parts per million"). It uses adjust_by_scaled_ppm
> correctly performs the calculation and uses the base adjustment, so
> there's no error here. But it is a new feature and doesn't need to
> backported to the stable releases.
> 
> This issue affects both v6.0 and v6.1, and the v6.1 version is an LTS
> release. Therefore, the patch only needs to be applied to v6.1 stable.
> 
> Fixes: 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation")
> Cc: <stable@vger.kernel.org> # 6.1
> Cc: Tony Nguyen <anthony.l.nguyen@intel.com>
> Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
>  drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Now queued up, thanks.

greg k-h

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

end of thread, other threads:[~2023-10-07 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-26  7:10 [PATCH RESEND] i40e: fix the wrong PTP frequency calculation Yajun Deng
2023-10-07 11:33 ` Greg KH

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