Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8826215ybl; Wed, 25 Dec 2019 07:09:56 -0800 (PST) X-Google-Smtp-Source: APXvYqzy3yN9w2B++gnUPBfmaoTSYQap7dyf9TvmFFHlPEZvdMBO0eSdQ9F17pJ0mySP/tQqDv2u X-Received: by 2002:a9d:75da:: with SMTP id c26mr45328280otl.40.1577286596694; Wed, 25 Dec 2019 07:09:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577286596; cv=none; d=google.com; s=arc-20160816; b=r5rTwg3m9yVOiBz07eW1MCFy0fojJ7PhRV5GJFopER7AyiN+HWbic4w8K2r64ARo+Y zcQZfIhbwEM7+tNkwz1k0ENtZRCKWuqJ6GMex1+SlWwzS7jzh8oM73HopxhtkLX6bxkB J7ZDqYPPJfdl9BC/IDo3wBRcGPYRTew2t8GFyNj/9VkDXPCC5VMopVGTx1167/F13Ato fb1tZKseAwx0iIl2WOwr5B5XVwEWtP5UC9/9rhV+UZvDLuhZaWQPKHjmh2/uoMtltl/d BhadtpgCToKMhOsQfNJSDoJ3YhHgi8CQbz2CHB63/lVZZvPI47WQEtUAWzDiX4o0KCLM cnug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jQM1mPv2ronZJbcInLqrwGfsm7Z5m5AylYfzZgE2JXA=; b=Nix6IvM3DuZ/zfCDEWDrWceGYFWf6lIXiWoToyyg03z5Qvl7HgO7gPGu8VM/QT+dGi Sqans1sw+Ft3G2nqAh/WNRVftznNjPC+VJA3HNLY7T9L2o1oGitvCNc7ogzuMZ3mf+0Z Gcts951IBXpA7UBFXD9Il4ACcSo0y2wU+bzx6FoionYPv4S8U/WSzZnpyfNoSk+ZCiKL RPJk26ns+AHhI+Jp7b9tmQREuZIVk6+t9i80h5DJPfs1HZWP/ylIetFYuMH4RA8Fu3+S zKi+veL+W9OvDeGTQtXq5V+U+U91VC9N+9fmQzvMhhCOXakdA+qIvpPuXWm26sa8Fbuv i/+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@lunn.ch header.s=20171124 header.b=zTEfMuOo; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si12504779oic.19.2019.12.25.07.09.42; Wed, 25 Dec 2019 07:09:56 -0800 (PST) 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=fail header.i=@lunn.ch header.s=20171124 header.b=zTEfMuOo; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726516AbfLYPI6 (ORCPT + 99 others); Wed, 25 Dec 2019 10:08:58 -0500 Received: from vps0.lunn.ch ([185.16.172.187]:39902 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726353AbfLYPI6 (ORCPT ); Wed, 25 Dec 2019 10:08:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jQM1mPv2ronZJbcInLqrwGfsm7Z5m5AylYfzZgE2JXA=; b=zTEfMuOoUE9MwHB3sP2D4Xd29U B+ejTbVH8L+m+Y7bydqkF8Dm/oDIF0kTrd+TKU5JrmBdJkTJbF1cPtIa5qlI4XdJcYZcJR2eZKCfI NTTb5UzoFmrjvo0NuqfqIaHH1JhkSOviMTwD8hDle1tN/hewSV9OhQeSRTHZtCZwz6aw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.93) (envelope-from ) id 1ik8HF-0004Zd-42; Wed, 25 Dec 2019 16:08:45 +0100 Date: Wed, 25 Dec 2019 16:08:45 +0100 From: Andrew Lunn To: Martin Blumenstingl Cc: linux-amlogic@lists.infradead.org, netdev@vger.kernel.org, davem@davemloft.net, khilman@baylibre.com, linus.luessing@c0d3.blue, balbes-150@yandex.ru, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, ingrassia@epigenesys.com, jbrunet@baylibre.com Subject: Re: [PATCH 1/3] net: stmmac: dwmac-meson8b: Fix the RGMII TX delay on Meson8b/8m2 SoCs Message-ID: <20191225150845.GA16671@lunn.ch> References: <20191225005655.1502037-1-martin.blumenstingl@googlemail.com> <20191225005655.1502037-2-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191225005655.1502037-2-martin.blumenstingl@googlemail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 25, 2019 at 01:56:53AM +0100, Martin Blumenstingl wrote: > GXBB and newer SoCs use the fixed FCLK_DIV2 (1GHz) clock as input for > the m250_sel clock. Meson8b and Meson8m2 use MPLL2 instead, whose rate > can be adjusted at runtime. > > So far we have been running MPLL2 with ~250MHz (and the internal > m250_div with value 1), which worked enough that we could transfer data > with an TX delay of 4ns. Unfortunately there is high packet loss with > an RGMII PHY when transferring data (receiving data works fine though). > Odroid-C1's u-boot is running with a TX delay of only 2ns as well as > the internal m250_div set to 2 - no lost (TX) packets can be observed > with that setting in u-boot. > > Manual testing has shown that the TX packet loss goes away when using > the following settings in Linux: > - MPLL2 clock set to ~500MHz > - m250_div set to 2 > - TX delay set to 2ns Hi Martin The delay will depend on the PHY, the value of phy-mode, and the PCB layout. https://ethernetfmc.com/rgmii-interface-timing-considerations/ RGMII requires a delay of 2ns between the data and the clock signal. There are at least three ways this can happen. 1) The MAC adds the delay 2) The PCB adds the delay by making the clock line longer than the data line. 3) The PHY adds the delay. In linux you configure this using the phy-mode in DT. # RX and TX delays are added by the MAC when required - rgmii # RGMII with internal RX and TX delays provided by the PHY, # the MAC should not add the RX or TX delays in this case - rgmii-id # RGMII with internal RX delay provided by the PHY, the MAC # should not add an RX delay in this case - rgmii-rxid # RGMII with internal TX delay provided by the PHY, the MAC # should not add an TX delay in this case - rgmii-txid So ideally, you want the MAC to add no delay at all, and then use the correct phy-mode so the PHY adds the correct delay. This gives you the most flexibility in terms of PHY and PCB design. This does however require that the PHY implements the delay, which not all do. Looking at patches 2 and 3, the phy-mode is set to rgmii. What you might actually need to do is set this to rgmii-txid, or maybe rgmii-id, once you have the MAC not inserting any delay. With MAC/PHY issues, it is a good idea to Cc: the PHY maintainers. Andrew