Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1510044ybb; Sat, 11 Apr 2020 05:17:33 -0700 (PDT) X-Google-Smtp-Source: APiQypJ7QoC4OOMMIzO8fB90Y70I5OKmXJf1FPy1XdxF+L5/3t2ci1TkJNs2yBZlJSZlME8umBJh X-Received: by 2002:a37:4117:: with SMTP id o23mr8141053qka.295.1586607453043; Sat, 11 Apr 2020 05:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586607453; cv=none; d=google.com; s=arc-20160816; b=gA4EUnAYpcZmgeCkuFmoMcqD/OpGNyBFFgIr2qQkUzeRs4kO47HvD38faAkZRmlGzo sf/poSdCZClA5drihVAZi62WVog8EY5X5mpAKhJCsFx+Q89CMcoB3JGjzNRCsghoJlWV rjy94SOch6solm4mAXX1w8bIWfl+4XFMgIwodX+ZD+b2EU/bHCN3wu7CZZJZDt00meTu 8iAoksVAYm19XdMq2k0COBn30t6cL9Uut3PX7Ypji6WCMj1tV43KyvQlDBXRNGYA3Cyd Ldo1bmOMfGAOwVHhgovgMlUHmFiOHqi54U4/kFKf4UshWJcnIV4xDbO8zQ3IvVvhrNl6 4vQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=39rmb4CBtKGpnqLbOhnh4j+4FeGC7Xd1b9IYIioPETo=; b=LGVq54U4pZ8NepoRng+BjjQtlSAUwGE57RPxDn30gmGfrvb4AWrEvO/Y5HXZms/bJD L0/E8BEW9a1PckdnyfF/wZkBRiep42iVEEaTFtXfz0akY1W6Hx/5NK4HreBHwOSElAIr NxmosSu25ZWBrTtEkCCYBNzlMTdjuVzQmFCzqh5NT+uIGijgwFeKJqlvjb+2jIDvA8UK AF32dU1ZOcVw1iVdCDwaLK/J9DCGrSfg6cuYJwIx42TLkvYotsTRV2EqiefeLcUraRjY siPw3zCIFBJay1jTnfhOHtV/T+QyL5jGyR4pMH5w015YiY8YogUaF2bTKWh/wwiX+lRi tc/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=04t5qJfM; 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 s17si2881135qkg.301.2020.04.11.05.17.18; Sat, 11 Apr 2020 05:17: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=@kernel.org header.s=default header.b=04t5qJfM; 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 S1727181AbgDKMPe (ORCPT + 99 others); Sat, 11 Apr 2020 08:15:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:49460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726913AbgDKMPd (ORCPT ); Sat, 11 Apr 2020 08:15:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2E6721556; Sat, 11 Apr 2020 12:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1586607332; bh=+E7nHQNtNavTflFgXsFcr/2lLc/xEjcHb705tglUxoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=04t5qJfME0yLvwhhhiHK5Qqs//CWLKgnrx0JzKyINE+mth5nks9Zj6f65OvVuPZnD EdLv92+lxJbPHSAkDZWQZfVC5C1FSjrQUTjyK32Y9/3xIf7NXeDwMLx1PYN8cxm8Rd Dvz6JPl43+072AS5MXLvBPrmBZktXFILAI2Jaxeg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksij Rempel , Andrew Lunn , Florian Fainelli , "David S. Miller" Subject: [PATCH 4.19 31/54] net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers Date: Sat, 11 Apr 2020 14:09:13 +0200 Message-Id: <20200411115511.571968882@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200411115508.284500414@linuxfoundation.org> References: <20200411115508.284500414@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oleksij Rempel [ Upstream commit 6110dff776f7fa65c35850ef65b41d3b39e2fac2 ] After the power-down bit is cleared, the chip internally triggers a global reset. According to the KSZ9031 documentation, we have to wait at least 1ms for the reset to finish. If the chip is accessed during reset, read will return 0xffff, while write will be ignored. Depending on the system performance and MDIO bus speed, we may or may not run in to this issue. This bug was discovered on an iMX6QP system with KSZ9031 PHY and attached PHY interrupt line. If IRQ was used, the link status update was lost. In polling mode, the link status update was always correct. The investigation showed, that during a read-modify-write access, the read returned 0xffff (while the chip was still in reset) and corresponding write hit the chip _after_ reset and triggered (due to the 0xffff) another reset in an undocumented bit (register 0x1f, bit 1), resulting in the next write being lost due to the new reset cycle. This patch fixes the issue by adding a 1...2 ms sleep after the genphy_resume(). Fixes: 836384d2501d ("net: phy: micrel: Add specific suspend") Signed-off-by: Oleksij Rempel Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/micrel.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -29,6 +29,7 @@ #include #include #include +#include /* Operation Mode Strap Override */ #define MII_KSZPHY_OMSO 0x16 @@ -738,6 +739,12 @@ static int kszphy_resume(struct phy_devi genphy_resume(phydev); + /* After switching from power-down to normal mode, an internal global + * reset is automatically generated. Wait a minimum of 1 ms before + * read/write access to the PHY registers. + */ + usleep_range(1000, 2000); + ret = kszphy_config_reset(phydev); if (ret) return ret;