Received: by 10.192.165.156 with SMTP id m28csp1192112imm; Wed, 11 Apr 2018 14:15:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+RhTLRBnwSBogyq0lbqUz0k+p8c1uS3G7DcMsNa2kC+CZJRpv2rDRtO7yeoj8Z9mMMrlcQ X-Received: by 2002:a17:902:bf47:: with SMTP id u7-v6mr6641506pls.133.1523481336026; Wed, 11 Apr 2018 14:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523481335; cv=none; d=google.com; s=arc-20160816; b=R8MNq8btmfA+atYwK0pmFQ7tNLU7eG2nhYmXW0SbsgAFpitN3dAClgT6Hh+JaDxfI3 FNGnXiLT0hiAgmJ473T0Su/X7Lun1k6JxfT+mqVAWVfXGVlIMsIdFfeQrLmH//BG92bV Bu9VeVSbPF+2qPgi6jqC9WyiujySHOEa8RrjzDMS2+lJ9QiE58ajm2hBXfiihm90E7Y6 g8UheFOfAeMkmlHNiOnTeubiEh0JLtWtv2xrnBAygBV7JYNDMm+waDM6K+OVhCtpVCgf EVNbIXWt9Fr2QHr4GMG4+i/9m3ADj7YCDBUwYlv1pdlt8pqmuq5+wdu/WR+r22uuylKW kMBg== 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=0KV8ignKlOfaErOpcyQLcBFd3DHiZSktmbGH4E8bAQc=; b=iOXDKqvmcQ/XH+aOJ6qs+mMLtRDQB2qNfV6yNcLeCB2RfWMEnZfTeRhoQnkTs2Lo8M 3x06GsCt5aT1qXSrBIX3KSdpCFUyutB1tzktB4hQVcYdbf0AGRatkNV4rAthc6pVIArF Ue0zX2oM53vR8dk0QRWJIFygBwwNiAvPrppfnjzdUin092BmvPCkV1Vi3HMVzoPIMIrT ylPLkfW0aZ37n1lA7YNKSKizRL7rVPs8ia2e0h6soTo4Bo635+7bfZAHF1kk2VM4Xm3T 4OsCVKxRylc8A2D7T/hy6n+DnztuZ2VGfduSVX1AxunlvBzRRv7FN6ttrHGQpNy1DoJn 9IyQ== 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 g66si1413696pfa.257.2018.04.11.14.14.59; Wed, 11 Apr 2018 14:15:35 -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 S1754852AbeDKSlb (ORCPT + 99 others); Wed, 11 Apr 2018 14:41:31 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56804 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754698AbeDKSlX (ORCPT ); Wed, 11 Apr 2018 14:41:23 -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 DED91E10; Wed, 11 Apr 2018 18:41:22 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Blake , Russell Senior , Christian Lamparter , Andrew Lunn , "David S. Miller" , Sasha Levin Subject: [PATCH 3.18 079/121] net: emac: fix reset timeout with AR8035 phy Date: Wed, 11 Apr 2018 20:36:22 +0200 Message-Id: <20180411183501.003275697@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183456.195010921@linuxfoundation.org> References: <20180411183456.195010921@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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Lamparter [ Upstream commit 19d90ece81da802207a9b91ce95a29fbdc40626e ] This patch fixes a problem where the AR8035 PHY can't be detected on an Cisco Meraki MR24, if the ethernet cable is not connected on boot. Russell Senior provided steps to reproduce the issue: |Disconnect ethernet cable, apply power, wait until device has booted, |plug in ethernet, check for interfaces, no eth0 is listed. | |This appears to be a problem during probing of the AR8035 Phy chip. |When ethernet has no link, the phy detection fails, and eth0 is not |created. Plugging ethernet later has no effect, because there is no |interface as far as the kernel is concerned. The relevant part of |the boot log looks like this: |this is the failing case: | |[ 0.876611] /plb/opb/emac-rgmii@ef601500: input 0 in RGMII mode |[ 0.882532] /plb/opb/ethernet@ef600c00: reset timeout |[ 0.888546] /plb/opb/ethernet@ef600c00: can't find PHY! |and the succeeding case: | |[ 0.876672] /plb/opb/emac-rgmii@ef601500: input 0 in RGMII mode |[ 0.883952] eth0: EMAC-0 /plb/opb/ethernet@ef600c00, MAC 00:01:.. |[ 0.890822] eth0: found Atheros 8035 Gigabit Ethernet PHY (0x01) Based on the comment and the commit message of commit 23fbb5a87c56 ("emac: Fix EMAC soft reset on 460EX/GT"). This is because the AR8035 PHY doesn't provide the TX Clock, if the ethernet cable is not attached. This causes the reset to timeout and the PHY detection code in emac_init_phy() is unable to detect the AR8035 PHY. As a result, the emac driver bails out early and the user left with no ethernet. In order to stay compatible with existing configurations, the driver tries the current reset approach at first. Only if the first attempt timed out, it does perform one more retry with the clock temporarily switched to the internal source for just the duration of the reset. LEDE-Bug: #687 Cc: Chris Blake Reported-by: Russell Senior Fixes: 23fbb5a87c56e98 ("emac: Fix EMAC soft reset on 460EX/GT") Signed-off-by: Christian Lamparter Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/ibm/emac/core.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -349,6 +349,7 @@ static int emac_reset(struct emac_instan { struct emac_regs __iomem *p = dev->emacp; int n = 20; + bool __maybe_unused try_internal_clock = false; DBG(dev, "reset" NL); @@ -361,6 +362,7 @@ static int emac_reset(struct emac_instan } #ifdef CONFIG_PPC_DCR_NATIVE +do_retry: /* * PPC460EX/GT Embedded Processor Advanced User's Manual * section 28.10.1 Mode Register 0 (EMACx_MR0) states: @@ -368,10 +370,19 @@ static int emac_reset(struct emac_instan * of the EMAC. If none is present, select the internal clock * (SDR0_ETH_CFG[EMACx_PHY_CLK] = 1). * After a soft reset, select the external clock. + * + * The AR8035-A PHY Meraki MR24 does not provide a TX Clk if the + * ethernet cable is not attached. This causes the reset to timeout + * and the PHY detection code in emac_init_phy() is unable to + * communicate and detect the AR8035-A PHY. As a result, the emac + * driver bails out early and the user has no ethernet. + * In order to stay compatible with existing configurations, the + * driver will temporarily switch to the internal clock, after + * the first reset fails. */ if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { - if (dev->phy_address == 0xffffffff && - dev->phy_map == 0xffffffff) { + if (try_internal_clock || (dev->phy_address == 0xffffffff && + dev->phy_map == 0xffffffff)) { /* No PHY: select internal loop clock before reset */ dcri_clrset(SDR0, SDR0_ETH_CFG, 0, SDR0_ETH_CFG_ECS << dev->cell_index); @@ -389,8 +400,15 @@ static int emac_reset(struct emac_instan #ifdef CONFIG_PPC_DCR_NATIVE if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { - if (dev->phy_address == 0xffffffff && - dev->phy_map == 0xffffffff) { + if (!n && !try_internal_clock) { + /* first attempt has timed out. */ + n = 20; + try_internal_clock = true; + goto do_retry; + } + + if (try_internal_clock || (dev->phy_address == 0xffffffff && + dev->phy_map == 0xffffffff)) { /* No PHY: restore external clock source after reset */ dcri_clrset(SDR0, SDR0_ETH_CFG, SDR0_ETH_CFG_ECS << dev->cell_index, 0);