Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4032606pxb; Mon, 8 Feb 2021 06:27:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOlV/PXJ8F9FIHuhrOlIOfRFDZAGaHVEAEab4Op4AAZik7Qq6SOBMyJW9IYxzzplwWaUm7 X-Received: by 2002:a17:906:296a:: with SMTP id x10mr16933382ejd.240.1612794426145; Mon, 08 Feb 2021 06:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612794426; cv=none; d=google.com; s=arc-20160816; b=gc9Mj/nnmhAhzrefIsLxs1bimhAQ8/v+WxWkECImAE8/E7dCBHJ2/wyosX2OimXkj1 3vEgjziukW9HPOUYq6gnrve/pgi3WnLTtdOQ4ISJ83aAq04tAjOvy176ZoVh0SnBQ1mN n/4Q8Uk1zShCc1p/XWZt3RVFZyNyRFvhZtCnat4Z9YZkCNZ83H4VZh8f3uj2Fc+KrL9s lUaFKmDaAY8pAbyKDQHc/TlHzYaKN6+RBxiC1RODjnbB9cWYVULS/Q0x0b3wm2wyloWT 4VW6HUPaz3UmhEUhtyd7L90ok33thv9aw0E+IIiCSVCm933oxvgixjRl0fEBCaVdhYJ1 sJ+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/UH6OejMI8z/min7/teHujILaeQaEIn3xs5VaQ/M1Is=; b=BWZDqdDPKY6ZUtyR65rgqm+7jN24m7eYUB/PB6bbjQlbF73PVSxZqfaUnHY3946S0r rypv1vsg9raXdJDzQz/8mum9f/cUIHPUzyubdzEguMIvD2/Nk8R2XoYP8k4gkgHZpGU6 mU9/19ETZXoQ8jDxW4Zqqbw600McnXvQzC1ZDr5R9uN2iALmHnf8nutZk9ABJWtRdkJi +COSXW9b8dYu3HD2MWt010zlgInwRqvtVR008z6XjcS5+BCmLLKF7yTBUXt9e++dhO1z dQaBz/ajQdwiEB7nHGwSlBST3h+aApMQ/Rjd7gKa7BW05n+gqmAUJBH2dQQ9VYqapuN8 t1dw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn19si10930299ejc.106.2021.02.08.06.26.42; Mon, 08 Feb 2021 06:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233090AbhBHOW4 (ORCPT + 99 others); Mon, 8 Feb 2021 09:22:56 -0500 Received: from mail.baikalelectronics.com ([87.245.175.226]:57186 "EHLO mail.baikalelectronics.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbhBHOEh (ORCPT ); Mon, 8 Feb 2021 09:04:37 -0500 From: Serge Semin To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Joao Pinto , Jose Abreu , Andrew Lunn , Heiner Kallweit , Russell King CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , , , , Subject: [PATCH 01/20] net: phy: realtek: Fix events detection failure in LPI mode Date: Mon, 8 Feb 2021 17:03:22 +0300 Message-ID: <20210208140341.9271-2-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> References: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It has been noticed that RTL8211E PHY stops detecting and reporting events when EEE is successfully advertised and RXC stopping in LPI is enabled. The freeze happens right after 3.0.10 bit (PC1R "Clock Stop Enable" register) is set. At the same time LED2 stops blinking as if EEE mode has been disabled. Notably the network traffic still flows through the PHY with no obvious problem. Anyway if any MDIO read procedure is performed after the "RXC stop in LPI" mode is enabled PHY gets to be unfrozen, LED2 starts blinking and PHY interrupts happens again. The problem has been noticed on RTL8211E PHY working together with DW GMAC 3.73a MAC and reporting its event via a dedicated IRQ signal. (Obviously the problem has been unnoticed in the polling mode, since it gets naturally fixed by the periodic MDIO read procedure from the PHY status register - BMSR.) In order to fix that problem we suggest to locally re-implement the MMD write method for RTL8211E PHY and perform a dummy read right after the PC1R register is accessed to enable the RXC stopping in LPI mode. Signed-off-by: Serge Semin --- drivers/net/phy/realtek.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 99ecd6c4c15a..cbb86c257aae 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -559,6 +559,42 @@ static int rtl822x_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, return ret; } +static int rtl8211e_write_mmd(struct phy_device *phydev, int devnum, u16 regnum, + u16 val) +{ + int ret; + + /* Write to the MMD registers by using the standard control/data pair. + * The only difference is that we need to perform a dummy read after + * the PC1R.CLKSTOP_EN bit is set. It's required to workaround an issue + * of a partial core freeze so LED2 stops blinking in EEE mode, PHY + * stops detecting the link change and raising IRQs until any read from + * its registers performed. That happens only if and right after the PHY + * is enabled to stop RXC in LPI mode. + */ + ret = __phy_write(phydev, MII_MMD_CTRL, devnum); + if (ret) + return ret; + + ret = __phy_write(phydev, MII_MMD_DATA, regnum); + if (ret) + return ret; + + ret = __phy_write(phydev, MII_MMD_CTRL, devnum | MII_MMD_CTRL_NOINCR); + if (ret) + return ret; + + ret = __phy_write(phydev, MII_MMD_DATA, val); + if (ret) + return ret; + + if (devnum == MDIO_MMD_PCS && regnum == MDIO_CTRL1 && + val & MDIO_PCS_CTRL1_CLKSTOP_EN) + ret = __phy_read(phydev, MII_MMD_DATA); + + return ret < 0 ? ret : 0; +} + static int rtl822x_get_features(struct phy_device *phydev) { int val; @@ -725,6 +761,7 @@ static struct phy_driver realtek_drvs[] = { .resume = genphy_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .write_mmd = rtl8211e_write_mmd, }, { PHY_ID_MATCH_EXACT(0x001cc916), .name = "RTL8211F Gigabit Ethernet", -- 2.29.2