Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2066857rwb; Thu, 27 Jul 2023 01:13:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlE1rACayVndn/bahEJEFhPQwhvKhjnte8C5gjlh1RmFSl5h0X+Xn/CGxD1I2J5SpXnJ3Rvd X-Received: by 2002:aa7:cf01:0:b0:51d:8f9b:b6ce with SMTP id a1-20020aa7cf01000000b0051d8f9bb6cemr1218882edy.1.1690445591227; Thu, 27 Jul 2023 01:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690445591; cv=none; d=google.com; s=arc-20160816; b=XZ/BsDPmvyhMZoqTmJffr7z1DCLjRDkEXAQar84OxzPD9T3oUpRAPxjrp5PNmiYHaO NM6Jd20CuxKmv4avU4FiRv1/Qp0Civ/1Vy0pllm2iUfNtMYpyss2E3drEVzvb6E7ffCk ik7TmboXQCkUIsscTew+txjNSiwMEH/5iXceDFlojaHUf0hLVj/9lt7RVFIWYA0HDo2F uA2lm93WEKcjcBsX2ozhF5i0lRU/7LQ5GDQBK9Jev6iLO4jP5iFwFn27I6k+54YLCN6R r5yUY6jQuC1HdWiWWGxzMRLBMqQG3qc6u1lTCPHK1Q4mJVBAxPixMfugheG2JnVOsnqg r/UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=HjMmryv/E+pE1StZ8CVn/dpAC7Xxm74hTHOGroyI9gQ=; fh=Eax5s2Hpvo9Z8QzkxmTm/e/rGEKscET66iMhiOPCFyg=; b=c7k3YCqUueNZjlVj3KxQAUiQHqGvdIQJE3iz20Od3d7MXH9eBzml5GgZAMNVMVXMdi 75rTHW5Mo2XgVJMzDnYPNtYoRYrSlQU3tNq57rmIj0HAqWcBKJ7BhpcnM9OwAyLtEBA4 kRJv6J94OOdhPGgFUWk2Rc5IVm6qNs+q9hg3Lk1E9ajboVOyMazR19rrCQV4SBNSosl7 q46gILSrLd2Pn7YxVPE7MCMAjDB/2UkEFqEM1CHnbbsrTgy5r5OIcxUQx0rrZ0CWeAde dhR307dmV5RIZbjqRx1F1ZHXUxpJFhf1KHpV4ul7hZOH6nkSw4gjrV6fF/QUQ3e5LVQV 6t0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a056402180500b00522314454ffsi574323edy.599.2023.07.27.01.12.46; Thu, 27 Jul 2023 01:13:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232141AbjG0HcK (ORCPT + 99 others); Thu, 27 Jul 2023 03:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231883AbjG0Hbq (ORCPT ); Thu, 27 Jul 2023 03:31:46 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C993F2D60 for ; Thu, 27 Jul 2023 00:20:31 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1qOvIF-0000DH-VE; Thu, 27 Jul 2023 09:20:16 +0200 Message-ID: <729dd79e-83aa-0237-1edd-1662a6ae28cd@pengutronix.de> Date: Thu, 27 Jul 2023 09:20:10 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] net: stmmac: correct MAC propagation delay Content-Language: en-US, de-DE To: Richard Cochran Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Russell King , patchwork-jzi@pengutronix.de, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, kernel test robot References: <20230719-stmmac_correct_mac_delay-v2-1-3366f38ee9a6@pengutronix.de> From: Johannes Zink In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: j.zink@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Richard, On 7/26/23 22:57, Richard Cochran wrote: > On Mon, Jul 24, 2023 at 12:01:31PM +0200, Johannes Zink wrote: > > Earlier versions of the IP core return zero from these... > >> +#define PTP_TS_INGR_LAT 0x68 /* MAC internal Ingress Latency */ >> +#define PTP_TS_EGR_LAT 0x6c /* MAC internal Egress Latency */ > good catch. Gonna send a v3 with a check to and set the values for dwmac v5 only. Best regards Johannes > and so... > >> +static void correct_latency(struct stmmac_priv *priv) >> +{ >> + void __iomem *ioaddr = priv->ptpaddr; >> + u32 reg_tsic, reg_tsicsns; >> + u32 reg_tsec, reg_tsecsns; >> + u64 scaled_ns; >> + u32 val; >> + >> + /* MAC-internal ingress latency */ >> + scaled_ns = readl(ioaddr + PTP_TS_INGR_LAT); >> + >> + /* See section 11.7.2.5.3.1 "Ingress Correction" on page 4001 of >> + * i.MX8MP Applications Processor Reference Manual Rev. 1, 06/2021 >> + */ >> + val = readl(ioaddr + PTP_TCR); >> + if (val & PTP_TCR_TSCTRLSSR) >> + /* nanoseconds field is in decimal format with granularity of 1ns/bit */ >> + scaled_ns = ((u64)NSEC_PER_SEC << 16) - scaled_ns; >> + else >> + /* nanoseconds field is in binary format with granularity of ~0.466ns/bit */ >> + scaled_ns = ((1ULL << 31) << 16) - >> + DIV_U64_ROUND_CLOSEST(scaled_ns * PSEC_PER_NSEC, 466U); >> + >> + reg_tsic = scaled_ns >> 16; >> + reg_tsicsns = scaled_ns & 0xff00; >> + >> + /* set bit 31 for 2's compliment */ >> + reg_tsic |= BIT(31); >> + >> + writel(reg_tsic, ioaddr + PTP_TS_INGR_CORR_NS); > > here reg_tsic = 0x80000000 for a correction of -2.15 seconds! > > @Jakub Can you please revert this patch? > > Thanks, > Richard > > -- Pengutronix e.K. | Johannes Zink | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686| Fax: +49-5121-206917-5555 |