From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CA35C433E0 for ; Mon, 8 Feb 2021 21:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 011C264E6F for ; Mon, 8 Feb 2021 21:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234440AbhBHVX7 (ORCPT ); Mon, 8 Feb 2021 16:23:59 -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-Google-Smtp-Source: ABdhPJzKlwzMStUUKKnjrHt7O1icNkl7L0iRGnE9pd6UFl4QxImBc3lc3ymv/8dEALTTipgSSMBoqg== 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", > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BF04C433DB for ; Mon, 8 Feb 2021 20:15:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B9B2B64DBD for ; Mon, 8 Feb 2021 20:15:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9B2B64DBD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:Subject: From:References:To:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VNrAHF8sLhsCAm4J/RddjvR9a+yuRm+1+xYoX74hysQ=; b=e3y0Ckyd3erD/3Wg8rjr8JGhE p9W75MYQJXZJL5w8bBtbVp393rKMsK9l4F9aEeRjpyXF3P55bCa9jGEEnTc6semVoGK5dsHhUDH58 zrZRem6eqmVkNHx72ccxK+FkU54JdcM2xa1UTaq4ONLXBnkCUqXu8ot2Vt+WjRAcIf+G3imlePXAI N62ihHcIfGNj3L6ePc74YXkfZ08BE2FTDa3Wi0vaNJjPQp0sftvivd2WY2xGf3L1ux+XuL29bymUr SeWWg1O9dPfa28oSTeGgSFTY8E1aLuwsL5sD9iinyNTu34nx6VjF6GdnErmVND5PjVd8fe31nomxE 6IHCiJg2w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9CvL-0002lo-GG; Mon, 08 Feb 2021 20:14:19 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9CvJ-0002lP-Bt for linux-arm-kernel@lists.infradead.org; Mon, 08 Feb 2021 20:14:18 +0000 Received: by mail-wr1-x430.google.com with SMTP id n6so5905660wrv.8 for ; Mon, 08 Feb 2021 12:14:14 -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=Q+tGt2BCdPz3iaM9xh1+cKQ5Ms/VnP/CERlxhqMHnAxVSCvnb2aXBD1yYS9q5De4eo VrNUx580dUTvxuaGLdCh/qnLFVX5H8PtF600Fmg1BasTnljMfZwWf+yC9+ZcErSboBQA wjiiG9wui3I9pjcbuoRx7xfpASXaCVsHXPWgPvpIAmZmajku9zOwRLHBWqkF/hpK5cGX DWz110fCCHo41dAGSryFBhqQIAXFSXTSmzPWbw8GJnoPZ7Nz0goUq4WhyoPRNFB1XcCk HWll8poIjfIz35K9s8kemdpReUYrO+085zQd9rjJoYfyktFF3BaHQsixhhqgw7WDCONv 82kA== X-Gm-Message-State: AOAM5329nrVWW0OYQn1fnFewal9WOBSqhKJD/NLZRTJqEAhy5/fqzOV0 aVT+vjonoJ5l881kd7N48atDw0reOiJU0A== X-Google-Smtp-Source: ABdhPJzKlwzMStUUKKnjrHt7O1icNkl7L0iRGnE9pd6UFl4QxImBc3lc3ymv/8dEALTTipgSSMBoqg== 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 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-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_151417_466508_4E9BC61B X-CRM114-Status: GOOD ( 29.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Serge Semin , Alexey Malahov , Vyacheslav Mitrofanov , Pavel Parkhomenko , Maxime Coquelin , linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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", > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel