From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (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 757AF83CAD for ; Thu, 7 Mar 2024 16:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=156.67.10.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709828556; cv=none; b=M5gQRjcensYQmJEuOYpSSjZ5fFXcxe8+2wE0RhPZBbh8eqIWIGNwUZs9ea2rg0wW25rfX2FPi7yXurtKSgiOPSLxrOLl64CCNYPTbQ38LBizBcpezuIV+VGu9uxXYksSoyDlzUY3yLh06zjG0bL8GEQhNrJoREg9KfY4SaU3RvE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709828556; c=relaxed/simple; bh=QUE7z2MxArFhVxmlOACQcSmq5txWjfQB6wj+HZzYcEM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=T/jfv+FRHHm16Vy8pgsbJraAAfcM/oKQrLMuZaYj2qplPipVaKgdgChGnXLzEuZdv+cADPJuTAtu0y0PXe+1Dy2nC6tEA/FJqNLkOcTfPkNwtbuK16lA/Y/m/WSfwMaKSNk9N5QMW5C8XXwDH0qcZ7oy5hp6YNXUlPIeJg2PkEI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b=Vdiknhx0; arc=none smtp.client-ip=156.67.10.101 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="Vdiknhx0" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=K2xrB7zZjamNwhoMEeeZkyZGWpu5h0rZLfg8zzQ/9fk=; b=Vdiknhx0NfYE8OHlxLjxK1pxh9 w3cQTw7vkJqsUrzNC7UeHBmEZBwn6WHt84StqgXPtaSC0odydFrczKBSUjiaYRZAL6sE9BusOsPdB u2qi7CTqFRlrTux9lpUdfoCwYFgcBxrYLuc3F1s8Det4p2tL5KlssACd1EQNGZ8R7jF4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1riGWH-009bNN-RE; Thu, 07 Mar 2024 17:22:57 +0100 Date: Thu, 7 Mar 2024 17:22:57 +0100 From: Andrew Lunn To: "Jan Petrous (OSS)" Cc: "netdev@vger.kernel.org" , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: Re: [RFC PATCH net-next] net: phy: Don't suspend/resume device not in use Message-ID: References: Precedence: bulk X-Mailing-List: netdev@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: > Because such device didn't go through attach process, internal > parameters like phy_dev->interface is set to the default value, which > is not correct for some drivers. Ie. Aquantia PHY AQR107 doesn't > support PHY_INTERFACE_MODE_GMII and trying to use phy_init_hw() > in mdio_bus_phy_resume() ends up with the following error caused > by initial check of supported interfaces in aqr107_config_init(): > > [ 63.927708] Aquantia AQR113C stmmac-0:08: PM: failed to resume: error -19'] > > Signed-off-by: Jan Petrous > --- > drivers/net/phy/phy_device.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 3611ea64875e..30c03ac6b84c 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -311,6 +311,10 @@ static __maybe_unused int mdio_bus_phy_suspend(struct device *dev) > { > struct phy_device *phydev = to_phy_device(dev); > > + /* Don't suspend device if not in use state */ > + if (phydev->state <= PHY_READY) > + return 0; > + > if (phydev->mac_managed_pm) > return 0; If nothing is using it, suspending it does however make sense. It is consuming power, which could be saved by suspending it. It makes the code asymmetrical, but i would throw this hunk away. > > @@ -344,6 +348,10 @@ static __maybe_unused int mdio_bus_phy_resume(struct device *dev) > struct phy_device *phydev = to_phy_device(dev); > int ret; > > + /* Don't resume device which wasn't previously in use state */ > + if (phydev->state <= PHY_READY) > + return 0; > + This is the real fix to your problem. phy_attach_direct() also does a phy_resume(), so if the device does come along and claim the PHY after the resume, it looks like this should work, without the matching suspend. Andrew