From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 085803B6379; Thu, 9 Apr 2026 10:43:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775731386; cv=none; b=lyigSP7Zm5vL8tIfFAnwlenBDp70sUU7E7/yqC9Ke9YGAL64sRItcMbi/VS1sFplc8nARQAKgSEQnLh49mx6jljgcbSwg2bpW8809KeraA7OrhbNtEWrxi2/d2TBnUDGILRmqK5MnLiPVeDbFZezUE1wYR7zNH2k+E1ZNzHL1GQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775731386; c=relaxed/simple; bh=VZPyNjsPHkfvXkTrFGRyWHslccPlQvVyBCHMlj+YG4Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bR1z2+Oemte2/ovYgo+dxrEddTOQiNVNU4IjdJuTFLB7Vg7Ev1hup5aXU5IDmVW9dD/gUya2F3MUVGfEDIKkJoIl0v0H27dNsYBXVt+fV9IXNLP71pBety+MA1bgT0L2UnO7UQZ8ps/9OlNPgBacy5SpWGb5+QEHguF4ICq91vI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=0qUYsqrO; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="0qUYsqrO" 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=TLN9vggo80g7NSDym4IU8WuBR7pk3Ud+NWcSTee47r0=; b=0qUYsqrOpu7kzCjmePUmbGaqsx J2pUKHjH73kC3dyIWW09mkHBxCFDnJYoiSTcuG5VVjCW3/iP17VErmbp6lj5yYWyD0ktdky9ztODQ gykwt3NIWIrlMrt0mdCL6KQ7CX6BDfviVedyXHjPHig0X8Ai8WOqnjH7p9VOX7AyGpUeAqXaqq336 voBcfam0kIbmymEPnsIjAUqfpd0OKU3a24PERp37Da2iB1Pq+PNhJwetcX1GvfdyfiZ6CIRohtGN6 OUWmGWqixNIZmPgpo/lmTtR1BZMZLFKS2A2TRli6GzRoVu7Iu2o8ggTIJCZ5sA/nYhbZDOEN4iO7+ QF1UKgtw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:51782) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wAmqf-000000003QE-3MSk; Thu, 09 Apr 2026 11:42:57 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.98.2) (envelope-from ) id 1wAmqe-000000004K4-01nn; Thu, 09 Apr 2026 11:42:56 +0100 Date: Thu, 9 Apr 2026 11:42:55 +0100 From: "Russell King (Oracle)" To: Ovidiu Panait Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, biju.das.jz@bp.renesas.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: Re: [PATCH net v2 1/2] net: phylink: call phy_init_hw() in phylink resume path Message-ID: References: <20260409095633.70973-1-ovidiu.panait.rb@renesas.com> <20260409095633.70973-2-ovidiu.panait.rb@renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260409095633.70973-2-ovidiu.panait.rb@renesas.com> Sender: Russell King (Oracle) On Thu, Apr 09, 2026 at 09:56:32AM +0000, Ovidiu Panait wrote: > When mac_managed_pm flag is set, mdio_bus_phy_resume() is skipped, > so phy_init_hw(), which performs soft_reset and config_init, is not > called during resume. > > This is inconsistent with the non-mac_managed_pm path, where > mdio_bus_phy_resume() calls phy_init_hw() before phy_resume() > on every resume. > > Add phy_init_hw() calls in both phylink_prepare_resume() and > phylink_resume(), to ensure that the PHY state is the same as > when the PHY is resumed via the MDIO bus. > > Signed-off-by: Ovidiu Panait > --- > drivers/net/phy/phylink.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 087ac63f9193..c302126009f6 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -2669,8 +2669,10 @@ void phylink_prepare_resume(struct phylink *pl) > * then resume the PHY. Note that 802.3 allows PHYs 500ms before > * the clock meets requirements. We do not implement this delay. > */ > - if (pl->config->mac_requires_rxc && phydev && phydev->suspended) > + if (pl->config->mac_requires_rxc && phydev && phydev->suspended) { > + phy_init_hw(phydev); > phy_resume(phydev); I'm going to make an alternative suggestion - should we combine phy_init_hw() and phy_resume() to ensure that all MAC drivers that call phy_resume() correctly initialise the PHY first? Looking at the callers of phy_resume(): - drivers/net/ethernet/nxp/lpc_eth.c - calls phy_resume() from lpc_eth_open() but no call to phy_init_hw(). Not used in suspend/resume paths, so presumably uses the built-in phylib handling that does call phy_init_hw() before phy_resume(). - drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c - suspends and then immediately resumes the PHY before enabling loopback. Seems like a PHY workaround that should've been handled in the PHY driver. Suspends the PHY when loopback is disabled (which looks buggy.) - drivers/net/ethernet/hisilicon/hns/hns_ethtool.c - resumes the PHY when enabling loopback and suspends the PHY when loopback is disabled. (what if the netdev is already up? Also looks buggy to me.) - drivers/net/ethernet/broadcom/genet/bcmgenet.c - bcmgenet_resume() calls phy_init_hw() before a conditional call to phy_resume(). I don't see a matching call to phy_suspend(). If the bcmgenet device may wakeup the system, then wouldn't the PHY configuration be preserved over suspend/resume making the call to phy_init_hw() also unnecessary if device_may_wakeup(d) returns true? - drivers/net/ethernet/broadcom/bcmsysport.c - no call to phy_init_hw() before phy_resume(). - drivers/net/ethernet/realtek/r8169_main.c - calls phy_init_hw() immediately before phy_resume(). -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!