From patchwork Thu Nov 3 16:36:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9411213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 928CA601C2 for ; Thu, 3 Nov 2016 16:36:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A11A2ACC9 for ; Thu, 3 Nov 2016 16:36:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CE012AD23; Thu, 3 Nov 2016 16:36:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8D9432AD1F for ; Thu, 3 Nov 2016 16:36:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2L0S-0006JH-Mv; Thu, 03 Nov 2016 16:36:48 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c2L0O-0006HW-JX for linux-amlogic@lists.infradead.org; Thu, 03 Nov 2016 16:36:46 +0000 Received: by mail-wm0-x22a.google.com with SMTP id a197so216648338wmd.0 for ; Thu, 03 Nov 2016 09:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version; bh=byhQXqS9rcEKPboFvFrFkaG8Rn+eK3BeguOujdfxaLA=; b=J4JGxz+RnuG+X2vGCPlsaGMePwCogQKZC2rgJeQveA3pyhSpRlN7KmOLxx9W4tfLPn ToemUwtYQoqqFLz0bXXmARzK91ZqYgFEMyBOO+KOG0dxdn5wbX6h+gB3Kr/U6RZNiUqD EIytkZN8QEXkQtNyM7PNb6bn+2y96j0AQw0OOa1XrjyxEe846fUPTp93P+wgxmtzfGoX nPcd6adSCswSdKAmZc4l3yTxaQjYLSRusrQVNnpGq2xMIC8Ni6fRRmvUCCRAUhhsMkKh pBt3PVB8/DmrKHjUKhT8kwKPBVlP6CYQcLT04YN8kQGZEe/xT1BhmsCYIZ4Sesp/UH7L FU2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version; bh=byhQXqS9rcEKPboFvFrFkaG8Rn+eK3BeguOujdfxaLA=; b=dwiAUwCoPZTmMOx5xkdtdOcaWlqZHPuAvi1GELoFMqeC0Devlbi1FjPZKDBPyxQHZ+ PKkJ95CsgV3fFao349ow+bwlxTgIBKdU1BOrB+yFcsZKzRYwHIgcf2QOwpCYrbH5Tg7T 7mcX58h8Xsmxpyunm72EKsvZWoxMbBBba2D1ExXI3Ah0EEe6fXpbU9Fs15EFGo+aq25V HGL4PhGoPkQSyQxvefcxuTpcf07Kb7TnyTgi5dBsTMDU1wsOhXPXVC54UxN+hGnfFc5U Yz5Gk/Mhz/Kb4MWtBkPXctzgcIvGjl647vmoGfW9gqICC0cP3hX0rn9I9ZQl4dLy3deE Y+bA== X-Gm-Message-State: ABUngverJ0faI+fOgK8jJBgB202NtzwRMpie+3sNYh3LrpA+bxcGiGiVpQyIE95nP0vnlQLP X-Received: by 10.194.134.72 with SMTP id pi8mr8044054wjb.42.1478190981917; Thu, 03 Nov 2016 09:36:21 -0700 (PDT) Received: from boomer ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id 1sm9939665wmk.22.2016.11.03.09.36.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Nov 2016 09:36:21 -0700 (PDT) Message-ID: <1478190980.6632.26.camel@baylibre.com> Subject: Re: stmmac/RTL8211F/Meson GXBB: TX throughput problems From: Jerome Brunet To: Martin Blumenstingl , Giuseppe CAVALLARO Date: Thu, 03 Nov 2016 17:36:20 +0100 In-Reply-To: References: <20160917232312.1e30d425@gmail.com> X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161103_093645_029460_956A03B8 X-CRM114-Status: GOOD ( 31.11 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johnson Leung , netdev@vger.kernel.org, =?ISO-8859-1?Q?Andr=E9?= Roth , Alexandre Torgue , linux-amlogic@lists.infradead.org Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, 2016-10-01 at 17:58 +0200, Martin Blumenstingl wrote: > Hello Peppe, > > On Mon, Sep 26, 2016 at 8:17 AM, Giuseppe CAVALLARO > wrote: > > > > Hello André > > > > On 9/17/2016 11:23 PM, André Roth wrote: > > > > > > > > > > > > Hi all, > > > > > > I have an odroid c2 board which shows this issue. No data is > > > transmitted or received after a moment of intense tx traffic. > > > Copying a > > > 1GB file per scp from the board triggers it repeatedly. > > > > > > The board has a stmmac - user ID: 0x11, Synopsys ID: 0x37. > > > > > > When switching the network to 100Mb/s the copying does > > > not seam to trigger the issue. > > > > > > I've attached the ethtool statistics before and after the > > > problem. > > > > > > at first glance, it enters in EEE mode often in the ethtool.after. > > On some platforms we met problems and it was necessary to disable > > the > > feature. Maybe, you can start looking at if this is true on yours. > > We will see to provide a clean subset of patches to switch-on/off > > it. > I did some hacking in the stmmac driver to disable the LPI stuff (see > the attachment) > > Unfortunately this did not fix the problem. > > I did not issue any ethtool commands not shown in the logs. > Also I did not have time to change the AXI tuning / PBL value yet - > so > those are also untouched. > > I will keep testing, but unfortunately my device is starting to fall > apart (I sometimes have DDR initialization issues and u-boot fails to > come up, oh dear...). Hi all, I did several tests on this issue with amlogic's S905 SoC (Synopsys MAC - user ID: 0x11, Synopsys ID: 0x37.)  With the OdroidC2 (PHY Realtek RTL8211F), EEE is on by default. Just before launching iperf3, here are the ethtool stats regarding LPI:      irq_tx_path_in_lpi_mode_n: 6      irq_tx_path_exit_lpi_mode_n: 5      irq_rx_path_in_lpi_mode_n: 76      irq_rx_path_exit_lpi_mode_n: 75      phy_eee_wakeup_error_n: 0 Sending data with iperf usually works for little while (between 0 and 10s) # iperf3 -c 192.168.1.170 -p12345 Connecting to host 192.168.1.170, port 12345 local 192.168.1.30 port 54450 connected to 192.168.1.170 port 12345 Interval           Transfer     Bandwidth       Retr  Cwnd 0.00-1.00   sec   112 MBytes   938 Mbits/sec    0    409 KBytes        1.00-2.00   sec   112 MBytes   940 Mbits/sec    0    426 KBytes        2.00-3.00   sec   112 MBytes   939 Mbits/sec    0    426 KBytes        3.00-4.00   sec   112 MBytes   940 Mbits/sec    0    426 KBytes        4.00-5.00   sec   112 MBytes   940 Mbits/sec    0    426 KBytes        5.00-6.00   sec   112 MBytes   939 Mbits/sec    0    426 KBytes        6.00-7.00   sec  9.26 MBytes  77.6 Mbits/sec    2   1.41 KBytes        7.00-8.00   sec  0.00 Bytes  0.00 bits/sec    1   1.41 KBytes        8.00-9.00   sec  0.00 Bytes  0.00 bits/sec    0   1.41 KBytes        ^C10.00-13.58  sec  0.00 Bytes  0.00 bits/sec    1   1.41 KBytes        - - - - - - - - - - - - - - - - - - - - - - - - - Interval           Transfer     Bandwidth       Retr 0.00-13.58  sec   681 MBytes   421 Mbits/sec    4             sender 0.00-13.58  sec  0.00 Bytes  0.00 bits/sec                  receiver iperf3: interrupt - the client has terminated iperf3 does not exit ant the link seems completely broken. We cannot send or receive until the interface is brought down then up again. Here are the LPI related stats after the test:      irq_tx_path_in_lpi_mode_n: 48      irq_tx_path_exit_lpi_mode_n: 48      irq_rx_path_in_lpi_mode_n: 325      irq_rx_path_exit_lpi_mode_n: 325      phy_eee_wakeup_error_n: 0 Like Martin, I tried playing around with eee in stmmac, but I could not improve the situation. Then I tried disabling EEE advertisement on the PHY (patch attached). With this patch, iperf3 runs nicely for me. This is what the folks of FreeBSD have done for the Same MAC/PHY combination [0] On the P200 Board (PHY Micrel KSZ9031), EEE is off by default. There is no problem on this board right now. I tried to force the activation of EEE on this board and ended up in the same situation as the OdroidC2 (link broken). The stats were a bit different though:      irq_tx_path_in_lpi_mode_n: 28      irq_tx_path_exit_lpi_mode_n: 28      irq_rx_path_in_lpi_mode_n: 408      irq_rx_path_exit_lpi_mode_n: 408      phy_eee_wakeup_error_n: 5440 To everybody having similar issue with their OdroidC2, could you try the attached patch and let us know if it changes anything for you ? Peppe, Alexandre, What is your view on this ? I'm not sure that removing EEE advertisement is the right way to address the problem ? Could it be an issue stmmac ? If there is any other information / test which would help understand the issue, please let me know. Cheers Jerome [0] : https://github.com/freebsd/freebsd-base-graphics/commit/1f49e276c 3801545dc0a337792a5f07e6ad39c84   > _______________________________________________ > linux-amlogic mailing list > linux-amlogic@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-amlogic diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts index a45d1013c225..3cbeec63a439 100644 --- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts +++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts @@ -127,3 +127,18 @@ &usb1 { status = "okay"; }; + +ðmac { + phy-handle = <ð_phy0>; + + mdio { + compatible = "snps,dwmac-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + eth_phy0: ethernet-phy@0 { + reg = <0>; + realtek,disable-eee-1000t; + }; + }; +}; diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index aadd6e9f54ad..30e20ba10f45 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -15,6 +15,12 @@ */ #include #include +#include + +struct rtl8211f_phy_priv { + bool eee_1000_disable; + bool eee_100_disable; +}; #define RTL821x_PHYSR 0x11 #define RTL821x_PHYSR_DUPLEX 0x2000 @@ -93,6 +99,25 @@ static int rtl8211f_config_intr(struct phy_device *phydev) return err; } +static void rtl8211f_force_eee(struct phy_device *phydev) +{ + struct rtl8211f_phy_priv *priv = phydev->priv; + u16 val; + + if (priv->eee_1000_disable || priv->eee_100_disable) { + val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, + MDIO_MMD_AN); + + if (priv->eee_1000_disable) + val &= ~MDIO_AN_EEE_ADV_1000T; + if (priv->eee_100_disable) + val &= ~MDIO_AN_EEE_ADV_100TX; + + phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, + MDIO_MMD_AN, val); + } +} + static int rtl8211f_config_init(struct phy_device *phydev) { int ret; @@ -102,6 +127,8 @@ static int rtl8211f_config_init(struct phy_device *phydev) if (ret < 0) return ret; + rtl8211f_force_eee(phydev); + if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { /* enable TXDLY */ phy_write(phydev, RTL8211F_PAGE_SELECT, 0xd08); @@ -115,6 +142,26 @@ static int rtl8211f_config_init(struct phy_device *phydev) return 0; } +static int rtl8211f_phy_probe(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + struct device_node *of_node = dev->of_node; + struct rtl8211f_phy_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + if (of_property_read_bool(of_node, "realtek,disable-eee-1000t")) + priv->eee_1000_disable= true; + if (of_property_read_bool(of_node, "realtek,disable-eee-100t")) + priv->eee_100_disable= true; + + phydev->priv = priv; + + return 0; +} + static struct phy_driver realtek_drvs[] = { { .phy_id = 0x00008201, @@ -164,6 +211,7 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211f_phy_probe, .config_aneg = &genphy_config_aneg, .config_init = &rtl8211f_config_init, .read_status = &genphy_read_status,