From patchwork Mon Jun 5 20:49:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 771466 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 3whRlQ2JBbz9s3w for ; Tue, 6 Jun 2017 06:49:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlemail.com header.i=@googlemail.com header.b="TsrC21zk"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdFEUtp (ORCPT ); Mon, 5 Jun 2017 16:49:45 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33588 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbdFEUtn (ORCPT ); Mon, 5 Jun 2017 16:49:43 -0400 Received: by mail-wr0-f196.google.com with SMTP id v104so8555493wrb.0 for ; Mon, 05 Jun 2017 13:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=KeO8uS7TZCE2HWrYwYDszMw59vb5Uhmvy29tBiTJ/ko=; b=TsrC21zksLXmXpodAKY8skBbsy24URf6MubH5JkH44nSsf0A1gwu3V/+oV17cYe2pu lKUPd8j+SHMmqqmauPV+PaVpEyrHRkzggGbYrZYx1ztw8pOhBSTjgC5/+cTFl80hZ0Ot mB2WBIUZX1ftcrnBvVgqSdu9Mlxx2gTzg5VgTDhXIAqHyKMBwecUOFuO4pycGCh4Dt22 d59FQeL0r4oPErHaHYy0y5vJp4nOAruQ9CsoQfQdJqdCgy0JA1dmzs2mnyzNxkY7OW0I /A30f8zygFynTVOzTMa/HVPa3z/hdMitEDxRiqFS54mwRjApBlSA4JcR/vrBSzuAlfvu gqhA== 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; bh=KeO8uS7TZCE2HWrYwYDszMw59vb5Uhmvy29tBiTJ/ko=; b=e5gTJXWslZ4LEMYDVDHeb5n8jZD9XUfohRqRGtP1XufdDFguKP7olmKwQ/73KrUmaR vYMlA29ZWoHUV0i/0Rg/N40z5RNvVK7QklaAhAIHoFHTdwI8KdKYm5LYohTgf82yqOz+ Bw5l8jIfCRgNsBOKY1VuChffzjtXtU0auepsZfSyhzD3xLlLG3aQzqDCa6EjVCk8Nxjw m2gcsu4Tqi4kIMcrOUEpIxDvypZnmkWFVcmZzDSev/G/FlH4Zr19VUMCj53ZiV6WzjU/ MuyTOib3VTtdOW0eaXnqb5HrseFduKslHne3hitOiTVU5TPbFvHa7Yi5GszPU1fbqiBE rqBA== X-Gm-Message-State: AODbwcDy7DWu+9ged+ytnDkl/r9pdI774WwvM0D30HC7AihsPH63oAUR pUHXfYBuwaLnRqG6 X-Received: by 10.223.161.220 with SMTP id v28mr5383095wrv.37.1496695782094; Mon, 05 Jun 2017 13:49:42 -0700 (PDT) Received: from debian64.daheim (p200300D5FBC16BFCD63D7EFFFEBDE96E.dip0.t-ipconnect.de. [2003:d5:fbc1:6bfc:d63d:7eff:febd:e96e]) by smtp.gmail.com with ESMTPSA id v45sm46506901wrb.68.2017.06.05.13.49.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Jun 2017 13:49:41 -0700 (PDT) Received: from chuck by debian64.daheim with local (Exim 4.89) (envelope-from ) id 1dHywW-00047t-BW; Mon, 05 Jun 2017 22:49:40 +0200 From: Christian Lamparter To: netdev@vger.kernel.org Cc: "David S . Miller" , Ivan Mikhaylov , Chris Blake Subject: [PATCH v1 1/2] net: emac: fix reset timeout with AR8035 phy Date: Mon, 5 Jun 2017 22:49:39 +0200 Message-Id: <635dd014238af6f48c4169439b7ac161e80de1b7.1496695540.git.chunkeey@googlemail.com> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 of the Meraki MR24 does not provide the 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 detect the AR8035 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 try the normal reset first and only falls back to to the internal clock, after the first reset fails. If the second reset fails as well, it will give up as before. 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 --- drivers/net/ethernet/ibm/emac/core.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index 508923f39ccf..18af1116fa1d 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -343,6 +343,7 @@ static int emac_reset(struct emac_instance *dev) { struct emac_regs __iomem *p = dev->emacp; int n = 20; + bool try_internal_clock = false; DBG(dev, "reset" NL); @@ -355,6 +356,7 @@ static int emac_reset(struct emac_instance *dev) } #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: @@ -362,10 +364,19 @@ static int emac_reset(struct emac_instance *dev) * 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 fall back to and 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); @@ -383,8 +394,8 @@ static int emac_reset(struct emac_instance *dev) #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 (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); @@ -396,9 +407,16 @@ static int emac_reset(struct emac_instance *dev) dev->reset_failed = 0; return 0; } else { - emac_report_timeout_error(dev, "reset timeout"); - dev->reset_failed = 1; - return -ETIMEDOUT; + if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX) && + !try_internal_clock) { + /* do a retry with the internal clock */ + try_internal_clock = true; + goto do_retry; + } else { + emac_report_timeout_error(dev, "reset timeout"); + dev->reset_failed = 1; + return -ETIMEDOUT; + } } }