From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 101D72E2299; Wed, 28 Jan 2026 15:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769614828; cv=none; b=VEE96yrF2xT68sL4FvIgHGVGEa2/fuVwG7sx6V3aaHAodBdhWkZOvzpWKi5LUtU/eBhgZ/rWoF0GHKWnv9mdTU6NfvZf4uFdS7hwbbHskLFhRGRR4YgRjRfwx0BcZc65jyUEMWISW8J9ni645L9k9/oXMTYC17jaK0pg68aotsA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769614828; c=relaxed/simple; bh=xRgGuSE53cqGx8RSeO9sdv8zRLAhUaQ/pvL0ljeqGzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XtdNO8y2mCXSIRvbAD0+6qNI4nPzXVE5uDiSTHBqqgEqovE1+PCjwq7qDupGipLWgi5whw+JmkRie0FciYdDod+uglYsb1SVXd7IY5hPnAL39OwzRg/TO3kcp5MNBjQ9oAh5beDmcodFrgpnaFNfjLp98Nm4+9Ov2nRjsCjkZwo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=SW42jWSp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="SW42jWSp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE2FDC4CEF7; Wed, 28 Jan 2026 15:40:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769614827; bh=xRgGuSE53cqGx8RSeO9sdv8zRLAhUaQ/pvL0ljeqGzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SW42jWSpXlQ7fNSFZkWDD1Y5M1ih8yfbgMq3cggPFGbOmS+L+wTURM0ljVAy7KHFJ 6fDuGHmjnbJnSIcEeunB1ZQ42V/tYwojaTQCfmB3j1lMH18O55URqECtU3y/pUHIND 2hSktrkv+7GGI5PpS6tsxCTktyCQjKQjohTrHYW4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xu Yang , "Russell King (Oracle)" , Vladimir Oltean , Jakub Kicinski , Rajani Kantha <681739313@139.com> Subject: [PATCH 6.6 254/254] net: phy: fix phy_uses_state_machine() Date: Wed, 28 Jan 2026 16:23:50 +0100 Message-ID: <20260128145353.940562420@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260128145344.698118637@linuxfoundation.org> References: <20260128145344.698118637@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Russell King (Oracle)" [ Upstream commit e0d1c55501d377163eb57feed863777ed1c973ad ] The blamed commit changed the conditions which phylib uses to stop and start the state machine in the suspend and resume paths, and while improving it, has caused two issues. The original code used this test: phydev->attached_dev && phydev->adjust_link and if true, the paths would handle the PHY state machine. This test evaluates true for normal drivers that are using phylib directly while the PHY is attached to the network device, but false in all other cases, which include the following cases: - when the PHY has never been attached to a network device. - when the PHY has been detached from a network device (as phy_detach() sets phydev->attached_dev to NULL, phy_disconnect() calls phy_detach() and additionally sets phydev->adjust_link NULL.) - when phylink is using the driver (as phydev->adjust_link is NULL.) Only the third case was incorrect, and the blamed commit attempted to fix this by changing this test to (simplified for brevity, see phy_uses_state_machine()): phydev->phy_link_change == phy_link_change ? phydev->attached_dev && phydev->adjust_link : true However, this also incorrectly evaluates true in the first two cases. Fix the first case by ensuring that phy_uses_state_machine() returns false when phydev->phy_link_change is NULL. Fix the second case by ensuring that phydev->phy_link_change is set to NULL when phy_detach() is called. Reported-by: Xu Yang Link: https://lore.kernel.org/r/20250806082931.3289134-1-xu.yang_2@nxp.com Fixes: fc75ea20ffb4 ("net: phy: allow MDIO bus PM ops to start/stop state machine for phylink-controlled PHY") Signed-off-by: Russell King (Oracle) Reviewed-by: Vladimir Oltean Link: https://patch.msgid.link/E1uvMEz-00000003Aoe-3qWe@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski Signed-off-by: Rajani Kantha <681739313@139.com> Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/phy_device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -304,8 +304,7 @@ static bool phy_uses_state_machine(struc if (phydev->phy_link_change == phy_link_change) return phydev->attached_dev && phydev->adjust_link; - /* phydev->phy_link_change is implicitly phylink_phy_change() */ - return true; + return !!phydev->phy_link_change; } static bool mdio_bus_phy_may_suspend(struct phy_device *phydev) @@ -1853,6 +1852,8 @@ void phy_detach(struct phy_device *phyde phydev->attached_dev->phydev = NULL; phydev->attached_dev = NULL; } + + phydev->phy_link_change = NULL; phydev->phylink = NULL; if (!phydev->is_on_sfp_module)