diff mbox series

[net-next,2/3] net: fec: use mac-managed PHY PM

Message ID a34e3ad6-21a8-5151-7beb-5080f4ac102a@gmail.com (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series net: make PHY PM ops a no-op if MAC driver manages PHY PM | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Heiner Kallweit April 7, 2021, 3:52 p.m. UTC
Use the new mac_managed_pm flag to work around an issue with KSZ8081 PHY
that becomes unstable when a soft reset is triggered during aneg.

Reported-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/freescale/fec_main.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Joakim Zhang April 8, 2021, 5:45 a.m. UTC | #1
> -----Original Message-----
> From: Heiner Kallweit <hkallweit1@gmail.com>
> Sent: 2021年4月7日 23:53
> To: Andrew Lunn <andrew@lunn.ch>; Russell King - ARM Linux
> <linux@armlinux.org.uk>; Jakub Kicinski <kuba@kernel.org>; David Miller
> <davem@davemloft.net>; Fugang Duan <fugang.duan@nxp.com>
> Cc: netdev@vger.kernel.org; Joakim Zhang <qiangqing.zhang@nxp.com>
> Subject: [PATCH net-next 2/3] net: fec: use mac-managed PHY PM
> 
> Use the new mac_managed_pm flag to work around an issue with KSZ8081
> PHY that becomes unstable when a soft reset is triggered during aneg.
> 
> Reported-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> b/drivers/net/ethernet/freescale/fec_main.c
> index 3db882322..70aea9c27 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -2048,6 +2048,8 @@ static int fec_enet_mii_probe(struct net_device
> *ndev)
>  	fep->link = 0;
>  	fep->full_duplex = 0;
> 
> +	phy_dev->mac_managed_pm = 1;
> +
>  	phy_attached_info(phy_dev);
> 
>  	return 0;
> @@ -3864,6 +3866,7 @@ static int __maybe_unused fec_resume(struct
> device *dev)
>  		netif_device_attach(ndev);
>  		netif_tx_unlock_bh(ndev);
>  		napi_enable(&fep->napi);
> +		phy_init_hw(ndev->phydev);


For now, I think we doesn't need to re-initialize PHY after MAC resume back, it also can be done by PHY driver if it needed.

Best Regards,
Joakim Zhang
>  		phy_start(ndev->phydev);
>  	}
>  	rtnl_unlock();
> --
> 2.31.1
>
Heiner Kallweit April 8, 2021, 5:59 a.m. UTC | #2
On 08.04.2021 07:45, Joakim Zhang wrote:
> 
>> -----Original Message-----
>> From: Heiner Kallweit <hkallweit1@gmail.com>
>> Sent: 2021年4月7日 23:53
>> To: Andrew Lunn <andrew@lunn.ch>; Russell King - ARM Linux
>> <linux@armlinux.org.uk>; Jakub Kicinski <kuba@kernel.org>; David Miller
>> <davem@davemloft.net>; Fugang Duan <fugang.duan@nxp.com>
>> Cc: netdev@vger.kernel.org; Joakim Zhang <qiangqing.zhang@nxp.com>
>> Subject: [PATCH net-next 2/3] net: fec: use mac-managed PHY PM
>>
>> Use the new mac_managed_pm flag to work around an issue with KSZ8081
>> PHY that becomes unstable when a soft reset is triggered during aneg.
>>
>> Reported-by: Joakim Zhang <qiangqing.zhang@nxp.com>
>> Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>  drivers/net/ethernet/freescale/fec_main.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/freescale/fec_main.c
>> b/drivers/net/ethernet/freescale/fec_main.c
>> index 3db882322..70aea9c27 100644
>> --- a/drivers/net/ethernet/freescale/fec_main.c
>> +++ b/drivers/net/ethernet/freescale/fec_main.c
>> @@ -2048,6 +2048,8 @@ static int fec_enet_mii_probe(struct net_device
>> *ndev)
>>  	fep->link = 0;
>>  	fep->full_duplex = 0;
>>
>> +	phy_dev->mac_managed_pm = 1;
>> +
>>  	phy_attached_info(phy_dev);
>>
>>  	return 0;
>> @@ -3864,6 +3866,7 @@ static int __maybe_unused fec_resume(struct
>> device *dev)
>>  		netif_device_attach(ndev);
>>  		netif_tx_unlock_bh(ndev);
>>  		napi_enable(&fep->napi);
>> +		phy_init_hw(ndev->phydev);
> 
> 
> For now, I think we doesn't need to re-initialize PHY after MAC resume back, it also can be done by PHY driver if it needed.
> 
The PHY PM resume callback (that used to call phy_init_hw) is a no-op now.
So we have to call it from the MAC resume callback. Power to the PHY may be
off during system suspend, therefore it may be reset to power-on defaults.
That's why phy_init_hw() should be called, that includes calling the
PHY drivers config_init callback.

> Best Regards,
> Joakim Zhang
>>  		phy_start(ndev->phydev);
>>  	}
>>  	rtnl_unlock();
>> --
>> 2.31.1
>>
>
Joakim Zhang April 8, 2021, 6:21 a.m. UTC | #3
> -----Original Message-----
> From: Heiner Kallweit <hkallweit1@gmail.com>
> Sent: 2021年4月8日 14:00
> To: Joakim Zhang <qiangqing.zhang@nxp.com>; Andrew Lunn
> <andrew@lunn.ch>; Russell King - ARM Linux <linux@armlinux.org.uk>; Jakub
> Kicinski <kuba@kernel.org>; David Miller <davem@davemloft.net>; Fugang
> Duan <fugang.duan@nxp.com>
> Cc: netdev@vger.kernel.org
> Subject: Re: [PATCH net-next 2/3] net: fec: use mac-managed PHY PM
> 
> On 08.04.2021 07:45, Joakim Zhang wrote:
> >
> >> -----Original Message-----
> >> From: Heiner Kallweit <hkallweit1@gmail.com>
> >> Sent: 2021年4月7日 23:53
> >> To: Andrew Lunn <andrew@lunn.ch>; Russell King - ARM Linux
> >> <linux@armlinux.org.uk>; Jakub Kicinski <kuba@kernel.org>; David
> >> Miller <davem@davemloft.net>; Fugang Duan <fugang.duan@nxp.com>
> >> Cc: netdev@vger.kernel.org; Joakim Zhang <qiangqing.zhang@nxp.com>
> >> Subject: [PATCH net-next 2/3] net: fec: use mac-managed PHY PM
> >>
> >> Use the new mac_managed_pm flag to work around an issue with KSZ8081
> >> PHY that becomes unstable when a soft reset is triggered during aneg.
> >>
> >> Reported-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> >> Tested-by: Joakim Zhang <qiangqing.zhang@nxp.com>
> >> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> >> ---
> >>  drivers/net/ethernet/freescale/fec_main.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >>
> >> diff --git a/drivers/net/ethernet/freescale/fec_main.c
> >> b/drivers/net/ethernet/freescale/fec_main.c
> >> index 3db882322..70aea9c27 100644
> >> --- a/drivers/net/ethernet/freescale/fec_main.c
> >> +++ b/drivers/net/ethernet/freescale/fec_main.c
> >> @@ -2048,6 +2048,8 @@ static int fec_enet_mii_probe(struct net_device
> >> *ndev)
> >>  	fep->link = 0;
> >>  	fep->full_duplex = 0;
> >>
> >> +	phy_dev->mac_managed_pm = 1;
> >> +
> >>  	phy_attached_info(phy_dev);
> >>
> >>  	return 0;
> >> @@ -3864,6 +3866,7 @@ static int __maybe_unused fec_resume(struct
> >> device *dev)
> >>  		netif_device_attach(ndev);
> >>  		netif_tx_unlock_bh(ndev);
> >>  		napi_enable(&fep->napi);
> >> +		phy_init_hw(ndev->phydev);
> >
> >
> > For now, I think we doesn't need to re-initialize PHY after MAC resume back,
> it also can be done by PHY driver if it needed.
> >
> The PHY PM resume callback (that used to call phy_init_hw) is a no-op now.
> So we have to call it from the MAC resume callback. Power to the PHY may be
> off during system suspend, therefore it may be reset to power-on defaults.
> That's why phy_init_hw() should be called, that includes calling the PHY drivers
> config_init callback.

Yes, it is reasonable to invoke phy_init_hw() here to cover more cases. What I want to describe, we have not run into such case for FEC driver before.
At least no one complain it before as I know. Anyway, re-initialize PHY here indeed can benefit more scenarios.

Best Regards,
Joakim Zhang
> > Best Regards,
> > Joakim Zhang
> >>  		phy_start(ndev->phydev);
> >>  	}
> >>  	rtnl_unlock();
> >> --
> >> 2.31.1
> >>
> >
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 3db882322..70aea9c27 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2048,6 +2048,8 @@  static int fec_enet_mii_probe(struct net_device *ndev)
 	fep->link = 0;
 	fep->full_duplex = 0;
 
+	phy_dev->mac_managed_pm = 1;
+
 	phy_attached_info(phy_dev);
 
 	return 0;
@@ -3864,6 +3866,7 @@  static int __maybe_unused fec_resume(struct device *dev)
 		netif_device_attach(ndev);
 		netif_tx_unlock_bh(ndev);
 		napi_enable(&fep->napi);
+		phy_init_hw(ndev->phydev);
 		phy_start(ndev->phydev);
 	}
 	rtnl_unlock();