public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v1] net: microchip: lan743x: add fixed phy unregister support
@ 2023-09-14  6:17 Pavithra Sathyanarayanan
  2023-09-17 11:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Pavithra Sathyanarayanan @ 2023-09-14  6:17 UTC (permalink / raw)
  To: netdev, linux-kernel
  Cc: bryan.whitehead, UNGLinuxDriver, davem, edumazet, kuba, pabeni

When operating in fixed phy mode and if there is repeated open/close
phy test cases, everytime the fixed phy is registered as a new phy
which leads to overrun after 32 iterations. It is solved by adding
fixed_phy_unregister() in the phy_close path.

In phy_close path, netdev->phydev cannot be used directly in
fixed_phy_unregister() due to two reasons,
    - netdev->phydev is set to NULL in phy_disconnect()
    - fixed_phy_unregister() can be called only after phy_disconnect()
So saving the netdev->phydev in local variable 'phydev' and
passing it to phy_disconnect().

Signed-off-by: Pavithra Sathyanarayanan <Pavithra.Sathyanarayanan@microchip.com>
---
 drivers/net/ethernet/microchip/lan743x_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index c81cdeb4d4e7..f940895b14e8 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1466,9 +1466,15 @@ static void lan743x_phy_link_status_change(struct net_device *netdev)
 static void lan743x_phy_close(struct lan743x_adapter *adapter)
 {
 	struct net_device *netdev = adapter->netdev;
+	struct phy_device *phydev = netdev->phydev;
 
 	phy_stop(netdev->phydev);
 	phy_disconnect(netdev->phydev);
+
+	/* using phydev here as phy_disconnect NULLs netdev->phydev */
+	if (phy_is_pseudo_fixed_link(phydev))
+		fixed_phy_unregister(phydev);
+
 }
 
 static void lan743x_phy_interface_select(struct lan743x_adapter *adapter)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next v1] net: microchip: lan743x: add fixed phy unregister support
  2023-09-14  6:17 [PATCH net-next v1] net: microchip: lan743x: add fixed phy unregister support Pavithra Sathyanarayanan
@ 2023-09-17 11:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-09-17 11:00 UTC (permalink / raw)
  To: Pavithra Sathyanarayanan
  Cc: netdev, linux-kernel, bryan.whitehead, UNGLinuxDriver, davem,
	edumazet, kuba, pabeni

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 14 Sep 2023 11:47:37 +0530 you wrote:
> When operating in fixed phy mode and if there is repeated open/close
> phy test cases, everytime the fixed phy is registered as a new phy
> which leads to overrun after 32 iterations. It is solved by adding
> fixed_phy_unregister() in the phy_close path.
> 
> In phy_close path, netdev->phydev cannot be used directly in
> fixed_phy_unregister() due to two reasons,
>     - netdev->phydev is set to NULL in phy_disconnect()
>     - fixed_phy_unregister() can be called only after phy_disconnect()
> So saving the netdev->phydev in local variable 'phydev' and
> passing it to phy_disconnect().
> 
> [...]

Here is the summary with links:
  - [net-next,v1] net: microchip: lan743x: add fixed phy unregister support
    https://git.kernel.org/netdev/net-next/c/1e73cfe85952

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-17 11:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14  6:17 [PATCH net-next v1] net: microchip: lan743x: add fixed phy unregister support Pavithra Sathyanarayanan
2023-09-17 11:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox