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 X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 D4638C433FF for ; Mon, 5 Aug 2019 10:36:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B261220856 for ; Mon, 5 Aug 2019 10:36:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728388AbfHEKg4 (ORCPT ); Mon, 5 Aug 2019 06:36:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727328AbfHEKg4 (ORCPT ); Mon, 5 Aug 2019 06:36:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7C2F33084025; Mon, 5 Aug 2019 10:36:55 +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 9C22760603; Mon, 5 Aug 2019 10:36:53 +0000 (UTC) Date: Mon, 5 Aug 2019 12:36:52 +0200 From: Miroslav Lichvar To: Vladimir Oltean Cc: Hubert Feurstein , Richard Cochran , Andrew Lunn , netdev , lkml , Vivien Didelot , Florian Fainelli , "David S. Miller" Subject: Re: [RFC] net: dsa: mv88e6xxx: ptp: improve phc2sys precision for mv88e6xxx switch in combination with imx6-fec Message-ID: <20190805103652.GA16411@localhost> References: <20190802163248.11152-1-h.feurstein@gmail.com> 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 05 Aug 2019 10:36:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 05, 2019 at 12:54:49PM +0300, Vladimir Oltean wrote: > - Along the lines of the above, I wonder how badly would the > maintainers shout at the proposal of adding a struct > ptp_system_timestamp pointer and its associated lock in struct device. > That way at least you don't have to change the API, like you did with > mdiobus_write_nested_ptp. Relatively speaking, this is the least > amount of intrusion (although, again, far from beautiful). That would make sense to me, if there are other drivers that could use it. > I also added Miroslav Lichvar, who originally created the > PTP_SYS_OFFSET_EXTENDED ioctl, maybe he can share some ideas on how it > is best served. The idea behind that ioctl was to allow drivers to take the system timestamps as close to the reading of the HW clock as possible, excluding delays (and jitter) due to other operations that are necessary to get that timestamp. In the ethernet drivers that was a single PCI read. If in this case it's a "write" operation that triggers the reading of the HW clock, then I think the patch is using is the ptp_read_system_*ts() calls correctly. > > --- a/drivers/net/ethernet/freescale/fec_main.c > > +++ b/drivers/net/ethernet/freescale/fec_main.c > > @@ -1814,11 +1814,25 @@ static int fec_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum, > > > > reinit_completion(&fep->mdio_done); > > > > - /* start a write op */ > > - writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE | > > - FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | > > - FEC_MMFR_TA | FEC_MMFR_DATA(value), > > - fep->hwp + FEC_MII_DATA); > > + if (bus->ptp_sts) { > > + unsigned long flags = 0; > > + local_irq_save(flags); > > + __iowmb(); > > + /* >Take the timestamp *after* the memory barrier */ > > + ptp_read_system_prets(bus->ptp_sts); > > + writel_relaxed(FEC_MMFR_ST | FEC_MMFR_OP_WRITE | > > + FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | > > + FEC_MMFR_TA | FEC_MMFR_DATA(value), > > + fep->hwp + FEC_MII_DATA); > > + ptp_read_system_postts(bus->ptp_sts); > > + local_irq_restore(flags); > > + } else { > > + /* start a write op */ > > + writel(FEC_MMFR_ST | FEC_MMFR_OP_WRITE | > > + FEC_MMFR_PA(mii_id) | FEC_MMFR_RA(regnum) | > > + FEC_MMFR_TA | FEC_MMFR_DATA(value), > > + fep->hwp + FEC_MII_DATA); > > + } -- Miroslav Lichvar