Message ID | 20240229105256.2903095-3-john.ernberg@actia.se |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-86584-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2097:b0:108:e6aa:91d0 with SMTP id gs23csp319905dyb; Thu, 29 Feb 2024 03:15:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUY5RWpuErR7g5Feeijt6otPHwZnz3AVppnMMtcTfNnxjcvG2W8xUbZp5HIPvKt5UBADwZ1ogDQ8nAKgcUZCZS8FShS3A== X-Google-Smtp-Source: AGHT+IHOKojr8lEay06mJWx+HBCoezvCnslhC/KLcI9vh4vKoR1pp9m8mgwU83HJR1H3/JLbHUHW X-Received: by 2002:a17:902:c40c:b0:1dc:177b:1d85 with SMTP id k12-20020a170902c40c00b001dc177b1d85mr2147395plk.27.1709205323296; Thu, 29 Feb 2024 03:15:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709205323; cv=pass; d=google.com; s=arc-20160816; b=vSwLWCbNII+qGEW/hxPaXkDV0h7Yn34VEoVim+3vUKU7m/FuL3FRB9Evn5dIP4udoe 2TdV7qy2kOaluK5aRvejiQA61lo9aHvKohfX9Zy9hQynhCCtggOYMRzr/mREOMWjBFnk MeKg+xlGGt9dkw9dPS8nuhKlHvRHN122MZP0pwK9IBwpiaLYLTeMVmuvGHK7feI7qHvL LD83lJGXRta3+bKwuq+8RJ5KDFEi2vmWH1MxXAWzKrOVu10OTCFRQbs5+sswZRp+uRIS JqGizMbqAZVhvF9yDFqxsLHmUNznPufiLWU90RDhymi0JV10GPuQ0Uxrx0/A8yEXNMEa WHGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:content-language:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=cxg530EYz0QxMvejo+zSZofD2JUgp5nuEw8YF9fW8nY=; fh=CrDPfPlgkeovG7op10fbcGzHGY6r1dnuK3p4aI6pv3Y=; b=X/vNzA2bGIZDWvt0kS2Riod5X6PmTCqOgaP/xkOvZR0XDv7yA+UMKflKtVpNJipLAs sAMI+bv2YCqpfw/buXxjPktso9voN+1bj/8B6lDi6fyhEnAcXOyB3cOYy9/aVSEqXDsW UC1OlM4zzF41TFiTlCf0vSq0bIrjdZQPhvpOBmQ060mceA659J3ZgIRbxECL0Y0bNQwt GJnZfY3e3/FHJulsY5O444xui1lP3Poe15JesWvxaXXevIWPFencNwgkdu5Xkl4nFl+M 9h8SOvm1FotuhY8iD7aM003LgBAvMul5kvQsJ0D9anY+hG34Y9cj8S3f6r1WppH0AIMQ TD0Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=actia.se); spf=pass (google.com: domain of linux-kernel+bounces-86584-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86584-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f13-20020a170902ce8d00b001dc5cf7ab7bsi1151916plg.336.2024.02.29.03.15.22 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 03:15:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-86584-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=actia.se); spf=pass (google.com: domain of linux-kernel+bounces-86584-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-86584-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 25F01B27AC7 for <ouuuleilei@gmail.com>; Thu, 29 Feb 2024 10:54:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5162C7C08E; Thu, 29 Feb 2024 10:53:33 +0000 (UTC) Received: from mail.actia.se (mail.actia.se [212.181.117.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AB517AE4B; Thu, 29 Feb 2024 10:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.181.117.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709204011; cv=none; b=FelLRIKFDG1P6ygUPWqhCnpgSpDHXbGxwi17l0hw+gMRb10TiiCpkBUkTMkjdf/tgDr4de6b114EFMLlGLmuuHcLUXIF10lk9FJhaNHcQS02lqwsm3pQt8W36MSZ0bqTzu322pDiAhejH/Rm+7ApM7TeW02NGN6cn2fiHMq9VVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709204011; c=relaxed/simple; bh=PNwWwvuBJawLAblzdVhyPVN105zb/MBZ+sqrDXI5M8A=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=UJjy9LnjKDsiYK8KQeo1PH2wpj1R35fuBSJq53jqxKtY8f8QH6L/o/JeTKGfqGAozGJsgcus4Q8nzKoRiJLUjH9a0FVWApdaV0qp7LR9bJSPkvQ6XMib3AcpLwGrqzDGg26KCGSHhTGzFjeHvdJ5fBK55BhEhdb4kAMEnaNSwsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=actia.se; spf=pass smtp.mailfrom=actia.se; arc=none smtp.client-ip=212.181.117.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=actia.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=actia.se Received: from S036ANL.actianordic.se (10.12.31.117) by S035ANL.actianordic.se (10.12.31.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 29 Feb 2024 11:53:15 +0100 Received: from S036ANL.actianordic.se ([fe80::e13e:1feb:4ea6:ec69]) by S036ANL.actianordic.se ([fe80::e13e:1feb:4ea6:ec69%4]) with mapi id 15.01.2507.035; Thu, 29 Feb 2024 11:53:15 +0100 From: John Ernberg <john.ernberg@actia.se> To: Wei Fang <wei.fang@nxp.com> CC: Shenwei Wang <shenwei.wang@nxp.com>, Clark Wang <xiaoning.wang@nxp.com>, NXP Linux Team <linux-imx@nxp.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, Heiner Kallweit <hkallweit1@gmail.com>, "netdev@vger.kernel.org" <netdev@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, John Ernberg <john.ernberg@actia.se> Subject: [PATCH net v2 2/2] net: fec: Suspend and resume the PHY Thread-Topic: [PATCH net v2 2/2] net: fec: Suspend and resume the PHY Thread-Index: AQHaav1/Ffv5x8jH7kmxx77YLYL/oA== Date: Thu, 29 Feb 2024 10:53:15 +0000 Message-ID: <20240229105256.2903095-3-john.ernberg@actia.se> References: <20240229105256.2903095-1-john.ernberg@actia.se> In-Reply-To: <20240229105256.2903095-1-john.ernberg@actia.se> Accept-Language: en-US, sv-SE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.43.0 x-esetresult: clean, is OK x-esetid: 37303A2921D72955637266 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792231681051286717 X-GMAIL-MSGID: 1792231681051286717 |
Series |
net: fec: Fixes to suspend / resume with mac_managed_pm
|
|
Commit Message
John Ernberg
Feb. 29, 2024, 10:53 a.m. UTC
PHYs that are always-on will not enter their low power modes otherwise as
they have no regulator to be powered off with.
Since the PHY is picked up via {of_,}phy_connect() and dropped with
phy_disconnect() when the link is brought up and down respectively the only
cases were pm is needed is when the netif is running or or when the link
has never been up.
To deal with the latter case the PHY is suspended on discovery in probe,
since it won't be needed until link up.
Fixes: 557d5dc83f68 ("net: fec: use mac-managed PHY PM")
Signed-off-by: John Ernberg <john.ernberg@actia.se>
---
v2: New patch
---
drivers/net/ethernet/freescale/fec_main.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
Comments
> -----Original Message----- > From: John Ernberg <john.ernberg@actia.se> > Sent: 2024年2月29日 18:53 > To: Wei Fang <wei.fang@nxp.com> > Cc: Shenwei Wang <shenwei.wang@nxp.com>; Clark Wang > <xiaoning.wang@nxp.com>; dl-linux-imx <linux-imx@nxp.com>; David S. > Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; > Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; > Heiner Kallweit <hkallweit1@gmail.com>; netdev@vger.kernel.org; > linux-kernel@vger.kernel.org; John Ernberg <john.ernberg@actia.se> > Subject: [PATCH net v2 2/2] net: fec: Suspend and resume the PHY > > PHYs that are always-on will not enter their low power modes otherwise as > they have no regulator to be powered off with. > > Since the PHY is picked up via {of_,}phy_connect() and dropped with > phy_disconnect() when the link is brought up and down respectively the only > cases were pm is needed is when the netif is running or or when the link nit: where > has never been up. > > To deal with the latter case the PHY is suspended on discovery in probe, > since it won't be needed until link up. > > Fixes: 557d5dc83f68 ("net: fec: use mac-managed PHY PM") I'm not sure whether this commit should be blamed. After checking my local code (not the recent upstream code), fec_suspend() will make the PHY enter suspend mode when calling phy_stop(), the specific logic is fec_suspend() --> phy_stop() --> phy_state_machine() --> phy_suspend (). But the latest upstream code may have changed this logic. I'm sorry that I don't have time to sit down and look at the latest code. > Signed-off-by: John Ernberg <john.ernberg@actia.se> > --- > > v2: New patch > --- > drivers/net/ethernet/freescale/fec_main.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c > b/drivers/net/ethernet/freescale/fec_main.c > index 8decb1b072c5..c5394a4d8491 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -2539,8 +2539,10 @@ static int fec_enet_mii_init(struct > platform_device *pdev) > /* find all the PHY devices on the bus and set mac_managed_pm to true > */ > for (addr = 0; addr < PHY_MAX_ADDR; addr++) { > phydev = mdiobus_get_phy(fep->mii_bus, addr); > - if (phydev) > + if (phydev) { > phydev->mac_managed_pm = true; > + phy_suspend(phydev); > + } > } > > mii_cnt++; > @@ -4631,6 +4633,7 @@ static int __maybe_unused fec_suspend(struct > device *dev) > if (fep->wol_flag & FEC_WOL_FLAG_ENABLE) > fep->wol_flag |= FEC_WOL_FLAG_SLEEP_ON; > phy_stop(ndev->phydev); > + phy_suspend(ndev->phydev); As I aforementioned, if phy_stop() does not suspend the PHY in the latest code, is it more general to restore the suspend operation in phy_stop()? > napi_disable(&fep->napi); > netif_tx_lock_bh(ndev); > netif_device_detach(ndev); > @@ -4716,6 +4719,7 @@ static int __maybe_unused fec_resume(struct > device *dev) > netif_tx_unlock_bh(ndev); > napi_enable(&fep->napi); > phy_init_hw(ndev->phydev); > + phy_resume(ndev->phydev); > phy_start(ndev->phydev); > } > rtnl_unlock(); > -- > 2.43.0
Hi Wei, On 3/1/24 02:49, Wei Fang wrote: >> -----Original Message----- >> From: John Ernberg <john.ernberg@actia.se> >> Sent: 2024年2月29日 18:53 >> To: Wei Fang <wei.fang@nxp.com> >> Cc: Shenwei Wang <shenwei.wang@nxp.com>; Clark Wang >> <xiaoning.wang@nxp.com>; dl-linux-imx <linux-imx@nxp.com>; David S. >> Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; >> Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; >> Heiner Kallweit <hkallweit1@gmail.com>; netdev@vger.kernel.org; >> linux-kernel@vger.kernel.org; John Ernberg <john.ernberg@actia.se> >> Subject: [PATCH net v2 2/2] net: fec: Suspend and resume the PHY >> >> PHYs that are always-on will not enter their low power modes otherwise as >> they have no regulator to be powered off with. >> >> Since the PHY is picked up via {of_,}phy_connect() and dropped with >> phy_disconnect() when the link is brought up and down respectively the only >> cases were pm is needed is when the netif is running or or when the link > nit: where > >> has never been up. >> >> To deal with the latter case the PHY is suspended on discovery in probe, >> since it won't be needed until link up. >> >> Fixes: 557d5dc83f68 ("net: fec: use mac-managed PHY PM") > I'm not sure whether this commit should be blamed. After checking my local > code (not the recent upstream code), fec_suspend() will make the PHY enter > suspend mode when calling phy_stop(), the specific logic is fec_suspend() --> > phy_stop() --> phy_state_machine() --> phy_suspend (). But the latest upstream > code may have changed this logic. I'm sorry that I don't have time to sit down > and look at the latest code. I missed this flow, and also didn't see it take place when I look at the MDIO traffic. But the code has been there since 2013. I will check why that isn't happening. Thanks! // John Ernberg
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 8decb1b072c5..c5394a4d8491 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -2539,8 +2539,10 @@ static int fec_enet_mii_init(struct platform_device *pdev) /* find all the PHY devices on the bus and set mac_managed_pm to true */ for (addr = 0; addr < PHY_MAX_ADDR; addr++) { phydev = mdiobus_get_phy(fep->mii_bus, addr); - if (phydev) + if (phydev) { phydev->mac_managed_pm = true; + phy_suspend(phydev); + } } mii_cnt++; @@ -4631,6 +4633,7 @@ static int __maybe_unused fec_suspend(struct device *dev) if (fep->wol_flag & FEC_WOL_FLAG_ENABLE) fep->wol_flag |= FEC_WOL_FLAG_SLEEP_ON; phy_stop(ndev->phydev); + phy_suspend(ndev->phydev); napi_disable(&fep->napi); netif_tx_lock_bh(ndev); netif_device_detach(ndev); @@ -4716,6 +4719,7 @@ static int __maybe_unused fec_resume(struct device *dev) netif_tx_unlock_bh(ndev); napi_enable(&fep->napi); phy_init_hw(ndev->phydev); + phy_resume(ndev->phydev); phy_start(ndev->phydev); } rtnl_unlock();