Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EC84C2B9F4 for ; Mon, 14 Jun 2021 20:52:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5A596124B for ; Mon, 14 Jun 2021 20:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235359AbhFNUyM (ORCPT ); Mon, 14 Jun 2021 16:54:12 -0400 Received: from mga06.intel.com ([134.134.136.31]:41310 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235398AbhFNUyL (ORCPT ); Mon, 14 Jun 2021 16:54:11 -0400 IronPort-SDR: jgh4QnCOngczI93Khn/P3KxzlLMYEAlRvCTapS4j1AJIoVIye/SLACzi6JEVBS7mAyWcexxmr0 EgswHNoiHeMg== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="267026320" X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="267026320" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 13:52:00 -0700 IronPort-SDR: Vp/EfvIuMxOi6JmHxdGjrQ3IpMDGHvy+EpVRrkoq4qGR7OrNkXL86lsFxQ4YybG8sO4anafUI+ woC6b5R7MiHg== X-IronPort-AV: E=Sophos;i="5.83,273,1616482800"; d="scan'208";a="451713894" Received: from jekeller-mobl1.amr.corp.intel.com (HELO [10.212.172.19]) ([10.212.172.19]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 13:52:00 -0700 Subject: Re: [PATCH net-next 5/8] ice: register 1588 PTP clock device object for E810 devices To: Jakub Kicinski Cc: "Nguyen, Anthony L" , Richard Cochran , "davem@davemloft.net" , "netdev@vger.kernel.org" , "sassmann@redhat.com" , "Brelinski, TonyX" References: <20210611162000.2438023-1-anthony.l.nguyen@intel.com> <20210611162000.2438023-6-anthony.l.nguyen@intel.com> <20210611141800.5ebe1d4e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20210614110831.65d21c8b@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <427ddb2579f14d77b537aae9c2fa9759@intel.com> <20210614134802.633be4c5@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> From: Jacob Keller Organization: Intel Corporation Message-ID: Date: Mon, 14 Jun 2021 13:51:57 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210614134802.633be4c5@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 6/14/2021 1:48 PM, Jakub Kicinski wrote: > On Mon, 14 Jun 2021 19:50:23 +0000 Keller, Jacob E wrote: >>>> Hmmm.. I thought ppb was a s64, not an s32. >>>> >>>> In general, I believe max_adj is usually capped at 1 billion anyways, >>>> since it doesn't make sense to slow a clock by more than 1billioln ppb, >>>> and increasing it more than that isn't really useful either. >>> >>> Do you mean it's capped somewhere in the code to 1B? >>> >>> I'm no time expert but this is not probability where 1 is a magic >>> value, adjusting clock by 1 - 1ppb vs 1 + 1ppb makes little difference, >>> no? Both mean something is super fishy with the nominal or expected >>> frequency, but the hardware can do that and more. >>> >>> Flipping the question, if adjusting by large ppb values is not correct, >>> why not cap the adjustment at the value which would prevent the u64 >>> overflow? >> >> Large ppb values are sometimes used when you want to slew a clock to >> bring it in sync when its a few milliseconds to seconds off, without >> performing a time jump (so that you maintain monotonic increasing >> time). > > Ah, you're right, ptp4l will explicitly cap the freq adjustments > based on max_adj from sysfs, so setting max_adj too low could impact > the convergence time in strange scenarios. > Your patch to fix it so that the conversion from scaled_ppm to ppb can't overflow is the correct approach, here. The scaled_ppm function didn't account for the fact that the provided adjustment could overflow the s32. Increasing that to s64 ensures it won't overflow and prevents invalid bogus frequencies from passing that check.