Message ID | 20230926071059.1239033-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:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp2015876vqu; Tue, 26 Sep 2023 08:52:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERyYznv2In2uLAa5ASQHal3WJ2dZDti9swzhI7U04xR8k75kZpvHVW4DyFS5RdzpUjX4i0 X-Received: by 2002:a05:6a00:1818:b0:690:2ecd:a59c with SMTP id y24-20020a056a00181800b006902ecda59cmr9378746pfa.23.1695743554604; Tue, 26 Sep 2023 08:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695743554; cv=none; d=google.com; s=arc-20160816; b=09RSZko+unQCOE2PpwxZgGhV/AAAhjur1xUXZDfiINdAatUG54M+5RtGCqHYmvMcaJ HpGeg06bIPVcMzca5Y645BwFpdXi9EdzGo1Qin6IWVpUhPIccyvt1AtOSC4WB1qBVOwv l/r+hYEYFOEZYJBPMeE9oEBoQ2f+XcfSH4Mh7WKjAFrh0I7EtbjEaSU0Khqqv9Uikdai I9Kj5diu3vk35mvbO9ixTL3dyQ+P7nLCH0oYoz66ZH/DUzscG+Yqph3dhRZr5Bo4rpFM yjRTdrY/hjs4cNbg9pqfW8AXC1aPWTx9ZiiILjzw2vmf/i7poJhT96R9++WxfH/4mnUE zezA== 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=syqQR+9bPrQHdilL6zKTkrPq1VgSbRvVhw85Q7F9WZ4=; fh=lnTYizlpPujqyI2gbHlM0e/v9WyuFwHZQ3d4QblVNpw=; b=aqoje4IOztoOJ3QH/i21Pqz2BcUQR7LJduLjhkgE3Xj9DnUOWhFKbRY8kDTfpiWi9u 5X4SR14MRQVyaZ6Cl//0YY5RDeYJArpmwhPtvCiIH27lrc0/0DsTal3/ezHdkNOkIG9Y VPG5yd6VLAe+tO0utpn2Eo7sUuZUHP+wKvSl4j4LNFUMroS7z8Ptvzf2uZnqRiSWwrqv UXMLbmbmcz/QcFSp+qNvt68mgeDFNRq8dMUc+5u8ktY28kqesOSDeY6q6YQnZXBS/JO1 BbSA7oP9HAz99O5npjoz+6cxUEUU2Xn+2NN/rmlowSe/eE9D8dr8s/is64JjiqhRPP3i 932w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=B7R2Klen; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a21-20020a63e855000000b00578d7a3a4fdsi12818603pgk.563.2023.09.26.08.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 08:52:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=B7R2Klen; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E8C14812D203; Tue, 26 Sep 2023 00:11:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbjIZHLe (ORCPT <rfc822;ruipengqi7@gmail.com> + 27 others); Tue, 26 Sep 2023 03:11:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjIZHLb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 26 Sep 2023 03:11:31 -0400 Received: from out-201.mta0.migadu.com (out-201.mta0.migadu.com [91.218.175.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 759CEDE for <linux-kernel@vger.kernel.org>; Tue, 26 Sep 2023 00:11:24 -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=1695712282; 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=syqQR+9bPrQHdilL6zKTkrPq1VgSbRvVhw85Q7F9WZ4=; b=B7R2Klencrq0fTtMQPjIqR9iGvs7PJvaVFQliMgF9PNe5Ko1WkYEf6kFLTERkfM5/cf8eh Wu7gwqHpeVik7TI2jErLTf5Uj4xokGz0Gtf2RTq+RaTN/778O4FWJji7emfynVtBDp+U3D lGakHMqUulc7Nj2VfjrRSWWhAZd2It4= From: Yajun Deng <yajun.deng@linux.dev> To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, jacob.e.keller@intel.com, gregkh@linuxfoundation.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Yajun Deng <yajun.deng@linux.dev> Subject: [PATCH RESEND] i40e: fix the wrong PTP frequency calculation Date: Tue, 26 Sep 2023 15:10:59 +0800 Message-Id: <20230926071059.1239033-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 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 26 Sep 2023 00:11:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778115993904717657 X-GMAIL-MSGID: 1778115993904717657 |
Series |
[RESEND] i40e: fix the wrong PTP frequency calculation
|
|
Commit Message
Yajun Deng
Sept. 26, 2023, 7:10 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"), 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(-)
Comments
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
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);