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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6BE3EC46467 for ; Tue, 3 Jan 2023 14:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mw6xVJ7s6oun7G23qOVHzzOcS1ZmZb3PDwHRmwF9ldA=; b=xctZ8B5rkgnE07 zkmyYfSS8PmkMtSBtuXeZXrLQ1Nf0pFRu7WsjCmE8lGomswGow/0jp0nFmhVwzROEyj4pY/YVg7GC DUbHgUqvkev/IGMz3HVqQOVTkNNL5UlEPZD+LC887rMeszXTkz9hmnFIITISYsngSKNJX3N3IJdiP S7F/ihPMuf1MjSpZdzibhiYNuQrh6zXf7iCU8pOKIIB+8DlTyMYnbnVl5mH6xxlH3hMV43vTOSxf6 62wjXFr7cLPLpmapXVbh2hYF60cDEiAJvNlzkF1RxAvM2VoAzPPHU0l5TA4jr/uC+rt5nAggLoRaF HLggiTjlaGpGzgHigGxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCiYN-0026f6-DM; Tue, 03 Jan 2023 14:46:13 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCdul-000WMv-IC for linux-arm-kernel@lists.infradead.org; Tue, 03 Jan 2023 09:49:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9vieuoe0VgancC+Vnw4hbAtvMmDWGV3XLVPMbJmvafw=; b=DjP3AFWSIgtAoq9nrYBevpsOux 8+IfN83nBYtYLtUipjJF0PAXFkh4+KLpe4+C9WMwHPwnIhUNLwS8j8uzlyk2eZD/Q4R8OoaqgmKrL fgjU/hxE+F90CfGSvJSNY9v7hXKqLJZTQLxfYAko6A3O7NjZ64iC5kXu+NRjoF/jG9YsQajZpRkzB QqNObvOdiEpWXtfQXAsA03wndml1yT1FO3ELg7nXGGfEygUW+hG0OGKzwG3+81hyxxeNBrdR+Hvz7 Lo5WgayyUY7/D3N9okFGQWjhg/SsUhj9HTBvhi9d658sx/+sYwE1kxttlAKMa2WNM2ju8FwG1hb/Y nlDQQ89A==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:35898) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pCdsa-0005AO-H6; Tue, 03 Jan 2023 09:46:44 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pCdsU-0001x7-ML; Tue, 03 Jan 2023 09:46:38 +0000 Date: Tue, 3 Jan 2023 09:46:38 +0000 From: "Russell King (Oracle)" To: Clark Wang Cc: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] net: phylink: add a function to resume phy alone to fix resume issue with WoL enabled Message-ID: References: <20221221080144.2549125-1-xiaoning.wang@nxp.com> <20221221080144.2549125-2-xiaoning.wang@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221221080144.2549125-2-xiaoning.wang@nxp.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230103_014859_662130_2A7CC179 X-CRM114-Status: GOOD ( 27.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Wed, Dec 21, 2022 at 04:01:43PM +0800, Clark Wang wrote: > Issue we met: > On some platforms, mac cannot work after resumed from the suspend with WoL > enabled. > > The cause of the issue: > 1. phylink_resolve() is in a workqueue which will not be executed immediately. > This is the call sequence: > phylink_resolve()->phylink_link_up()->pl->mac_ops->mac_link_up() > For stmmac driver, mac_link_up() will set the correct speed/duplex... > values which are from link_state. > 2. In stmmac_resume(), it will call stmmac_hw_setup() after called the > phylink_resume(), because mac need phy rx_clk to do the reset. > stmmac_core_init() is called in function stmmac_hw_setup(), which will > reset the mac and set the speed/duplex... to default value. > Conclusion: Because phylink_resolve() cannot determine when it is called, it > cannot be guaranteed to be called after stmmac_core_init(). > Once stmmac_core_init() is called after phylink_resolve(), > the mac will be misconfigured and cannot be used. > > In order to avoid this problem, add a function called phylink_phy_resume() > to resume phy separately. This eliminates the need to call phylink_resume() > before stmmac_hw_setup(). > > Add another judgement before called phy_start() in phylink_start(). This way > phy_start() will not be called multiple times when resumes. At the same time, > it may not affect other drivers that do not use phylink_phy_resume(). > > Signed-off-by: Clark Wang > --- > drivers/net/phy/phylink.c | 21 ++++++++++++++++++++- > include/linux/phylink.h | 1 + > 2 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 09cc65c0da93..5bab59142579 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -1939,7 +1939,7 @@ void phylink_start(struct phylink *pl) > } > if (poll) > mod_timer(&pl->link_poll, jiffies + HZ); > - if (pl->phydev) > + if (pl->phydev && pl->phydev->state < PHY_UP) I'm really not happy with this - not only does this subvert the checks in phy_start(), it's a layering violation, and it delves into internals of phylib in an unprotected way. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel