From patchwork Tue Nov 15 14:29:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 695046 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tJ8v25D23z9t0q for ; Wed, 16 Nov 2016 01:30:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="FF631eaI"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755180AbcKOOae (ORCPT ); Tue, 15 Nov 2016 09:30:34 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37443 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755318AbcKOO3d (ORCPT ); Tue, 15 Nov 2016 09:29:33 -0500 Received: by mail-wm0-f53.google.com with SMTP id t79so2465780wmt.0 for ; Tue, 15 Nov 2016 06:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I3QF932m87od+RPqQjVJfv/wpVtp37hNDKLXADoxYlA=; b=FF631eaIzTLlVRDILWRgFD38OwU12acCAuDMeY5A3YeuRzhKNWcQeKaPxUkRvktYuC J4Tf9Of1Wmy2fS5jbtOxBh6eEXlJArjbo76wmMZTOVc5JBN5iKAYnFoDv5rxKOKfmimc Ky1qna8a1xvcjRt5PXhhKaZnxYWA4i22QwC8eysY3JzYj2Z82eSGDKtjdRo8nIrQRR59 4DRJs2t/K0aSrDcukL44OJjhujMUfDutoLXvwZVosYQ4Aw+jpVwlTZ6HBwi+7lPUHvh+ ogfrg6nCSj/dvMiRJElTwZYmwgHCE9CvCVV7LsIrxReI6u7l6j2U2WTbKKD3DLNH7xgb wjew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I3QF932m87od+RPqQjVJfv/wpVtp37hNDKLXADoxYlA=; b=dbZpJoiQ2wCn2oxI67z3e+rMeWL7/1ECRP7iPDxX8H2UAQRCg80R5AnOe34dzEyI04 18cD641U6vIa44dXPn0UezIwAGwRolAQuNSSycvLL27EzjZ4vLsleeB6oeckeEGEhx5d 063fpsjRio9Ej4E8PkQFvE3U0cEeJHT/Uql2hxHuUjggl0PeCHmKMes9EX1S27N2bbGU eLGZgLR5y2vZToxGfw5kCbhdCG9cTmVAp5nVzhnY9tpqBmqiI7B42ktQeJee+limZPqP VlyoiKdBM4EoWsBo2sPHSffizlQZ9mrDI8dRKRwHU7cBqWSlsQLkKn0xzPJ57xDQsh5d mamQ== X-Gm-Message-State: ABUngvfgeCV92T+EFqTKStbEBX1uTe3fION7tzM6nXbQ9Cfq+koRPyk3eS1IZIwvK3idxTPS X-Received: by 10.28.19.67 with SMTP id 64mr3999645wmt.111.1479220172139; Tue, 15 Nov 2016 06:29:32 -0800 (PST) Received: from boomer.baylibre.com ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id kp5sm7619219wjb.8.2016.11.15.06.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2016 06:29:31 -0800 (PST) From: Jerome Brunet To: netdev@vger.kernel.org, devicetree@vger.kernel.org, Florian Fainelli Cc: Jerome Brunet , Carlo Caione , Kevin Hilman , Giuseppe Cavallaro , Alexandre TORGUE , Martin Blumenstingl , Andre Roth , Neil Armstrong , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH net 1/3] net: phy: realtek: add eee advertisement disable options Date: Tue, 15 Nov 2016 15:29:12 +0100 Message-Id: <1479220154-25851-2-git-send-email-jbrunet@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479220154-25851-1-git-send-email-jbrunet@baylibre.com> References: <1479220154-25851-1-git-send-email-jbrunet@baylibre.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On some platforms, energy efficient ethernet with rtl8211 devices is causing issue, like throughput drop or broken link. This was reported on the OdroidC2 (DWMAC + RTL8211F). While the issue root cause is not fully understood yet, disabling EEE advertisement prevent auto negotiation from enabling EEE. This patch provides options to disable 1000T and 100TX EEE advertisement individually for the realtek phys supporting this feature. Reported-by: Martin Blumenstingl Cc: Giuseppe Cavallaro Cc: Alexandre TORGUE Signed-off-by: Jerome Brunet Signed-off-by: Neil Armstrong Tested-by: Andre Roth --- drivers/net/phy/realtek.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index aadd6e9f54ad..77235fd5faaf 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -15,6 +15,12 @@ */ #include #include +#include + +struct rtl8211x_phy_priv { + bool eee_1000t_disable; + bool eee_100tx_disable; +}; #define RTL821x_PHYSR 0x11 #define RTL821x_PHYSR_DUPLEX 0x2000 @@ -93,12 +99,44 @@ static int rtl8211f_config_intr(struct phy_device *phydev) return err; } +static void rtl8211x_clear_eee_adv(struct phy_device *phydev) +{ + struct rtl8211x_phy_priv *priv = phydev->priv; + u16 val; + + if (priv->eee_1000t_disable || priv->eee_100tx_disable) { + val = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV, + MDIO_MMD_AN); + + if (priv->eee_1000t_disable) + val &= ~MDIO_AN_EEE_ADV_1000T; + if (priv->eee_100tx_disable) + val &= ~MDIO_AN_EEE_ADV_100TX; + + phy_write_mmd_indirect(phydev, MDIO_AN_EEE_ADV, + MDIO_MMD_AN, val); + } +} + +static int rtl8211x_config_init(struct phy_device *phydev) +{ + int ret; + + ret = genphy_config_init(phydev); + if (ret < 0) + return ret; + + rtl8211x_clear_eee_adv(phydev); + + return 0; +} + static int rtl8211f_config_init(struct phy_device *phydev) { int ret; u16 reg; - ret = genphy_config_init(phydev); + ret = rtl8211x_config_init(phydev); if (ret < 0) return ret; @@ -115,6 +153,26 @@ static int rtl8211f_config_init(struct phy_device *phydev) return 0; } +static int rtl8211x_phy_probe(struct phy_device *phydev) +{ + struct device *dev = &phydev->mdio.dev; + struct device_node *of_node = dev->of_node; + struct rtl8211x_phy_priv *priv; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->eee_1000t_disable = + of_property_read_bool(of_node, "realtek,disable-eee-1000t"); + priv->eee_100tx_disable = + of_property_read_bool(of_node, "realtek,disable-eee-100tx"); + + phydev->priv = priv; + + return 0; +} + static struct phy_driver realtek_drvs[] = { { .phy_id = 0x00008201, @@ -140,7 +198,9 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211x_phy_probe, .config_aneg = genphy_config_aneg, + .config_init = &rtl8211x_config_init, .read_status = genphy_read_status, .ack_interrupt = rtl821x_ack_interrupt, .config_intr = rtl8211e_config_intr, @@ -152,7 +212,9 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211x_phy_probe, .config_aneg = &genphy_config_aneg, + .config_init = &rtl8211x_config_init, .read_status = &genphy_read_status, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211e_config_intr, @@ -164,6 +226,7 @@ static struct phy_driver realtek_drvs[] = { .phy_id_mask = 0x001fffff, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &rtl8211x_phy_probe, .config_aneg = &genphy_config_aneg, .config_init = &rtl8211f_config_init, .read_status = &genphy_read_status,