Skip to content

Commit

Permalink
net: microchip: lan743x: add fixed phy unregister support
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavithra Sathyanarayanan authored and David S. Miller committed Sep 17, 2023
1 parent 037dbd1 commit 1e73cfe
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/ethernet/microchip/lan743x_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1e73cfe

Please sign in to comment.