Message ID | 20231227231657.15152-1-asmaa@nvidia.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-12305-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1712704dyb; Wed, 27 Dec 2023 15:17:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/NT3GwJMan0U17taKw0LT3aGU5zJNXfwYF1Pzxat3tprROb7m7Bcc3+K78MhyWEd6hGYI X-Received: by 2002:a05:6a20:63a1:b0:195:2389:5f2d with SMTP id m33-20020a056a2063a100b0019523895f2dmr3725409pzg.116.1703719046587; Wed, 27 Dec 2023 15:17:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703719046; cv=pass; d=google.com; s=arc-20160816; b=bgM72vicXZJ6dQBC0t5DrVMJH4okAf6bIGs3Se530sZNH1ssXNcReSp86H3It8Wyyg rC7BeABdFg64uHzvbi61073Zh2tnRHMyMzgrQFcQI873lFdHlFq/8NaHym9Hb52r7ees ElhmNxIZ+8sjgqo5pQF1BfceizRW7nnYjkOtr80G6tY4/f/JTTJQzwzURBTSN2w+bjVo cUpGX4Oq2QhAx0R5dDHmtf5fzfCnFh+4cRZT8dSgyN+w9/8rb/ggabQwTPHseWvAbUIm RLat0IdQunZSIbm0oJL+rKS5JAgdhBRVcM4SdJRmb6ZlTC/G/z6PP/ubFNhYtqCSEzPp gCpg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=1QLYHabttXnUFGnQ8MZBduvKPRiYw4cCnYekrsESfio=; fh=DN6gn4oK6FQ7CR/+gDjQR7Nvu4AwHhlwZlRUgv/UMX4=; b=rB4YcdTM0aE5hRtQul4dbXtACvEnM8LS36eiuL0Crka2IZJuuKQcijylcUpUyBDAUc E3FSZiFR6cVaszxlMbAPAHWb5wvN67nu+qfdWv0gQNymXuzTncwlxHFJmBc2grmF7+Wf cb1xceq418/hCvSxMT3g3GnPGSw/YAYvnfHFiyfFpv6kzK7UrofDKleW7kR4vU3WrCmW mi0aezrAYZWbaz4pBRMdqVDlGkz8C+8ROxwSoYPV5aOPEpGK5PN0hMSdbNVzLXUJ2sCP w2T+740Dn1XEMRsZAYE2w3RgsVWMPjJXlPDuIhzK0w/Tf0NcZp4lkcPzItaPo7jAGpyd aFUg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=dWL+iN9T; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel+bounces-12305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12305-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q15-20020a17090311cf00b001d362b90468si11945930plh.286.2023.12.27.15.17.26 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 15:17:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=dWL+iN9T; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel+bounces-12305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12305-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id BBC10283BC9 for <ouuuleilei@gmail.com>; Wed, 27 Dec 2023 23:17:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DCAF49F6F; Wed, 27 Dec 2023 23:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="dWL+iN9T" X-Original-To: linux-kernel@vger.kernel.org Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2086.outbound.protection.outlook.com [40.107.244.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4C0049896; Wed, 27 Dec 2023 23:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mDCV/XEKiZ+HsSeF7MBvDnC+os2mPSh+QjzF48Iu/mjDEjPVBdzV6dUheIBP5VXsel7JJik6iqQ2nScz5DrQ+rQqchg8okxb2DJo+puVm1qY446jwhk7UpWvGJc1zTwIYK5ufIqsGrryQAsz56TD+G+kRJ3C2b0qOWxHHWc4GGH/nsqb+CKWXUoh1VDXK8cQn+slZwRVpOi/pqHaWlypECMlBP3AJFQek4uMIeGr4oIRgKb2r/axPTTX9iU+QojgMgY3AgNeYyhAbrip0RhfK7PjWRnTq/rty31zsKSqaSn/56aUFCVnwbA3iagsbUZjbQWrsX3n5sLZuHk4iXlFfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1QLYHabttXnUFGnQ8MZBduvKPRiYw4cCnYekrsESfio=; b=meHdh67ZVPoPdsMTuFeRE1dYN4eUADfvNbIiniyNF9MBjsiho8t1bOFa/JM5gpK7S5F5DnQ3sP4WH/3E2bXVGg644okhP+LYBMhnZ5qa3VInDbPaWbGn4mAEizn0Mn1/tFHh6RWbRaIsVbyr+6qBuJsNibk3r1clVNMsDMegDxRa/2H+cevNccPREkpz367JE1/K74wjb++iY0rIt+yus92y+1pl5i8zN+79ULhjbeWBVbDg/vNOoj2Smuy+yXoc1A9Q6HTNGUlywWrQIVseYoQdvJQGN5c5CacYG5xz7H9gypb2HY50igeUoddYjvSBM9v2OOdmFzQ3ir0tSAjBUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1QLYHabttXnUFGnQ8MZBduvKPRiYw4cCnYekrsESfio=; b=dWL+iN9Tt6ZEop5etEC2iaZSdqUDAX/Z4tJ8hzgh5TlX5bumH0+MTnF3dg6oDLjpjVUoeQbMpx3GGpDA8uwpz5ndDIPmsne0FfQrVKSIsAtsb7vvGKOCKaiWYn4Uk4GcjB7T6Opk0HMNalINOj9D0/BWYrUmebAD0XMBoS8qaQUnMmqwddiA2UrEb5Qr4hN2W8y8mHTPQ9qmAdkrj4TkHJ2HAjqQznT7CR0UYG0vNS8L2Z6MUtKQputdAHZcjtNDOoBMnn16+yPhU0rdvo4a3hGZmhu1yA81U1O0qSdXGaSSc2bPIdeNRVjrR3SM3IhVFaF1A7aw0lawD9mfCFKuAg== Received: from DS7PR05CA0007.namprd05.prod.outlook.com (2603:10b6:5:3b9::12) by BY5PR12MB4180.namprd12.prod.outlook.com (2603:10b6:a03:213::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.27; Wed, 27 Dec 2023 23:17:03 +0000 Received: from SA2PEPF0000150A.namprd04.prod.outlook.com (2603:10b6:5:3b9:cafe::89) by DS7PR05CA0007.outlook.office365.com (2603:10b6:5:3b9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.7 via Frontend Transport; Wed, 27 Dec 2023 23:17:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by SA2PEPF0000150A.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.14 via Frontend Transport; Wed, 27 Dec 2023 23:17:02 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 27 Dec 2023 15:17:01 -0800 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Wed, 27 Dec 2023 15:17:01 -0800 Received: from vdi.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Wed, 27 Dec 2023 15:17:00 -0800 From: Asmaa Mnebhi <asmaa@nvidia.com> To: <davem@davemloft.net>, <marek.mojik@nic.cz>, <netdev@vger.kernel.org> CC: Asmaa Mnebhi <asmaa@nvidia.com>, <davthompson@nvidia.com>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2 1/1] net: phy: micrel: Add workaround for incomplete autonegotiation Date: Wed, 27 Dec 2023 18:16:57 -0500 Message-ID: <20231227231657.15152-1-asmaa@nvidia.com> X-Mailer: git-send-email 2.30.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF0000150A:EE_|BY5PR12MB4180:EE_ X-MS-Office365-Filtering-Correlation-Id: 615197c9-3748-4169-a05a-08dc0731ef05 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vTS2yeVMv6pPFlUebO4B3f69UK0jx21/fAoFiKcK6MyZZl2oECYf8YgXHpxgMSZkIljRX1Uyg/wVwL1BPwsNwYIJ3iyzUAoFXhkPSJ6LViLoMe1yXyN1e0Hbd0TuQpm3yIDJiiF8/SZv3HFUP+YrSNOj+r0vr3s0iVBdpnaK6f3DA3RNBokHBp0GF8uB6EvwtV5/Yf0tQXtFgM+AvSEQH9UVo5YIbKpmoU8T5V/CRHPunuMTZBUP6xK8JehPa2q2NKg5jjrXEZ0FD5uOAKRF6ljHoGPp1uDlguL8IUFGi0R9H8ZK52B/kgeJJJt2dwfRFvswB5jJ9NLPsCkmN/wbbexmnNMjW1RJrLenNpP1v8BFjovHDPeZW5RyBmRqLHZh8b3D/EU72XEvePAZRI2Lv3XMtJTwYqPgW3lUEc/77plNgypEIzDM8yTqCPsh+71mdU2PkcVw1Jzd2LkzeaSlUcGzzZ2u3PWN/+G7Hg6omdN5DQnXN1whhndWfzzZrWWoi1pqZDH0m3FohjdHnlmZR5CAj3T8s5jkyeFRgWn6MMbjweMoylAZHh5zVbIkoKvE4Sk3VBLgL78+rZH6SFR8QCxmkfkllcmfI4KF2A3qcDg38t3XGwCgVxsK7iKFpJ6OuGkUaoPY20iMp8j/CErgCD+M852IXd0CPzuLmCLq6gZdFjIqwdLHk6RhwISihVpheqKuZWYyVMG5Rc1uXEjuqQ== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(39850400004)(136003)(396003)(346002)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(82310400011)(36840700001)(46966006)(316002)(26005)(8676002)(8936002)(478600001)(1076003)(7696005)(86362001)(2616005)(36756003)(336012)(82740400003)(7636003)(6666004)(36860700001)(356005)(426003)(54906003)(110136005)(47076005)(41300700001)(70586007)(70206006)(5660300002)(40480700001)(2906002)(4326008);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2023 23:17:02.3433 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 615197c9-3748-4169-a05a-08dc0731ef05 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF0000150A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4180 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786478902789493783 X-GMAIL-MSGID: 1786478902789493783 |
Series |
[v2,1/1] net: phy: micrel: Add workaround for incomplete autonegotiation
|
|
Commit Message
Asmaa Mnebhi
Dec. 27, 2023, 11:16 p.m. UTC
Very rarely, the KSZ9031 fails to complete autonegotiation although it was
initiated via phy_start(). As a result, the link stays down. Restarting
autonegotiation when in this state solves the issue.
Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com>
---
v1->v2:
- Use msleep() instead of mdelay()
drivers/net/phy/micrel.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
Comments
On 12/28/2023 12:16 AM, Asmaa Mnebhi wrote: > Very rarely, the KSZ9031 fails to complete autonegotiation although it was > initiated via phy_start(). As a result, the link stays down. Restarting > autonegotiation when in this state solves the issue. > > Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com> Is there a Micrel errata associated with this work around that could be referenced here?
> On 12/28/2023 12:16 AM, Asmaa Mnebhi wrote: > > Very rarely, the KSZ9031 fails to complete autonegotiation although it > > was initiated via phy_start(). As a result, the link stays down. > > Restarting autonegotiation when in this state solves the issue. > > > > Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com> > > Is there a Micrel errata associated with this work around that could be > referenced here? Hi Florian, No there isn’t. This is based on observations and comparison with the behavior and testing of other PHYs. For example, we don’t see this issue with the Vitesse PHY. Thanks. Asmaa
On 28.12.2023 14:37, Asmaa Mnebhi wrote: > > On 12/28/2023 12:16 AM, Asmaa Mnebhi wrote: >>> Very rarely, the KSZ9031 fails to complete autonegotiation although it >>> was initiated via phy_start(). As a result, the link stays down. >>> Restarting autonegotiation when in this state solves the issue. >>> >>> Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com> >> >> Is there a Micrel errata associated with this work around that could be >> referenced here? > > Hi Florian, > > No there isn’t. This is based on observations and comparison with the behavior and testing of other PHYs. For example, we don’t see this issue with the Vitesse PHY. > The Microchip KSZ9031 errata documentation lists few link-related errata. May any of these be relevant in your case? If not, please check with Microchip. KSZ9031 isn't new, and most likely we would have seen such reports before, if there's an actual issue. I'd like to avoid that we add code to work around an issue that is specific to your setup. > Thanks. > Asmaa
On 28.12.2023 00:16, Asmaa Mnebhi wrote: > Very rarely, the KSZ9031 fails to complete autonegotiation although it was > initiated via phy_start(). As a result, the link stays down. Restarting > autonegotiation when in this state solves the issue. > The patch isn't addressed to all relevant maintainers. Please use the get_maintainers script. You should use the net/net-next annotation to make clear whether this should be treated as a fix (in this case add a Fixes tag) or net-next material. > Signed-off-by: Asmaa Mnebhi <asmaa@nvidia.com> > --- > v1->v2: > - Use msleep() instead of mdelay() > > drivers/net/phy/micrel.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c > index 08e3915001c3..9952a073413f 100644 > --- a/drivers/net/phy/micrel.c > +++ b/drivers/net/phy/micrel.c > @@ -1475,6 +1475,7 @@ static int ksz9031_get_features(struct phy_device *phydev) > > static int ksz9031_read_status(struct phy_device *phydev) > { > + u8 timeout = 10; > int err; > int regval; > > @@ -1494,6 +1495,22 @@ static int ksz9031_read_status(struct phy_device *phydev) > return genphy_config_aneg(phydev); > } > > + /* KSZ9031's autonegotiation takes normally 4-5 seconds to complete. > + * Occasionally it fails to complete autonegotiation. The workaround is > + * to restart it. > + */ > + if (phydev->autoneg == AUTONEG_ENABLE) { > + while (timeout) { > + if (phy_aneg_done(phydev)) > + break; > + msleep(1000); > + timeout--; It's not too nice to do this synchronously. Even in the non-problem case this will block the phylib state machine for seconds. Better find a way to do it asynchronously. > + }; > + > + if (timeout == 0) > + phy_restart_aneg(phydev); > + } > + > return 0; > } >
> >> Is there a Micrel errata associated with this work around that could > >> be referenced here? > > > > Hi Florian, > > > > No there isn’t. This is based on observations and comparison with the > behavior and testing of other PHYs. For example, we don’t see this issue with > the Vitesse PHY. > > > The Microchip KSZ9031 errata documentation lists few link-related errata. > May any of these be relevant in your case? If not, please check with Microchip. > KSZ9031 isn't new, and most likely we would have seen such reports before, if > there's an actual issue. > I'd like to avoid that we add code to work around an issue that is specific to > your setup. > Thanks Heiner. I went over the errata and there are couple of issues which could result in the link not coming up: 1) Module 1: Device fails to link after Asymmetric Pause capability is set The micrel.c driver already has a workaround for this and I have verified that when our issue reproduces, only symmetric pause is enabled. 2) Module 5: Auto-Negotiation link-up failure / long link-up time due to default FLP interval setting The micrel.c driver also already has a workaround for this. Apart from the erratas, I see that there were other KSZ9031 issues for which workarounds were needed in the kernel: 1) commit d2fd719bcb0e83cb39cfee22ee800f98a56eceb3 net/phy: micrel: Add workaround for bad autoneg 2) commit c1a8d0a3accf64a014d605e6806ce05d1c17adf1 net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround in our case, I have verified that we don’t stumble upon the above 2 bugs (idle error count is 0x0). Our QA sees that autonegotiation fails to complete after rebooting the system > 2000 times. So it is hard to reproduce. Our OOB MAC is connected to the Micrel KSZ9031, which is connected to a switch. I have checked that phy_start() calls phy_start_aneg() and that the genphy_restart_aneg() sets the BMCR_ANRESTART bit. After that, it doesn’t matter how long we wait, the PHY autonegotiation doesn’t complete and the link is down. Restarting autonegotiation a second time solves the issue. I will share this information with Microchip. I hope they can help. Thanks. Asmaa
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 08e3915001c3..9952a073413f 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -1475,6 +1475,7 @@ static int ksz9031_get_features(struct phy_device *phydev) static int ksz9031_read_status(struct phy_device *phydev) { + u8 timeout = 10; int err; int regval; @@ -1494,6 +1495,22 @@ static int ksz9031_read_status(struct phy_device *phydev) return genphy_config_aneg(phydev); } + /* KSZ9031's autonegotiation takes normally 4-5 seconds to complete. + * Occasionally it fails to complete autonegotiation. The workaround is + * to restart it. + */ + if (phydev->autoneg == AUTONEG_ENABLE) { + while (timeout) { + if (phy_aneg_done(phydev)) + break; + msleep(1000); + timeout--; + }; + + if (timeout == 0) + phy_restart_aneg(phydev); + } + return 0; }