Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp730pxb; Mon, 8 Feb 2021 13:24:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzc5+6alaGB2rPXWRDrbHrCeAU+ybN8ay/Kl1KqPpSaTK9rpo3O0Iy8Ezz7KZ+e3X71X7xT X-Received: by 2002:a17:906:c081:: with SMTP id f1mr11240329ejz.97.1612819476351; Mon, 08 Feb 2021 13:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612819476; cv=none; d=google.com; s=arc-20160816; b=JYGtuxz+J+wxHX7HNyvW66gUutPbcNUY4PxWzR3jHcnSQd+qXlZFVeiMoasvw9dsoZ kHbEhBG4k4w0c9Arj3n3qPF+8nCX4ANyeMW6XM7S3bAHurAFAh06fghKwyYYoGAGW2jt e857gx+wOlE+HbxiLWlMMJn535nmxV3K6HfgWm90XMPrVFbZlppEmpTu+KwJz6e5yhJn GHXxdJt+bZ9GNcOl8ec5ZWe2VGUCE0UNgRQbDoqbTnO31rN4p5hxpPO6ypXBHYpZhtZn Yx8JuctXNE7AIeXSLbKmb8iiNXi5KjCptl5iFafI2MHp9CaEgtQw5usBl6N31mvs+vsb ahfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=OUh/84sIyniswzX8ah1LDDp71Tfd3ZoLrA0XAN17eZU=; b=zXwohMWzFE+QSEjTYaOuB6T8MBcSDlwoOScdrWdcTOF6VY5ExtTFlDKhzaEESYQkqn PRPcaX7IZuJuSdboUBuSqRRubD20m7g9hWhWL8KafHC24LUXFOhk5/J11kDoDNQw7mZl 3M7EHZIno7I1TR5cAK+xt4jBaLWxJmr37rfXkW2zsXr+9oSw0juBwzpF75OVeCG1gFE3 hPoc1X7WNOENkFXeJS1f+cdmmXXQXyZqDDiRntod1yXDUGJS1wgd/kIaw3KxCdRZn+Pi mB8CcclmmEtWq3B+r8RP7FPWZ02K5HEjEWc0YBoBlE8C7yjJ0RixEiFZKT+d1boMuV/M thVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rOBlwegd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 96si8045403edr.333.2021.02.08.13.24.11; Mon, 08 Feb 2021 13:24:36 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rOBlwegd; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231542AbhBHVXe (ORCPT + 99 others); Mon, 8 Feb 2021 16:23:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbhBHUPC (ORCPT ); Mon, 8 Feb 2021 15:15:02 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73B43C061786; Mon, 8 Feb 2021 12:14:15 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id b3so18735506wrj.5; Mon, 08 Feb 2021 12:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:references:from:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OUh/84sIyniswzX8ah1LDDp71Tfd3ZoLrA0XAN17eZU=; b=rOBlwegdw+wasDBf6XqUsr7z8cAF4XwNo4YBJhPomGCHLaAx8dI9yXJ6FOZRHIruw2 mUhpT1Y7RAhVooVYFKanYan6pZaRSJ0ALGceKovNVZX+Vaym5VgqzBIwVoFTyQjgcu9Y iN/+ftTaVmpIcKcRwbyOyL4jlJILklEpfev42bFOruz/B4/G+8hfYSpgpWJ/7srLXAsj NQLGXGSVUIVqRXSg5m+A+EdQ/S01L3zDTEQZeUvrHhF+2ES+IPNLK/y/zcl8vMy+kpH2 yeMMvYPIumFGm58eav/LAWdPmTNOhr68Fs2rlbzzsSvrk7ZUo7EYaOQvFqNYPMobwxd4 boeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OUh/84sIyniswzX8ah1LDDp71Tfd3ZoLrA0XAN17eZU=; b=rnd6l5zEIFNdOfJB7ak+paAGltNv2w1Hn1FvPjh5V7+9BvJUWJMGdCZcE2nheEzPrW kHjPJpuMW/sedGiP/BIfXBCuFBRZxsIi9BIU9zhymRk19AmjTQiu4ZJ4GwXtJtYns7U1 MEQlZ0L9LwuX+RHUkbF0q1Zbh16GuC5w4CreYWRC+ZuK4PhtDG5NoyvplbLYgl40QFmu 0hbaA5qmV1CpCJr8E06GK5qc7olLbr55e9pA4hO3G0srdmx96HWzWtAeX5SZrRZD0nPn aclLgZYqZhFtqzf68gvaQwEF8nZ01XYVkCBtPS8XyhegRFoqRIPre10NgpwoQeVqOMze o3Ng== X-Gm-Message-State: AOAM532kTSO85HPKnqJBzMlTHd3mtPQSs45mHcyq43rEOw8SuuDhW6lx 6VtsqxptSdZvHzc60KSnlMfW4BnmkJZ0UQ== X-Received: by 2002:adf:e705:: with SMTP id c5mr1768118wrm.39.1612815253875; Mon, 08 Feb 2021 12:14:13 -0800 (PST) Received: from ?IPv6:2003:ea:8f1f:ad00:f9e7:a381:9de9:80df? (p200300ea8f1fad00f9e7a3819de980df.dip0.t-ipconnect.de. [2003:ea:8f1f:ad00:f9e7:a381:9de9:80df]) by smtp.googlemail.com with ESMTPSA id o9sm33181629wrw.81.2021.02.08.12.14.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Feb 2021 12:14:12 -0800 (PST) To: Serge Semin , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S. Miller" , Jakub Kicinski , Joao Pinto , Jose Abreu , Andrew Lunn , Russell King Cc: Serge Semin , Alexey Malahov , Pavel Parkhomenko , Vyacheslav Mitrofanov , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20210208140341.9271-1-Sergey.Semin@baikalelectronics.ru> <20210208140341.9271-2-Sergey.Semin@baikalelectronics.ru> From: Heiner Kallweit Subject: Re: [PATCH 01/20] net: phy: realtek: Fix events detection failure in LPI mode Message-ID: <8300d9ca-b877-860f-a975-731d6d3a93a5@gmail.com> Date: Mon, 8 Feb 2021 21:14:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210208140341.9271-2-Sergey.Semin@baikalelectronics.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.02.2021 15:03, Serge Semin wrote: > 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; > + Nice analysis. Alternatively to duplicating this code piece we could export mmd_phy_indirect(). But up to you. > + 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", >