Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4131896ybl; Tue, 20 Aug 2019 07:27:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6xaqjImXX5+GUsptd7EJNPVmTgOYdTQNvpEN/zNxQW7zQsYKShzzqAmQ6qjGjPRdTPjBo X-Received: by 2002:a63:724b:: with SMTP id c11mr25500951pgn.30.1566311233277; Tue, 20 Aug 2019 07:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566311233; cv=none; d=google.com; s=arc-20160816; b=siI59sxN36LcqIaKylFeltxFwB86lRuXQWtLSGCtL/hdYhNhrxbhyUpCHk2OOC/b5F kf3UQHc2hBETkLK1tgysFhbA3bsWldoZq7I2fnXRmCHM1prooWSsVFx+s7HFG94qjHuL k239FVAowgKg5X1mIkRk5wat8qkwCPn8fkNutq4qgIweTfwhgEjIKyaztWIx3jX96LVm Byq/jPqsPS09jD8nboC33mr/zBcf/CMYHDLvLRgq40+q9rRukfMCwf+oq359JqfOS5Nr +Tk6CSV2rgKp2gMkIWIpN9vKiKn9Tou8fDU+KDxOcadTnrLyGqc4f/e0GA7X/2wKpeEv fnFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XOfMJETDcY5ZJLtTtiAt/sCoUhfs93USG/uKx6KJa40=; b=b94oC+gsGk5iEwSr2RhXU3SfVrIQzQ+zi04xvI/89dheqlYAhQTEWu4ajbkrpr0UJN k5xAPbpOBpUm8pQA6Xv48IqVFJxYBNUxpQhO9cNtm9biQp7d3YvN0zeLQsJtUsGKGk3B l0FzAMByzyC6VvRG8DK+qdJ6e4gJ/AZjeH0ib0IonY78GD09UftjL3xMMy/Ed0KAlNSA TCku6xGxj9FEHkCxLkFjay6lCt0orvjqYKzvF/1B+vVDQYHCkb7gCgCdexAZUAL2Fc4C dQWaVAqBqMFDJi7KDPwDcAcnPWoVYD9IlmMutSNpsG0mE8Yp7tyLU9jeVIamnVKJ+qfN nRNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11si11951184pgt.124.2019.08.20.07.26.57; Tue, 20 Aug 2019 07:27:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730227AbfHTOZn (ORCPT + 99 others); Tue, 20 Aug 2019 10:25:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35850 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730133AbfHTOZm (ORCPT ); Tue, 20 Aug 2019 10:25:42 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E77F7EB8A; Tue, 20 Aug 2019 14:25:42 +0000 (UTC) Received: from localhost (holly.tpb.lab.eng.brq.redhat.com [10.43.134.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71D5187A1; Tue, 20 Aug 2019 14:25:40 +0000 (UTC) Date: Tue, 20 Aug 2019 16:25:37 +0200 From: Miroslav Lichvar To: Hubert Feurstein Cc: netdev , lkml , Andrew Lunn , Richard Cochran , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , "David S. Miller" Subject: Re: [PATCH net-next v3 2/4] net: mdio: add PTP offset compensation to mdiobus_write_sts Message-ID: <20190820142537.GL891@localhost> References: <20190820084833.6019-1-hubert.feurstein@vahle.at> <20190820084833.6019-3-hubert.feurstein@vahle.at> <20190820094903.GI891@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.71]); Tue, 20 Aug 2019 14:25:42 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 20, 2019 at 02:29:27PM +0200, Hubert Feurstein wrote: > Am Di., 20. Aug. 2019 um 11:49 Uhr schrieb Miroslav Lichvar > > This is important to not break the estimation of maximum error in the > > measured offset. Applications using the ioctl may assume that the > > maximum error is (post_ts-pre_ts)/2 (i.e. half of the delay printed by > > phc2sys). That would not work if the delay could be occasionally 50 > > microseconds for instance, i.e. the post_ts timestamp would be earlier > > than the PHC timestamp. > > > If the timestamps are taken in the MDIO driver (imx-fec in my case), then > everything is quite deterministic (see results in the cover letter). Of course, > it still can be improved slightly, by splitting up the writel into iowmb and > write_relaxed and disable the interrupts while capturing the timestamps > (as I did in my original RFC patch). But phc2sys takes by default 5 measurements > and uses the one with the smallest delay, so this shouldn't be necessary. The delay that phc2sys sees is the difference between post_ts and pre_ts, which doesn't contain the actual delay, right? So, I'm not sure how well the phc2sys filtering actually works. Even if the measured delay was related to the write delay, would be 5 measurements always enough to get a "correct" sample? > Although, by adding 2 * ptp_sts_offset the system timestamp to post_ts > the timestamp is aligned with the PHC timestamp, but this also increases > the delay which is reported by phc2sys (~26us). But the maximum error > which must be expected is definitely much less (< 1us). So maybe it is better > to shift both timestamps pre_ts and post_ts by ptp_sts_offset. If you could guarantee that [pre_ts + ptp_sts_offset, post_ts + ptp_sts_offset] always contains the PHC timestamps, then that would be great. From what Andrew is writing, this doesn't seem to be the case. I'd suggest a different approach: - specify a minimum delay for the write and a minimum delay for the completion (if they are not equal) - take a second "post" system timestamp after the completion - adjust pre_ts and post_ts so that the middle point is equal to what you have now, but the interval contains both pre_ts + min_write_delay and post2_ts - min_completion_delay This way you get the best stability and also a delay that correctly estimates the maximum error. -- Miroslav Lichvar