From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AEFEC43334 for ; Thu, 21 Jul 2022 21:30:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1C8DF60B37; Thu, 21 Jul 2022 21:30:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1C8DF60B37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1658439034; bh=xqRTEExeTV9yfDpxCCIDP8M2boKmA80X9RvZ8KvAoM0=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rsBoovbe/o7NRcqsNW63uhOaqKF/zL+gM8KLKms7SpFKcF/h8P+jQgmTct2eDAbzF wg97v9mpuBO+HXqCAibEQ9Hyslu4C10+XlBnZ/ySWJDHLmPs1+WgdAGxxeT2yh0DM3 H2SqtJQ+iAZ3cyhA/fY20pvNv4+ouAIY5b02kKLa+bWrID4Xw4eEDlmSYiegjy/zsV 8q2PzZMSY4r3Go1kDqrGG3/wsThMUAs0xSzadOiBimfUR2WkIxHKba3+zurlO5DrXH O/4/hWvmIufQ+iciJZRaEUZdl4pQmW6OcWkB649JyRamMQWIZA3AtS30GlmgQH9QDT RsfFYIGqkBSpQ== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vN1Onfht1TwR; Thu, 21 Jul 2022 21:30:33 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id 2D4F660C05; Thu, 21 Jul 2022 21:30:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2D4F660C05 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 180E41BF375 for ; Thu, 21 Jul 2022 21:30:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 54DAB83F1F for ; Thu, 21 Jul 2022 21:30:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 54DAB83F1F X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NCSpzZlWP9pR for ; Thu, 21 Jul 2022 21:30:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org AB47C83F91 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by smtp1.osuosl.org (Postfix) with ESMTPS id AB47C83F91 for ; Thu, 21 Jul 2022 21:30:10 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6400,9594,10415"; a="274029238" X-IronPort-AV: E=Sophos;i="5.93,183,1654585200"; d="scan'208";a="274029238" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 14:30:10 -0700 X-IronPort-AV: E=Sophos;i="5.93,183,1654585200"; d="scan'208";a="740833164" Received: from jekeller-desk.amr.corp.intel.com ([10.166.241.7]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2022 14:30:09 -0700 From: Jacob Keller To: Intel Wired LAN Date: Thu, 21 Jul 2022 14:30:01 -0700 Message-Id: <20220721213001.2483596-9-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.35.1.456.ga9c7032d4631 In-Reply-To: <20220721213001.2483596-1-jacob.e.keller@intel.com> References: <20220721213001.2483596-1-jacob.e.keller@intel.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658439010; x=1689975010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M8If7d6GKztEBLpf8FdtfH6Aw7XWPyZcqoiYSe8xjCc=; b=nVZBwBB5dFUoEwrr/q4taUHJNz9NipGrgUeq+qIpJpLX5sZS+BjHEvEx 4qlkfTrdYBSmf6uR1VfvLyUZ0nWRFyj4GD4BDbZSFeWTL5cfOEx+hYpvf RsZDU11mQxcRR/4xnwCatvUCq3ppX8w1GXx/Cl3oF7O7S3uj+UQZ/5fNT MVTT61WF7YKNwNp8osZVXBqCIySHl7hkcfS4LkQ5MfV3K0Nd8RsRv0Ex0 2LLG6mbFSK7ioO4vvXNxzdniuKog5N4GKT6xwIqi2SSu2c1QQ/FTQ7rlJ 5pULKS7jgakcniZ4s3sVSrN912vMmGRjplXrZiESsPPUEMVGIIyHFbeAV g==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=nVZBwBB5 Subject: [Intel-wired-lan] [net-next PATCH 7/7] igb: convert .adjfreq to .adjfine X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" The 82576 PTP implementation still uses .adjfreq instead of using the newer .adjfine. This implementation uses a pre-simplified calculation since the base increment value for the 82576 is just 16 * 2^19. Converting this into scaled_ppm is tricky, and makes the intent a bit less clear. Simply convert to the normal flow of multiplying the base increment value by the scaled_ppm and then dividing by 1000000ULL << 16. This can be implemented using mul_u64_u64_div_u64 which can avoid the possible overflow that might occur for large adjustments. Use of .adjfine can improve the precision of small adjustments and gets us one driver closer to removing the old implementation from the kernel entirely. Signed-off-by: Jacob Keller --- drivers/net/ethernet/intel/igb/igb_ptp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index 02fec948ce64..15e57460e19e 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -190,7 +190,7 @@ static void igb_ptp_systim_to_hwtstamp(struct igb_adapter *adapter, } /* PTP clock operations */ -static int igb_ptp_adjfreq_82576(struct ptp_clock_info *ptp, s32 ppb) +static int igb_ptp_adjfine_82576(struct ptp_clock_info *ptp, long scaled_ppm) { struct igb_adapter *igb = container_of(ptp, struct igb_adapter, ptp_caps); @@ -199,15 +199,14 @@ static int igb_ptp_adjfreq_82576(struct ptp_clock_info *ptp, s32 ppb) u64 rate; u32 incvalue; - if (ppb < 0) { + if (scaled_ppm < 0) { neg_adj = 1; - ppb = -ppb; + scaled_ppm = -scaled_ppm; } - rate = ppb; - rate <<= 14; - rate = div_u64(rate, 1953125); - incvalue = 16 << IGB_82576_TSYNC_SHIFT; + incvalue = INCVALUE_82576; + rate = mul_u64_u64_div_u64(incvalue, (u64)scaled_ppm, + 1000000ULL << 16); if (neg_adj) incvalue -= rate; @@ -1347,7 +1346,7 @@ void igb_ptp_init(struct igb_adapter *adapter) adapter->ptp_caps.max_adj = 999999881; adapter->ptp_caps.n_ext_ts = 0; adapter->ptp_caps.pps = 0; - adapter->ptp_caps.adjfreq = igb_ptp_adjfreq_82576; + adapter->ptp_caps.adjfine = igb_ptp_adjfine_82576; adapter->ptp_caps.adjtime = igb_ptp_adjtime_82576; adapter->ptp_caps.gettimex64 = igb_ptp_gettimex_82576; adapter->ptp_caps.settime64 = igb_ptp_settime_82576; -- 2.35.1.456.ga9c7032d4631 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan