Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp641973ybl; Wed, 21 Aug 2019 03:21:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvXnKYkey6HOqoEorJ6n+ZXZRcJmpru7Nh12ZuilKB+8tU5fpoD9BuC7NLioDAX5Tx6M8V X-Received: by 2002:a17:902:26f:: with SMTP id 102mr3374583plc.189.1566382907016; Wed, 21 Aug 2019 03:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566382907; cv=none; d=google.com; s=arc-20160816; b=xGrNpajNb8Zhiw4uNQgZxx9jfctAhKG7Yp7VFgRy46l6OWl7yy3u3TnPw4rxxiiBdn J6nxD01uGRXAM/36nXcfwZDwDiDv51l7Bf0E8TyuZ/e/w7pG/7j7ZA92BKAHDl/R8hx0 ie7zpqoFx80KNsGw54yzMC0c+F2PIfQwPUkN69gGDrPX2UTuaWp7QAIzCgNqSLH4VcR4 srcqcoHi2c1+hdUlw32uOw0iXjaqIuP7fRJrh7SrxjZg2YQQsZzkKKRVc7oaKqQckXfz +n/BReKZzRlT+SHq7OqdrBF5RNljlOH4yzWf2XhzcwMm4waB62T5JRlEqxLDtnTVL2n6 Fpvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0j0aLbF37mxr0p4tOgL1Wqo0ymRU6Jzah6uHZ9y7XhA=; b=cy33dogekPR1DGOUJEP/ft2EtK3z7SSdGBZnKdTRn5TSPHpjehoJZw+8Qe5S/H2Drc w+o5IPKuG+wh7eqzJD+tLwXLfF8PWccUkxvGDgWfWjOKOtmG5y414Z3uxQ6vzSsu3OJe ZN6USUjn7LIuoAbfONo6jfbjpacgpok6Qz04ACcJParZFeSRRBiuU9pDWQ9gSOsi6Mcu DVH6FZ6l46RUCxzQXG9RgHppo1zuhPEBiNEhULYM4icjPrzYK0vIO6CuodqR+pGbQ0Qj I5CSoJ/RVh+ecYDqqxZTirbeUM3TxZfRwiUgksKgtolh3pKTiX4fvJ84Bla1PVdxw56Y WP4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=by0zxMIC; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66si14491943plc.428.2019.08.21.03.21.32; Wed, 21 Aug 2019 03:21:47 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=by0zxMIC; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727882AbfHUKTZ (ORCPT + 99 others); Wed, 21 Aug 2019 06:19:25 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:42228 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfHUKTY (ORCPT ); Wed, 21 Aug 2019 06:19:24 -0400 Received: by mail-ed1-f68.google.com with SMTP id m44so2288010edd.9; Wed, 21 Aug 2019 03:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0j0aLbF37mxr0p4tOgL1Wqo0ymRU6Jzah6uHZ9y7XhA=; b=by0zxMIC8CA0LYBrVXAyJ1cpW9JX3DO0Io4PD9hXj3gKSJI6/JK38qOq4Wc5uIpI4F aAgc9zM64oy87SzjcASlQF0aBmd5J/xm01U6Rd0S9w1oOC6Tj/tGI6ufoj21FoW0q1Wj +bA5mro6vmQnjSZgTOwVh3mXMUi92BFvLtnPc5WvnTePqF1JF7tcViUCiMbQlDhu90F2 hRleiL/zdAwtlkRzJKrxYIBMC7utuCUzh56xKfgKxE/3zUZ6DYO4skiLfIB9qyJ/Q4Nf 78oLrZfKIesSuhWj1dxbfkIwBLAIIApOZIB+6GDPlFFV9icfy/GrvwJdYhvIcurTY5so HH+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0j0aLbF37mxr0p4tOgL1Wqo0ymRU6Jzah6uHZ9y7XhA=; b=pT4h5LGQNm2gR8hzIVI6VEQGol72ZQa7r35jVphf1syRqrwyz/NT2YfzHNcSCGYlVr SY4btxt7kyu3vGQO4qkzXzjtw2jRTLf2Id+9WUgTJahzBDr2OpzlclTD+6eHFyHzJv+I qrLh3QcW5Fud50tpLmSGHKXcyM7d+oblNIvwG/9TUawV3plhk22Y3/YXPNJi0q0re2eV f9ncbwSVrqfrcIWRYfB/EYXhJzKvvDCSwp2cMdevZgcej9eRWgkWVlx+dbInC7IFL+1p qxXdly2bYuM4mJ1hW3DZ898U2GUUt8TKjb0aoTZMn2zbHvs1tnJ/KWlEpRGsc0QH7SD0 lK8g== X-Gm-Message-State: APjAAAUGaRFxmsXjhe5Q1q1dU97eK/qxcBKytIwidM35qwNlMfoQE22z QqCPLbKsQTEAAf/iqUhzc3lD3Wsl9axK0AeYK00= X-Received: by 2002:a17:906:1484:: with SMTP id x4mr2757504ejc.204.1566382762303; Wed, 21 Aug 2019 03:19:22 -0700 (PDT) MIME-Version: 1.0 References: <20190820084833.6019-1-hubert.feurstein@vahle.at> <20190820084833.6019-3-hubert.feurstein@vahle.at> <20190820094903.GI891@localhost> <20190820142537.GL891@localhost> <20190820152306.GJ29991@lunn.ch> <20190820154005.GM891@localhost> <20190821080709.GO891@localhost> In-Reply-To: From: Vladimir Oltean Date: Wed, 21 Aug 2019 13:19:11 +0300 Message-ID: Subject: Re: [PATCH net-next v3 2/4] net: mdio: add PTP offset compensation to mdiobus_write_sts To: Hubert Feurstein Cc: Miroslav Lichvar , Andrew Lunn , netdev , lkml , Richard Cochran , Florian Fainelli , Heiner Kallweit , "David S. Miller" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 21 Aug 2019 at 12:53, Hubert Feurstein wrote: > > Am Mi., 21. Aug. 2019 um 10:07 Uhr schrieb Miroslav Lichvar > : > > > Currently I do not see the benefit from this. The original intention was to > > > compensate for the remaining offset as good as possible. > > > > That's ok, but IMHO the change should not break the assumptions of > > existing application and users. > > > > > The current code > > > of phc2sys uses the delay only for the filtering of the measurement record > > > with the shortest delay and for reporting and statistics. Why not simple shift > > > the timestamps with the offset to the point where we expect the PHC timestamp > > > to be captured, and we have a very good result compared to where we came > > > from. > > > > Because those reports/statistics are important in calculation of > > maximum error. If someone had a requirement for a clock to be accurate > > to 1.5 microseconds and the ioctl returned a delay indicating a > > sufficient accuracy when in reality it could be worse, that would be a > > problem. > > > Ok, I understand your point. But including the MDIO completion into > delay calculation > will indicate a much wore precision as it actually is. When the MDIO > driver implements > the PTP system timestamping as follows ... > > ptp_read_system_prets(bus->ptp_sts); > writel(value, mdio-reg) > ptp_read_system_postts(bus->ptp_sts); > > ... then we catch already the error caused by interrupts which hit the > pre/post_ts section. > Now we only have the additional error of one MDIO clock cycle > (~400ns). Because I expect > the MDIO controller to shift out the MDIO frame on the next MDIO clock > cycle. So if I subtract How do you know? The MDIO controller is a memory-mapped peripheral so there will be a transaction on the core <-> peripheral interconnect in the SoC. Depending on the system load, the transaction might not be instantaneous as you think. Additionally there will be clock domain crossings in the MDIO controller when transferring the command from the platform clock to the peripheral clock, which might also add some jitter. MDIO frames may also begin with 32 bits of preamble, with some controllers being able to suppress it. Have you checked/accounted for this? The only reliable moment when you know the MDIO command has completed is when the controller says it has. If there is additional jitter in waiting for the completion event caused by the GIC and the scheduling of the ISR, then just switch the driver to poll mode, like everybody else. > one MDIO clock cycle from pre_ts and add one MDIO clock cycle to > post_ts the error indication > would be sufficiently corrected IMHO. And then we can shift both > timestamps in the switch driver > (in the gettimex handler) to compensate the switch depending offset. > What do you think? > > Hubert Regards, -Vladimir