Received: by 10.213.65.68 with SMTP id h4csp2115053imn; Sun, 8 Apr 2018 20:05:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+tV6NHK0E6zAMwa3/gloKUN/j0kKzdgWJPn2bIkPjybUSGETYAlDj9RUphzPUrl5gSrizR X-Received: by 10.99.174.67 with SMTP id e3mr23874298pgp.139.1523243133649; Sun, 08 Apr 2018 20:05:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243133; cv=none; d=google.com; s=arc-20160816; b=THx16yQvFxYY1uL/ir2cIqisfcK4oma8XgDgSDS0bybrfROgSvEu30jV+ublsrHZD4 Rfqb3j8QdGz7a7o1s95hww34YeokIyDpXIOEMyDLY8O12pLzuHYydMPUc7Z6a7JRNbzc HQQkeWdwgNfvMV7HtTC+jVJsqLGRGJnx6qMP1noUCBGIZRPg2XJwnUcNk8odzjP+so3G TA7JcFsfFv9MQuTkDjLn+a3aaz1pbERI5KrBZrPpJOtmfW5Y/fnusMUasWOW7GBXwnKZ IEba6AqzPbTc91AuiW5fPvKNpLkBi5OUCXMHys6l1H2YH1TGpauP9Eg0tN0Xru1/hInC SlDA== 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=tS+lR4ksBSbussWLk9meDr4Umj87AHjJDZQoXh6y8Xg=; b=lTLAqzwCqrUNyl5YfpGGCVwKNHkwowDR3a30S/uHeVKM+WxbUdhr2G8xgORp7/vVBS C6C3ReVwE6VIN+CNuSm3JQcScwuNbPROk1z0+UPp6fL/vf++O15TEMEJIcFFV7ufK5WP 7APZAq9IXinm4qVRUo7FKMgODtTaqxAwQsL46CLf4cJ5WQ6ycoPkfLgnNp73QFFcaPwQ sNVHE61ei/Ep+pFida+haXAnuJmIkTl2gn0r9gmjhcGJmc6CwhYN9f/8bC2ZkM5Hrff4 UUB+/8MIVDsElo+ZcmnXE1jmAMKPLrLAi17iUIN8NLmZVVZ9NOCQnHnzPjQbPzBC9VR6 mdPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=Rgq33/b7; 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 e32-v6si13830460plb.135.2018.04.08.20.04.56; Sun, 08 Apr 2018 20:05:33 -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=Rgq33/b7; 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 S1755502AbeDIA1A (ORCPT + 99 others); Sun, 8 Apr 2018 20:27:00 -0400 Received: from mail-by2nam01on0099.outbound.protection.outlook.com ([104.47.34.99]:2811 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754312AbeDIA0o (ORCPT ); Sun, 8 Apr 2018 20:26:44 -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=tS+lR4ksBSbussWLk9meDr4Umj87AHjJDZQoXh6y8Xg=; b=Rgq33/b7UU9b/dX5Ev7EJyWHFOqICv2PZ3gnDbjNQqC4nlTT7AEoxZyvvp8F4pJBpWD0rR79EBxrizguA53f/idGzj0W4T10cyu+YCavgomeMfPHWLdi6u/ZEBouo6YFQA0N1hddOhVN8OXNTjXcLHxwIy98cN2pJja2cPcad68= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1015.namprd21.prod.outlook.com (52.132.133.37) 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:26:36 +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:26:36 +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.9 012/293] net: emac: fix reset timeout with AR8035 phy Thread-Topic: [PATCH AUTOSEL for 4.9 012/293] net: emac: fix reset timeout with AR8035 phy Thread-Index: AQHTz5jo5JvCXR18aEyf4sACKzqHgA== Date: Mon, 9 Apr 2018 00:22:57 +0000 Message-ID: <20180409002239.163177-12-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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;DM5PR2101MB1015;7:x7BVchSYQAJZpMy0eN2Siztyo5yCfl6bMwO3qhTPss2o4dftcZXYGKSfN2Mcqb7LFo+dNC8VmnhggaBfG4lUXyxvi+bP99t4M1feGbF7pLVNKTC4k3HXrvw+ol2XajWX7TO+mGEIE2Y9YCyMZD0lWdfs4GJtZHhqKR+gQgX8IHVLc9FxPlCEL5Sg93zEiIOn7IuMBMLAspzS+6vIRsUZiF5FgUSRFVwVCof1L66ZUcHSNd1ftAMBLUlCfVqM0+H+;20:rbocMO1P0fZcth7IeJ1p9qCT/8rvVSbfuuiXOQ7r8P5fbbmNyFTALr/5GAvnqSZv8noox+idgIBU7+Ft51CaY+1DPJtdKXowgxFNZ/Hs7krQLcxGyjFHWFTFBRbJptJRRb2Omm04XB2Z6t1yC2y35WRXU6qsI9gpQcmIOhfM8Ec= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 14f7efef-db8f-4c16-676e-08d59db08e3a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1015; x-ms-traffictypediagnostic: DM5PR2101MB1015: 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:DM5PR2101MB1015;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1015; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(39380400002)(376002)(346002)(366004)(189003)(199004)(53936002)(4326008)(478600001)(72206003)(3280700002)(2616005)(14454004)(305945005)(5250100002)(5890100001)(3660700001)(2501003)(2900100001)(54906003)(110136005)(86362001)(1076002)(347745004)(107886003)(6506007)(36756003)(446003)(68736007)(6512007)(7736002)(486006)(2906002)(6306002)(5660300001)(6436002)(3846002)(86612001)(6486002)(66066001)(11346002)(575784001)(476003)(6666003)(59450400001)(26005)(10090500001)(16799955002)(316002)(22452003)(8676002)(81156014)(81166006)(6116002)(105586002)(99286004)(186003)(106356001)(76176011)(39060400002)(25786009)(97736004)(10290500003)(102836004)(8936002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1015;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: R4E8gG7Ey8ykOtAQWAOnaimM652bVHp6io+23S5lvjs6H6Mvb7coqD6XmDr5wPUz3KrzW/bVAE70Fe5XFZovzp82YNVxD+C4E/tcH80NSCepWGWQbUoJvLTrwbpTq+qv/4gMKiHwKA77MD9Ui5HP1I0ZgmnzS952eCwIb1iiIMQnWxtbmf4CQlPrECk/RDCV8yx4eQtdpCN3vyOcUo/3+FT6EJlsTTnfBjbyJYq+iYONWNs2jhLpxSCqjnB0qa9/oiTusBhMGETHsIDKLgZSFevLYOmDANOMyKaaLjLiOnbciAjjJnBBmXUR1aMR9pSUeWjcSbNbT8SphJXrbCOh4GMmQPh7hEOBCI+IscuSCmGXH2/FS/LMA7XICi8GbRc+MFH/gpdPEG+peXtisSjRekdcFnCNueXe5STw0UpA7IM= 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: 14f7efef-db8f-4c16-676e-08d59db08e3a X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:22:57.3623 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1015 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 8f139197f1aa..5977b695d0fa 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