Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8185209ybl; Tue, 24 Dec 2019 16:58:53 -0800 (PST) X-Google-Smtp-Source: APXvYqw68HDsXKJ+1IoARxdRYDbj5DqLHSQ/eaT5rUrChLHfBjSEk5zvi86eGxj4pxY5XXK14TcI X-Received: by 2002:aca:ad11:: with SMTP id w17mr1412492oie.85.1577235532878; Tue, 24 Dec 2019 16:58:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577235532; cv=none; d=google.com; s=arc-20160816; b=byH6xVfobzZyYnE79+fiBCwMxixn4Fe6WiGYRB6C/t7+guvtlU30sRyUxN+bmK3zfM qDx26m6WV5y9fnSb1AYnxG5N57GODPs2wNt+nnwhaBSOFsqHApunDYIesbO3pODhVHzO MIUQrH4s3KaUn4TIM6Ajhmr/o7g5o65KeQFAjafqkoew7AvIe5jESmA+ahdPC+d1of2i y94DmTSXusT0/vb9lXaQ9wKQgJb/rKOM+gi83D2mmZEvUicO0tHxH3M0703RYr+VEHBz 62q9J6ryWqeibfWSPdI9t7rsiQ4JW0N3L8QfSaPN+oxTyJu4qMDEtAtY5ZEd1e5TJkza Yb6Q== 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=6qx3JuRWucxWSZ+edEqkzvKfjwC/qHMJGDM4MA7mRVg=; b=fJnLDR5UAnnuCCENU1yaoJTWNeUMaPELG5EoyKkslNCjpuEHcg3PwADPjk6Erz6P7u 3jTwRKgqEwJlkFAu5wSPx1iXFcbHdnqIxOwwJ+WzCLH54/BRQrTdYSiePTACH67qGeY9 jJdg+QBoV4I9Yd8zPer7TjADhgHrXDOOtYJPtQPCTiEjI3/6oapkXgxjoj2ZDPGoPUEe Sl2zQf3u44r2t3CMMkb0Bn8SMhJe77ymuxlbMySu4etXXxnKBAT9xX5U/jSv8+sLInz7 rs3OZSC/WrhtLBDDSulJcPLzhpzv/vnwGuJdPdjNqkHvyfdNAMYMdbheGHgkZhX6TnGD ixaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@googlemail.com header.s=20161025 header.b=WAwEyf9Z; 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 24si11810437oip.248.2019.12.24.16.58.40; Tue, 24 Dec 2019 16:58:52 -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=WAwEyf9Z; 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 S1726879AbfLYA55 (ORCPT + 99 others); Tue, 24 Dec 2019 19:57:57 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40261 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbfLYA54 (ORCPT ); Tue, 24 Dec 2019 19:57:56 -0500 Received: by mail-wm1-f66.google.com with SMTP id t14so3500789wmi.5; Tue, 24 Dec 2019 16:57:55 -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=6qx3JuRWucxWSZ+edEqkzvKfjwC/qHMJGDM4MA7mRVg=; b=WAwEyf9Z6R6RPOxZ66EqNRQZQ/elC7tzeA/mn5bIOlxp8yZz+nS/BxDaKgYaFwfrwf 9b6O3XYC0Z6/4CSU1raIO9xqGyG0UXjUsvZuz6PihpBJc3JyAT76iT76Xxv2PhW+F69E YcBYqaIDmNM3HZZmTC6kLjY9vQng9uwX75RxEuhAKlrNji9btuO8khgsADSUsGWlB08p vSaG//6exaCwKeBBy5q29SFW4ugGU7isTDy0weKFZJ2ZD3TinNdcT22uPYuDz3fjjH2s EpO7/UY1LUXPzIiFg9eku7VkHkUjW4p/bJZX8DogDpQOAYAdMwbZHgKZZz03BQx5YKlu L57g== 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=6qx3JuRWucxWSZ+edEqkzvKfjwC/qHMJGDM4MA7mRVg=; b=WNtrRoVAAW8HgUxR6ko5mMGyEyuNfn12/+n+B/HjZMMLthMKr8XWBAey102Adhm/4z 22Zc32q0vSiOzYaZQvhT8byD2Vv+xcHV0Y5QqAwV1peU561ZlJmY7Hbvu8fjhfXsh+v9 3VI6Yf+a/W7AilK/QUXdy1ZjIaFrHNthJzCpq4UZ5HAoxM9GyKms5oF7qQCdVtaeC8j7 NT7LkISQmCJk3g4bdMvHOwze8f0pE5f0PAmG4oPcC/+AKRBLmM38MkKdIJu69Su+X+7z u8+1pCaMQ4CgVjDqeUdvzebPRT74Z/Evmmf8NImyrTxmkQKd/itCBQpW4JUCAhIlz2qv 3g4g== X-Gm-Message-State: APjAAAUz2wtgu21ojdsrlu/aoRTXYodjJUBulrCfMSpiaDikEeTX/XPc atlrOVA9Oovq028N5SxYrCI= X-Received: by 2002:a7b:c957:: with SMTP id i23mr6473304wml.49.1577235474370; Tue, 24 Dec 2019 16:57:54 -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 e18sm26034448wrw.70.2019.12.24.16.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2019 16:57:53 -0800 (PST) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, netdev@vger.kernel.org, davem@davemloft.net, khilman@baylibre.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, balbes-150@yandex.ru, ingrassia@epigenesys.com, jbrunet@baylibre.com, linus.luessing@c0d3.blue, Martin Blumenstingl Subject: [PATCH 1/3] net: stmmac: dwmac-meson8b: Fix the RGMII TX delay on Meson8b/8m2 SoCs Date: Wed, 25 Dec 2019 01:56:53 +0100 Message-Id: <20191225005655.1502037-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191225005655.1502037-1-martin.blumenstingl@googlemail.com> References: <20191225005655.1502037-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: - MPLL2 clock set to ~500MHz - m250_div set to 2 - TX delay set to 2ns Update the m250_div divider settings to only accept dividers greater or equal 2. This will allow the Meson8 and Meson8m2 .dts to be updated to use a TX delay of 2ns (instead of 4ns) to fix the TX packet loss. 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