Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp208784ybb; Fri, 3 Apr 2020 00:56:12 -0700 (PDT) X-Google-Smtp-Source: APiQypKO7e68CqHqgedFgM6ezojWXFO6h8uHA53rExr4xCLpDJ95NUbuZ0REpye93rIUGMnJRbjq X-Received: by 2002:aca:7213:: with SMTP id p19mr2118839oic.159.1585900571970; Fri, 03 Apr 2020 00:56:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585900571; cv=none; d=google.com; s=arc-20160816; b=CZJ7IRaY6b9Ec7spgtLB/TNjkjKABUM62d79xy4oe7S8Usz6ROuwzcb90oEgGWUAW4 k1VfF/3wToI3pPjB/xUdzt129HWfSs1HSWaSzGZbudsRJ92DT+uqw6AXuwlhWpcsLoYa aCJziZPO+LuPTu1QYOPYcs8Og6ukzUtVwzYIkFumriuntO4oZcpfez/b6AO59GvF4m3+ fJeZ5mMPZToeT0cPJ4WCj04KwhLt7vygHtm4msJ4f/7/A3eoj2WEIosIBhVNXVafWGYt DqWZCLYFYIje3HHujDYQ3QLX/Z7gIYxsCwVzJmXnLge05jNGIZT8zXblOG0x8+20WTAS pSgg== 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 :message-id:date:subject:cc:to:from; bh=GqO6uuZB3xKct6p9rHnm/JmJzGNEXQEqEke9hGULqqg=; b=ySZ+woVqf/t69zWd6rrD7insW34T5N4/EehlQJT0d/GIC4H+GQDRV3ZMYk7Y+Tgjxk miDZnGXZttBeaOhk91rfQ4tk+JE4RQWqEKiZaFeBnlUAzltZfWAmpwRr6zz1Syq22bZk M1wUdf3JVTBss/YZroOAPIyCNJ1P6/FZMK+69rlDpYr7QfLmMX7RoaK3/b5d4APAdWzf uBE26kGMdsw0eYKKmP2baYdu9d8mpd5GPqWtkkswsf7xLW0sZRC3vcqAlaAQzAuNv++o u519tXKBI9koZpAslSiCsllPdIgxNsnoMJPc2iGg6ZBlcP9kZSBC3u+1omORx1oF52Sm P7FA== ARC-Authentication-Results: i=1; mx.google.com; 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 94si3044937otc.25.2020.04.03.00.55.58; Fri, 03 Apr 2020 00:56:11 -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; 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 S2389821AbgDCHxf (ORCPT + 99 others); Fri, 3 Apr 2020 03:53:35 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:58889 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732862AbgDCHxe (ORCPT ); Fri, 3 Apr 2020 03:53:34 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jKH8s-0007k2-Pp; Fri, 03 Apr 2020 09:53:30 +0200 Received: from ore by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1jKH8o-0003QX-Hj; Fri, 03 Apr 2020 09:53:26 +0200 From: Oleksij Rempel To: Andrew Lunn , Florian Fainelli , Heiner Kallweit Cc: Oleksij Rempel , David Jander , "David S. Miller" , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Philippe Schenker , Russell King Subject: [PATCH v1] net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers Date: Fri, 3 Apr 2020 09:53:25 +0200 Message-Id: <20200403075325.10205-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.26.0.rc2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/phy/micrel.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 2ec19e5540bff..05d20343b8161 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -25,6 +25,7 @@ #include #include #include +#include /* Operation Mode Strap Override */ #define MII_KSZPHY_OMSO 0x16 @@ -952,6 +953,12 @@ static int kszphy_resume(struct phy_device *phydev) 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; -- 2.26.0.rc2