Received: by 10.213.65.68 with SMTP id h4csp2118933imn; Sun, 8 Apr 2018 20:10:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx492tM08XUeZEUo0mYaL24gRRtVa/GxUZgl9FuRZzb3GTfL3ZFz62dJBX7KSoV+fMMXCYqU7 X-Received: by 10.98.204.12 with SMTP id a12mr27801969pfg.3.1523243426286; Sun, 08 Apr 2018 20:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243426; cv=none; d=google.com; s=arc-20160816; b=0IhiRS0z/hfJM/Yj+xj5idPZlBHyZzRKGcunmg2n6ShyMKzxoex06CnGcH7NA5luvT Am/CegBy7yiadFqyYqYdrU6fjkA3rO6RG9i/7JHsVWizQZmivH3KLBCRGfikP1zJWWYo zAoQW5YARu9s9BT/y+F2x8Ex+HIfpJ1OOJI3cpPonKTmVJTzlNui20hJ00fdgOrTXaDT MVh1EYYLrtuOnfY9/pkz1cEIYo0ziRn0Q/FIHBxKMctFsxYx2ySOKDwRwDnvT2nxJ8gq SfUAAP9k+GyuLb5ll1pS77RkXggqzH+zZ3LnVgBah0GyoXX0uDTqIZWWgXCf1cxp6aq0 lUxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=eLpHe1fkY1ROH0t+lYMTk1UlSjvHEkrWFF+Dy1KUUBs=; b=wpKDq7ZHbJVEkIXimCOuv79H4VS+Ue8Si1TJAdn7aaIkUt7yqWllzF/QkWdWfrkWjd +Ous0rEBOySW+vgx9orplSqAZW1NfuG3eaIOn4yb1sQ6GqSmw3XdrMhCjK/+qTiAyRWt MY9e4nOQ24O2mORpnr1tHpFxRnc2A+6/+o765odaxESKIbSFkUXc6LZFKC3EEGlC1fGu lw/uSDLiJsbSqfPfXP/BikbfsXj29+YK3VuloNcPAbDkuP/j/6EIQ6YFGGBkarpDm4Ov vepv7SeJZGXax9mdZKcYSWasWd4vFSEE4GwXs+367XUDFgqLfNCMb/1ZydNMtkfGdXiv R7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=M5Ds8238; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33-v6si13015354plb.369.2018.04.08.20.09.49; Sun, 08 Apr 2018 20:10:26 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=M5Ds8238; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932882AbeDIBlQ (ORCPT + 99 others); Sun, 8 Apr 2018 21:41:16 -0400 Received: from mail-sn1nam02on0094.outbound.protection.outlook.com ([104.47.36.94]:35040 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755773AbeDIAe4 (ORCPT ); Sun, 8 Apr 2018 20:34:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=eLpHe1fkY1ROH0t+lYMTk1UlSjvHEkrWFF+Dy1KUUBs=; b=M5Ds8238ireMUTI++T/Tq+feJbV2xKIIpKsDPH9vne/gyX6oq9EhdCM8tlA0FQkDPXSn3VK1vvxW7aD9uY7uDSXnbNZoUkY5rPwISU/GYPBqbP19SnQgQbizuODUZsbt9SChn/doIKHlH+SiFbpmu5ugI73cEO0YQxzc1oPe0FY= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1013.namprd21.prod.outlook.com (52.132.133.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:34:53 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:34:53 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Christian Lamparter , Chris Blake , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 007/162] net: emac: fix reset timeout with AR8035 phy Thread-Topic: [PATCH AUTOSEL for 4.4 007/162] net: emac: fix reset timeout with AR8035 phy Thread-Index: AQHTz5mWy/F6Qqz5skKERIJYPGwajw== Date: Mon, 9 Apr 2018 00:27:48 +0000 Message-ID: <20180409002738.163941-7-alexander.levin@microsoft.com> References: <20180409002738.163941-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002738.163941-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1013;7:QJ9YgztK5cY8+Vc5mJxOGYitIPCiVATbuSs6dXgonT5QZ/8ZMUDkobi2WQ7MQfrFcJxXI2z3EfpU79vARAn1n6igxNhP8eSRaOJFP7pyovccxKiAiz5ceiOtbA+FmpIR66iCYwBybflS02AjroOpRO9LICBpFVDiCtOa7YwcDfRjipOefbwifOxlzzYfom/7cfqcPqrHpUjPNV0xAX99MY88tD6WRQW5Z0LG31p4Q37iiJCoQA662KqZ6PW+qUf4;20:dHZZi7sbnxv04WraYwYwa4mMSDnYV5YehNiFHDsLECXdRBz1T7D8lz80bqoC6WHOep68jFAlMcoicrnnnHaZQzC5gB22f5jkQw71d+7P/A5nyj89G1meHtR10mnng7c4UTTs9LgjsWPPxZdxxqQdN1lTIBDczF5uMIlgRg4DiTM= X-MS-Office365-Filtering-Correlation-Id: 63d8b8da-63fb-4de5-2dbf-08d59db1b663 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1013; x-ms-traffictypediagnostic: DM5PR2101MB1013: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158)(8415204561270); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1013;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1013; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(39860400002)(396003)(346002)(366004)(376002)(189003)(199004)(478600001)(10290500003)(6436002)(5250100002)(2501003)(5890100001)(347745004)(14454004)(305945005)(4326008)(66066001)(99286004)(10090500001)(6506007)(36756003)(102836004)(54906003)(486006)(107886003)(76176011)(59450400001)(2900100001)(22452003)(39060400002)(316002)(110136005)(86362001)(3660700001)(2906002)(81166006)(186003)(86612001)(81156014)(2616005)(8936002)(16799955002)(3280700002)(11346002)(53936002)(7736002)(476003)(446003)(72206003)(68736007)(6116002)(5660300001)(106356001)(6666003)(6486002)(8676002)(1076002)(105586002)(26005)(6306002)(6512007)(3846002)(97736004)(25786009)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1013;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: /cUt90I3OFZZw9ywvIDVhvW5t3f9DKcwKQUsaERYHvps8U3iGFRxXQzM/5XYIhvy/jZzuzHsjQdhLnW6nUySxKAcD8ygWx+6x9M7S6eI7pAcjwdZ39Mx4lgAptTuBiJwOjZaahg29Jjv+U3QgikOcIR3QTarZ+6fTUaE6l8jYvSuFg80GoTz4r9M9YA4nIPf8ZivNcukUS7xK7kPAiujih2uofwCb8lrlbVjCqlH/tnVJxLLAkTeL+nrVnWGVf37smdv+l+77EZRVvSXgAAS/IRXwUpl8/qzmmhg0zU7hRt4VA/P/vVBHVGLg9RHZIYHAau/EabPv7PKN3YiwcYVvWzIG8RSG65V+ousgBPdYwOGrMm3gAH3BXrKxICZgALU6dqY2/sow1gG3cUYJz8+vSHcf1eP7yF2Q4+mP8Z2AAk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63d8b8da-63fb-4de5-2dbf-08d59db1b663 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:27:48.1922 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1013 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/ethernet/ibm/emac/core.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ib= m/emac/core.c index 5d7db6c01c46..f301c03c527b 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -342,6 +342,7 @@ static int emac_reset(struct emac_instance *dev) { struct emac_regs __iomem *p =3D dev->emacp; int n =3D 20; + bool __maybe_unused try_internal_clock =3D false; =20 DBG(dev, "reset" NL); =20 @@ -354,6 +355,7 @@ static int emac_reset(struct emac_instance *dev) } =20 #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: @@ -361,10 +363,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] =3D 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 =3D=3D 0xffffffff && - dev->phy_map =3D=3D 0xffffffff) { + if (try_internal_clock || (dev->phy_address =3D=3D 0xffffffff && + dev->phy_map =3D=3D 0xffffffff)) { /* No PHY: select internal loop clock before reset */ dcri_clrset(SDR0, SDR0_ETH_CFG, 0, SDR0_ETH_CFG_ECS << dev->cell_index); @@ -382,8 +393,15 @@ static int emac_reset(struct emac_instance *dev) =20 #ifdef CONFIG_PPC_DCR_NATIVE if (emac_has_feature(dev, EMAC_FTR_460EX_PHY_CLK_FIX)) { - if (dev->phy_address =3D=3D 0xffffffff && - dev->phy_map =3D=3D 0xffffffff) { + if (!n && !try_internal_clock) { + /* first attempt has timed out. */ + n =3D 20; + try_internal_clock =3D true; + goto do_retry; + } + + if (try_internal_clock || (dev->phy_address =3D=3D 0xffffffff && + dev->phy_map =3D=3D 0xffffffff)) { /* No PHY: restore external clock source after reset */ dcri_clrset(SDR0, SDR0_ETH_CFG, SDR0_ETH_CFG_ECS << dev->cell_index, 0); --=20 2.15.1