Message ID | 20230627022658.1876747-1-yajun.deng@linux.dev |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7897239vqr; Mon, 26 Jun 2023 19:34:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6eCQ2TEZcDXbPRTX7RMXGkhKdAlIsWUifVYE78Ho2t08nI/xHWU0ZqEGoAZTz5QhJSrbF2 X-Received: by 2002:a17:90a:558e:b0:262:edb9:bf49 with SMTP id c14-20020a17090a558e00b00262edb9bf49mr4826704pji.34.1687833294079; Mon, 26 Jun 2023 19:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687833294; cv=none; d=google.com; s=arc-20160816; b=kEV3G4mtu9mn6zCyXgzquAzrptxxkNhhlE7luOAf6vPrJ05/57Sw6beQ0ynNKz6R7K d6gAh45+vur+bZyDfJQJuPInLo2zT9VF+P5TE3+H90uM/2w+7O0/1kdgMdkY6KNpulvH Ne/kIDSZUUQjEqfoTwWP+2q8sdrGyCXXXC8CEHJ2odTuc75p1k8XW+4AM3PoHfTurYGR +E8/jCYfEYRM46H6WDo4OGSTkVUNMFX6qp7m7T+Qwngit+X/DisQnKydn80z22dAmbfL K4vH44qXvpTTUqsF2blXhNyYnxJ8TEnE2Iagyza9wiCdOY6Tbz+LsSvsg5bi6nuFem4P SdIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=NiLCSG+J8TFDNfzSLNUB+HE+7XY7CA+7w0Zb1WNocDM=; fh=uFb+6WCSblfd5akkrqFV8DeADoZua/naN7Y9nfLWovY=; b=GWCbgPrSZExIYhtbKIgMzTRXzqCX6KFaue5+vsOscM0byurIgDhL+ZmzUx2W4mruAF Vod7Suf+d5xj7/5Ap6A7tCTbEK+KTAfTJ0X50+gtrRI7622RdnFiDG/ijtaBxfAKurY4 vfAklU4OWJBk54GUEvCixvfBZ8Qw2l1Q58ubhL0NsEdxPK1tNMu4WdLwBprlQUyrSz/c mNTetrnrY48+sGu1EdcrDBRpfuSAiZemAdj7+x8R4V62cE2cSihSggeTflh1C8g6WV2Q Qz2ilvsqNx3DvjCkSz8PVvJzQM3PLyUu40TQiKRmZBXVT4zf4KuEDGeuIFzRjNS+CEk1 LqqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=IhqNKXxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg1-20020a17090b0d8100b00262db07eda9si4842039pjb.120.2023.06.26.19.34.28; Mon, 26 Jun 2023 19:34:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=IhqNKXxG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229965AbjF0C1S (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 22:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjF0C1Q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 22:27:16 -0400 Received: from out-28.mta1.migadu.com (out-28.mta1.migadu.com [95.215.58.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB09173B for <linux-kernel@vger.kernel.org>; Mon, 26 Jun 2023 19:27:14 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1687832833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=NiLCSG+J8TFDNfzSLNUB+HE+7XY7CA+7w0Zb1WNocDM=; b=IhqNKXxGVHAbv02ycD8gt4pXO7ev48kyVUIt/6qCLWeiBDI1Puem2akmTJkVtW85kXxD2v Dz6OdsIobdamjjipKw3k7iAt5SY9kitKkaE3qJdHabDP9eT8QLHB2BoUz6V9Y0QM8kwTDq qXggTMDRHehcW7QeX0CEM/ecZlOf+Kw= From: Yajun Deng <yajun.deng@linux.dev> To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, jacob.e.keller@intel.com Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev>, stable@vger.kernel.org Subject: [PATCH] i40e: fix the wrong PTP frequency calculation Date: Tue, 27 Jun 2023 10:26:58 +0800 Message-Id: <20230627022658.1876747-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769821483962335747?= X-GMAIL-MSGID: =?utf-8?q?1769821483962335747?= |
Series |
i40e: fix the wrong PTP frequency calculation
|
|
Commit Message
Yajun Deng
June 27, 2023, 2:26 a.m. UTC
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"), and was fixed in
commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled
parts per million"). However the latter is a new feature and hasn't been
backported to the stable releases.
This issue affects both v6.0 and v6.1 versions, and the v6.1 version is
an LTS version.
Fixes: 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation")
Cc: <stable@vger.kernel.org> # 6.1
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
---
drivers/net/ethernet/intel/i40e/i40e_ptp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 6/26/2023 7:26 PM, 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"), and was fixed in > commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled > parts per million"). However the latter is a new feature and hasn't been > backported to the stable releases. > > This issue affects both v6.0 and v6.1 versions, and the v6.1 version is > an LTS version. > > Fixes: 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation") > Cc: <stable@vger.kernel.org> # 6.1 > Signed-off-by: Yajun Deng <yajun.deng@linux.dev> > --- > 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); This straight forward fix makes sense. However, it wasn't obvious to me without context why the 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation") was where the fault got introduced. Thus, here is that context for anyone else who failed to spot it just looking at shrunk patch diffs. --> code before that commit <--- > /** > * i40e_ptp_adjfreq - Adjust the PHC frequency > * @ptp: The PTP clock structure > * @ppb: Parts per billion adjustment from the base > * > * Adjust the frequency of the PHC by the indicated parts per billion from the > * base frequency. > **/ > static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) > { > struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); > struct i40e_hw *hw = &pf->hw; > u64 adj, freq, diff; > int neg_adj = 0; > > if (ppb < 0) { > neg_adj = 1; > ppb = -ppb; > } > > freq = I40E_PTP_40GB_INCVAL; frequency is left just as base I40E_PTP_40GB_INCVAL. > freq *= ppb; > diff = div_u64(freq, 1000000000ULL); > > if (neg_adj) > adj = I40E_PTP_40GB_INCVAL - diff; > else > adj = I40E_PTP_40GB_INCVAL + diff; > So the base here can't be freq since we modify freq above using *=, but using I40E_PTP_40GB_INCVAL is consistent. > /* At some link speeds, the base incval is so large that directly > * multiplying by ppb would result in arithmetic overflow even when > * using a u64. Avoid this by instead calculating the new incval > * always in terms of the 40GbE clock rate and then multiplying by the > * link speed factor afterwards. This does result in slightly lower > * precision at lower link speeds, but it is fairly minor. > */ > smp_mb(); /* Force any pending update before accessing. */ > adj *= READ_ONCE(pf->ptp_adj_mult); > Finally, the multiply is applied last. This affects the combined base + difference, and is done in order to avoid overflowing the *= used in the original implementation. > wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF); > wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32); > > return 0; > } ---> code after that commit <--- > /** > * i40e_ptp_adjfreq - Adjust the PHC frequency > * @ptp: The PTP clock structure > * @ppb: Parts per billion adjustment from the base > * > * Adjust the frequency of the PHC by the indicated parts per billion from the > * base frequency. > **/ > static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) > { > struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); > struct i40e_hw *hw = &pf->hw; > u64 adj, freq, diff; > int neg_adj = 0; > > if (ppb < 0) { > neg_adj = 1; > ppb = -ppb; > } > > smp_mb(); /* Force any pending update before accessing. */ > freq = I40E_PTP_40GB_INCVAL * READ_ONCE(pf->ptp_adj_mult); > diff = mul_u64_u64_div_u64(freq, (u64)ppb, > 1000000000ULL); > Here, we assign freq to be the I40E_PTP_40GB_INCVAL times the ptp_adj_mult value, and then we don't modify it, instead using mul_u64_u64_div_u64. > if (neg_adj) > adj = I40E_PTP_40GB_INCVAL - diff; > else > adj = I40E_PTP_40GB_INCVAL + diff; > But then the diff is applied on the wrong value, and no multiplication is done afterwards. > wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF); > wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32); > > return 0; > } ---> current version with adjust_by_scaled_ppm <--- > /** > * i40e_ptp_adjfine - Adjust the PHC frequency > * @ptp: The PTP clock structure > * @scaled_ppm: Scaled parts per million adjustment from base > * > * Adjust the frequency of the PHC by the indicated delta from the base > * frequency. > * > * Scaled parts per million is ppm with a 16 bit binary fractional field. > **/ > static int i40e_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) > { > struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); > struct i40e_hw *hw = &pf->hw; > u64 adj, base_adj; > > smp_mb(); /* Force any pending update before accessing. */ > base_adj = I40E_PTP_40GB_INCVAL * READ_ONCE(pf->ptp_adj_mult); > > adj = adjust_by_scaled_ppm(base_adj, scaled_ppm); > Using adjust_by_scaled_ppm correctly performs the calculation and uses the base adjustment, so there's no error here. > wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF); > wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32); > > return 0; > } Thanks for finding and fixing this mistake. I think its the simplest fix to get into the stable kernel that are broken, since taking the adjust_by_scaled_ppm version would require additional patches. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
On 2023/6/28 04:20, Jacob Keller wrote: > > On 6/26/2023 7:26 PM, 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"), and was fixed in >> commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled >> parts per million"). However the latter is a new feature and hasn't been >> backported to the stable releases. >> >> This issue affects both v6.0 and v6.1 versions, and the v6.1 version is >> an LTS version. >> >> Fixes: 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for PTP frequency calculation") >> Cc: <stable@vger.kernel.org> # 6.1 >> Signed-off-by: Yajun Deng <yajun.deng@linux.dev> >> --- >> 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); > This straight forward fix makes sense. However, it wasn't obvious to me > without context why the 3626a690b717 ("i40e: use mul_u64_u64_div_u64 for > PTP frequency calculation") was where the fault got introduced. Thus, > here is that context for anyone else who failed to spot it just looking > at shrunk patch diffs. > > --> code before that commit <--- >> /** >> * i40e_ptp_adjfreq - Adjust the PHC frequency >> * @ptp: The PTP clock structure >> * @ppb: Parts per billion adjustment from the base >> * >> * Adjust the frequency of the PHC by the indicated parts per billion from the >> * base frequency. >> **/ >> static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) >> { >> struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); >> struct i40e_hw *hw = &pf->hw; >> u64 adj, freq, diff; >> int neg_adj = 0; >> >> if (ppb < 0) { >> neg_adj = 1; >> ppb = -ppb; >> } >> >> freq = I40E_PTP_40GB_INCVAL; > frequency is left just as base I40E_PTP_40GB_INCVAL. > >> freq *= ppb; >> diff = div_u64(freq, 1000000000ULL); >> >> if (neg_adj) >> adj = I40E_PTP_40GB_INCVAL - diff; >> else >> adj = I40E_PTP_40GB_INCVAL + diff; >> > So the base here can't be freq since we modify freq above using *=, but > using I40E_PTP_40GB_INCVAL is consistent. > >> /* At some link speeds, the base incval is so large that directly >> * multiplying by ppb would result in arithmetic overflow even when >> * using a u64. Avoid this by instead calculating the new incval >> * always in terms of the 40GbE clock rate and then multiplying by the >> * link speed factor afterwards. This does result in slightly lower >> * precision at lower link speeds, but it is fairly minor. >> */ >> smp_mb(); /* Force any pending update before accessing. */ >> adj *= READ_ONCE(pf->ptp_adj_mult); >> > Finally, the multiply is applied last. This affects the combined base + > difference, and is done in order to avoid overflowing the *= used in the > original implementation. > >> wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF); >> wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32); >> >> return 0; >> } > > ---> code after that commit <--- >> /** >> * i40e_ptp_adjfreq - Adjust the PHC frequency >> * @ptp: The PTP clock structure >> * @ppb: Parts per billion adjustment from the base >> * >> * Adjust the frequency of the PHC by the indicated parts per billion from the >> * base frequency. >> **/ >> static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) >> { >> struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); >> struct i40e_hw *hw = &pf->hw; >> u64 adj, freq, diff; >> int neg_adj = 0; >> >> if (ppb < 0) { >> neg_adj = 1; >> ppb = -ppb; >> } >> >> smp_mb(); /* Force any pending update before accessing. */ >> freq = I40E_PTP_40GB_INCVAL * READ_ONCE(pf->ptp_adj_mult); >> diff = mul_u64_u64_div_u64(freq, (u64)ppb, >> 1000000000ULL); >> > Here, we assign freq to be the I40E_PTP_40GB_INCVAL times the > ptp_adj_mult value, and then we don't modify it, instead using > mul_u64_u64_div_u64. > >> if (neg_adj) >> adj = I40E_PTP_40GB_INCVAL - diff; >> else >> adj = I40E_PTP_40GB_INCVAL + diff; >> > But then the diff is applied on the wrong value, and no multiplication > is done afterwards. > >> wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF); >> wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32); >> >> return 0; >> } > ---> current version with adjust_by_scaled_ppm <--- >> /** >> * i40e_ptp_adjfine - Adjust the PHC frequency >> * @ptp: The PTP clock structure >> * @scaled_ppm: Scaled parts per million adjustment from base >> * >> * Adjust the frequency of the PHC by the indicated delta from the base >> * frequency. >> * >> * Scaled parts per million is ppm with a 16 bit binary fractional field. >> **/ >> static int i40e_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) >> { >> struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); >> struct i40e_hw *hw = &pf->hw; >> u64 adj, base_adj; >> >> smp_mb(); /* Force any pending update before accessing. */ >> base_adj = I40E_PTP_40GB_INCVAL * READ_ONCE(pf->ptp_adj_mult); >> >> adj = adjust_by_scaled_ppm(base_adj, scaled_ppm); >> > Using adjust_by_scaled_ppm correctly performs the calculation and uses > the base adjustment, so there's no error here. > >> wr32(hw, I40E_PRTTSYN_INC_L, adj & 0xFFFFFFFF); >> wr32(hw, I40E_PRTTSYN_INC_H, adj >> 32); >> >> return 0; >> } > > Thanks for finding and fixing this mistake. I think its the simplest fix > to get into the stable kernel that are broken, since taking the > adjust_by_scaled_ppm version would require additional patches. > > Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> > Kindly ping...
On 9/25/2023 12:55 AM, Yajun Deng wrote: > > On 2023/6/28 04:20, Jacob Keller wrote: >> >> On 6/26/2023 7:26 PM, 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"), and was fixed in >>> commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled >>> parts per million"). However the latter is a new feature and hasn't been >>> backported to the stable releases. >>> >>> This issue affects both v6.0 and v6.1 versions, and the v6.1 version is >>> an LTS version. >>> ... >> >> Thanks for finding and fixing this mistake. I think its the simplest fix >> to get into the stable kernel that are broken, since taking the >> adjust_by_scaled_ppm version would require additional patches. >> >> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> >> > Kindly ping... As this patch looks to be for stable, you need to follow the process for that. I believe your situation would fall into option 3: https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-3 Thanks, Tony
On 2023/9/26 07:59, Tony Nguyen wrote: > On 9/25/2023 12:55 AM, Yajun Deng wrote: >> >> On 2023/6/28 04:20, Jacob Keller wrote: >>> >>> On 6/26/2023 7:26 PM, 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"), and was fixed in >>>> commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled >>>> parts per million"). However the latter is a new feature and hasn't >>>> been >>>> backported to the stable releases. >>>> >>>> This issue affects both v6.0 and v6.1 versions, and the v6.1 >>>> version is >>>> an LTS version. >>>> > > ... > >>> >>> Thanks for finding and fixing this mistake. I think its the simplest >>> fix >>> to get into the stable kernel that are broken, since taking the >>> adjust_by_scaled_ppm version would require additional patches. >>> >>> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> >>> >> Kindly ping... > > As this patch looks to be for stable, you need to follow the process > for that. I believe your situation would fall into option 3: > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-3 > > Yes, it needs an upstream commit ID. But this patch didn't need to apply to the upstream. As the commit of the patch, the issue was fixed in commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled parts per million"). However the commit is a new feature and hasn't been backported to the stable releases. Therefore, the patch does not have an upstream commit ID, and only needs to be applied to stable. > Thanks, > Tony
On Tue, Sep 26, 2023 at 09:54:29AM +0800, Yajun Deng wrote: > > On 2023/9/26 07:59, Tony Nguyen wrote: > > On 9/25/2023 12:55 AM, Yajun Deng wrote: > > > > > > On 2023/6/28 04:20, Jacob Keller wrote: > > > > > > > > On 6/26/2023 7:26 PM, 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"), and was fixed in > > > > > commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled > > > > > parts per million"). However the latter is a new feature and > > > > > hasn't been > > > > > backported to the stable releases. > > > > > > > > > > This issue affects both v6.0 and v6.1 versions, and the v6.1 > > > > > version is > > > > > an LTS version. > > > > > > > > > ... > > > > > > > > > > Thanks for finding and fixing this mistake. I think its the > > > > simplest fix > > > > to get into the stable kernel that are broken, since taking the > > > > adjust_by_scaled_ppm version would require additional patches. > > > > > > > > Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> > > > > > > > Kindly ping... > > > > As this patch looks to be for stable, you need to follow the process for > > that. I believe your situation would fall into option 3: > > https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-3 > > > > > Yes, it needs an upstream commit ID. But this patch didn't need to apply to > the upstream. > > As the commit of the patch, the issue was fixed in > commit 1060707e3809 ("ptp: introduce helpers to adjust by scaled > parts per million"). However the commit is a new feature and hasn't been > backported to the stable releases. > > Therefore, the patch does not have an upstream commit ID, and only needs to > be applied to stable. That wasn't very obvious to most of us, perhaps resend it and explicitly ask for acks/reviews so it can be only applied to the 6.1.y tree? thanks, greg k-h
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);