Received: by 10.213.65.68 with SMTP id h4csp294150imn; Fri, 23 Mar 2018 04:57:45 -0700 (PDT) X-Google-Smtp-Source: AG47ELsOExyAeOPvpGD2BtzvkDUAwFC/sV0Q0MC6Lv0cukDGJ2/qML2h6HMxff0OLl3oGn0wkP6z X-Received: by 2002:a17:902:209:: with SMTP id 9-v6mr28639556plc.403.1521806265335; Fri, 23 Mar 2018 04:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521806265; cv=none; d=google.com; s=arc-20160816; b=YCdoXRxv2J8RoSMZaR7omgoaftyGQ8AlPq3I4Vx9Brifiti14hLhm+yoPW72hytOgi G5O2d5H1BzT7s2Gn7FSPPQl6Of5/VIWmz3ZcqVJueKhi71beaLMTqn/nSCDgZD40T6QS 6e6ab6quMsM7jY6DX7+4kE9cdmoSSzMjU7PDY9ldiJ3VFaSJEU8IoKYlcvWrIIqJY7BH rsAEy1s6Knh/USN2qUPaq2dcEp3dOzveHgSh+QrELj6bXAgf2/t6/YEFJNVSlKItgjb2 BjyVvpukk3DxiQrCrqcXhTTs639/VK3Pn5FYQ3EKqOsSv3+6qHghPhPKXop+Vvm7Ir8E 48VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qxIOjwhFrtZnVpb/SyE9AXSH4K1P3jL0TLTonOI6Q5s=; b=C2uP40bEhZypWpnNuY8Bt4p226W8a/w8jtwEr3lOiKYw+dWgIsO9KyZbmWnl+Rf6Aa /akFFkfj98zCkoVeyARME5ybfBKXHmd0+arZW6KYO/ige/oDW09Ln0I0fSbJgAJdP3m6 Wg+crYg4QQZLbYO3w4ooWC5+vOloBDxljrptXWp5Rnt+KnK9RZ0Gja0ipku1OWo88hTl +CaEEtqN1e2cwrk7nwpyVuhe4gNqPCDYAxAiN/ejdnDX+cAFVOTZPfcC6sSxbMbuE/wB FZKT6mUBwag+mKeq84b5WoRswcYtHcceZT6qWu+ttqJV3P+zs6lC8fi+1pk7yOeJTUvr GSMg== ARC-Authentication-Results: i=1; mx.google.com; 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 u186si6640594pfb.120.2018.03.23.04.57.30; Fri, 23 Mar 2018 04:57:45 -0700 (PDT) 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; 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 S1753745AbeCWKAv (ORCPT + 99 others); Fri, 23 Mar 2018 06:00:51 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37340 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753282AbeCWKAs (ORCPT ); Fri, 23 Mar 2018 06:00:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B4231F80; Fri, 23 Mar 2018 10:00:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Leitner , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 08/77] net: fec: add phy_reset_after_clk_enable() support Date: Fri, 23 Mar 2018 10:53:42 +0100 Message-Id: <20180323094142.763285240@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094142.260022880@linuxfoundation.org> References: <20180323094142.260022880@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Leitner [ Upstream commit 1b0a83ac04e383e3bed21332962b90710fcf2828 ] Some PHYs (for example the SMSC LAN8710/LAN8720) doesn't allow turning the refclk on and off again during operation (according to their datasheet). Nonetheless exactly this behaviour was introduced for power saving reasons by commit e8fcfcd5684a ("net: fec: optimize the clock management to save power"). Therefore add support for the phy_reset_after_clk_enable function from phylib to mitigate this issue. Generally speaking this issue is only relevant if the ref clk for the PHY is generated by the SoC and therefore the PHY is configured to "REF_CLK In Mode". In our specific case (PCB) this problem does occur at about every 10th to 50th POR of an LAN8710 connected to an i.MX6SOLO SoC. The typical symptom of this problem is a "swinging" ethernet link. Similar issues were reported by users of the NXP forum: https://community.nxp.com/thread/389902 https://community.nxp.com/message/309354 With this patch applied the issue didn't occur for at least a few hundret PORs of our board. Fixes: e8fcfcd5684a ("net: fec: optimize the clock management to save power") Signed-off-by: Richard Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/freescale/fec_main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -1872,6 +1872,8 @@ static int fec_enet_clk_enable(struct ne ret = clk_prepare_enable(fep->clk_ref); if (ret) goto failed_clk_ref; + + phy_reset_after_clk_enable(ndev->phydev); } else { clk_disable_unprepare(fep->clk_ahb); clk_disable_unprepare(fep->clk_enet_out); @@ -2844,6 +2846,7 @@ fec_enet_open(struct net_device *ndev) { struct fec_enet_private *fep = netdev_priv(ndev); int ret; + bool reset_again; ret = pm_runtime_get_sync(&fep->pdev->dev); if (ret < 0) @@ -2854,6 +2857,17 @@ fec_enet_open(struct net_device *ndev) if (ret) goto clk_enable; + /* During the first fec_enet_open call the PHY isn't probed at this + * point. Therefore the phy_reset_after_clk_enable() call within + * fec_enet_clk_enable() fails. As we need this reset in order to be + * sure the PHY is working correctly we check if we need to reset again + * later when the PHY is probed + */ + if (ndev->phydev && ndev->phydev->drv) + reset_again = false; + else + reset_again = true; + /* I should reset the ring buffers here, but I don't yet know * a simple way to do that. */ @@ -2870,6 +2884,12 @@ fec_enet_open(struct net_device *ndev) if (ret) goto err_enet_mii_probe; + /* Call phy_reset_after_clk_enable() again if it failed during + * phy_reset_after_clk_enable() before because the PHY wasn't probed. + */ + if (reset_again) + phy_reset_after_clk_enable(ndev->phydev); + if (fep->quirks & FEC_QUIRK_ERR006687) imx6q_cpuidle_fec_irqs_used();