Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp10110630ybl; Thu, 26 Dec 2019 11:02:08 -0800 (PST) X-Google-Smtp-Source: APXvYqyaCvKNCroyuWrulFC60wmZg7tVZo1gP+00RuwTfapF+Z4Votu/BbxmhVjDsue37bq8CxTo X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr52801733otd.91.1577386928261; Thu, 26 Dec 2019 11:02:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577386928; cv=none; d=google.com; s=arc-20160816; b=KGvswXEiuWMmpY7Nk1OW8/6CiyUm9nWZLpbKvFYCbvkyzWNYzdVmk0xZOGVV8533B8 aYHiej6ZULPPSvIZtw66uwl6WjfmERLolimuZa9NgmEijg2KC59EuScFbnObCckZGtBe eED5WJp8ZAOd39e1/sTB/qINvupgLynErejH/3HStigLEx6vCv0NAeK4dwRXJTKzPMg3 LB3mkl7yPWXZow9voYorY91IVnCoZoxtD4H2I1cWwskOW2oCcLorH06KEJJ4Hm7dji4N TZ2WAViwtPl5xQhnVZSzd32lqaQU2TufgAmxThzHg9CNwiIEU/sUJ3+5SrXmhQSS6bfH IvRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G3rTKkxQ4jW7k/v9aR/psmRAwE+gN+ZcbP3Syw4+shY=; b=ilAtxCerotFut+5cFalCf5+2D5uNT3xDVw+dVnr3ET1v+dFpCyrJaxQ9fD6JG4Jnp9 8FP2SXyBuQVkhm6vqOn4Ok8UbrBRpzTFlnii6NuawY2ZNRqb9Jp789LqQSyMDoC2L/zU Cn588dWqnI74Sw0Opkoq7hWAuc951mAcbcLV0aJaSY05mNTlgRPta4XDNgv3fRqt5tnD +9ujSVQpIl1Q7xV7vRYs+PgpLtVZYioRz9bEL55gDJsoICCznsyfajABq4sazpVac0F8 k061cxa2smLxSFhnlcVdpvSWBOVfZs+xzFpm1dBVL/G6T2cSlJWjduYDjUKp0YubENDe omZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=mELOjX4S; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si15893498otp.147.2019.12.26.11.01.57; Thu, 26 Dec 2019 11:02:08 -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=pass header.i=@googlemail.com header.s=20161025 header.b=mELOjX4S; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbfLZTBS (ORCPT + 99 others); Thu, 26 Dec 2019 14:01:18 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33362 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726752AbfLZTBQ (ORCPT ); Thu, 26 Dec 2019 14:01:16 -0500 Received: by mail-wm1-f65.google.com with SMTP id d139so5551332wmd.0; Thu, 26 Dec 2019 11:01:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G3rTKkxQ4jW7k/v9aR/psmRAwE+gN+ZcbP3Syw4+shY=; b=mELOjX4SoFXM8AIHXZRIeFnnO9Y9LgnWsu0GIsFn/9o3LYHSDm34OAyN54M0CIE976 g6x4Mv7Z1xm/KtdgWm+DtHlMDMtdcBlKd8JzOVuyRJn/nTmxS5qnmqGrDdkhnYx1iqqT uJeydm1jD+sPIvsAb+IjfYPHOX2Etf2GNbfnuSDMPe6zafIuuvhnTwraW6BBmTsQfNbi aUsNny/3WM2NxfQoZuH/JjU8imbxePoXVI+IQvqq5QRlm7W+dwQTtx4g4aLVfhqHKnDm M47QUxht+pMbSs35w9DCmZk2F8XJb2CgZaHESFNfgq/tCg2TagCC2tYhLPANuDqrJrnG SPhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G3rTKkxQ4jW7k/v9aR/psmRAwE+gN+ZcbP3Syw4+shY=; b=GvMNkQvew8/PuFn3XFd+/rHkZpTMj326x49lzDMSV7tvjsRLNb7cCVZuHVrK5i2xXt qqfX0DRvmu5vDUDAmfjOJWTS2ZyyVCoPGby0b6qv/p5ay0y/pCk94QJtKCFZH7SrUpAw 6nmSc7t5zdPKt+ZzRchJA/ImwSdnrz/Y5rpDl7tQ21dBqK/JKDGcSot3hsMLsZyxJb1p 26nxxs/6RtR2g4FSXqH3izL6jiBAo5BG/Vd2AbPMfavb4cczUsaRX8ulxIpwmXUtzBMa CJyDJEKM/mnPhtehEcL0IPVlzf3ih2yxs0iEIK3oU8IvkkV6O/lyOIYrAMjuNGv3jbYe Aycg== X-Gm-Message-State: APjAAAXGvFsbfWJZu4ksZOTqtcKmYN5ZVU6+CnGAC0gxzHqDzhl9aj/c BtR3Mo9SUI011dEOmWHG5gE= X-Received: by 2002:a7b:c392:: with SMTP id s18mr15862281wmj.169.1577386874993; Thu, 26 Dec 2019 11:01:14 -0800 (PST) Received: from localhost.localdomain (p200300F1373A1900428D5CFFFEB99DB8.dip0.t-ipconnect.de. [2003:f1:373a:1900:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id u18sm31777854wrt.26.2019.12.26.11.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Dec 2019 11:01:14 -0800 (PST) From: Martin Blumenstingl To: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, netdev@vger.kernel.org, linux-amlogic@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Martin Blumenstingl Subject: [PATCH v2 1/1] net: stmmac: dwmac-meson8b: Fix the RGMII TX delay on Meson8b/8m2 SoCs Date: Thu, 26 Dec 2019 20:01:01 +0100 Message-Id: <20191226190101.3766479-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191226190101.3766479-1-martin.blumenstingl@googlemail.com> References: <20191226190101.3766479-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 (the vendor kernel uses the same settings): - MPLL2 clock set to ~500MHz - m250_div set to 2 - TX delay set to 2ns on the MAC side Update the m250_div divider settings to only accept dividers greater or equal 2 to fix the TX delay generated by the MAC. iperf3 results before the change: [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.00 sec 182 MBytes 153 Mbits/sec 514 sender [ 5] 0.00-10.00 sec 182 MBytes 152 Mbits/sec receiver iperf3 results after the change (including an updated TX delay of 2ns): [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-10.00 sec 927 MBytes 778 Mbits/sec 0 sender [ 5] 0.00-10.01 sec 927 MBytes 777 Mbits/sec receiver Fixes: 4f6a71b84e1afd ("net: stmmac: dwmac-meson8b: fix internal RGMII clock configuration") Signed-off-by: Martin Blumenstingl --- .../net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c index bd6c01004913..0e2fa14f1423 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c @@ -112,6 +112,14 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac) struct device *dev = dwmac->dev; const char *parent_name, *mux_parent_names[MUX_CLK_NUM_PARENTS]; struct meson8b_dwmac_clk_configs *clk_configs; + static const struct clk_div_table div_table[] = { + { .div = 2, .val = 2, }, + { .div = 3, .val = 3, }, + { .div = 4, .val = 4, }, + { .div = 5, .val = 5, }, + { .div = 6, .val = 6, }, + { .div = 7, .val = 7, }, + }; clk_configs = devm_kzalloc(dev, sizeof(*clk_configs), GFP_KERNEL); if (!clk_configs) @@ -146,9 +154,9 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac) clk_configs->m250_div.reg = dwmac->regs + PRG_ETH0; clk_configs->m250_div.shift = PRG_ETH0_CLK_M250_DIV_SHIFT; clk_configs->m250_div.width = PRG_ETH0_CLK_M250_DIV_WIDTH; - clk_configs->m250_div.flags = CLK_DIVIDER_ONE_BASED | - CLK_DIVIDER_ALLOW_ZERO | - CLK_DIVIDER_ROUND_CLOSEST; + clk_configs->m250_div.table = div_table; + clk_configs->m250_div.flags = CLK_DIVIDER_ALLOW_ZERO | + CLK_DIVIDER_ROUND_CLOSEST; clk = meson8b_dwmac_register_clk(dwmac, "m250_div", &parent_name, 1, &clk_divider_ops, &clk_configs->m250_div.hw); -- 2.24.1