Skip to content

Commit d5c5093

Browse files
fancerkuba-moo
authored andcommitted
net: stmmac: Add dedicated XPCS cleanup method
Currently the XPCS handler destruction is performed in the stmmac_mdio_unregister() method. It doesn't look good because the handler isn't originally created in the corresponding protagonist stmmac_mdio_unregister(), but in the stmmac_xpcs_setup() function. In order to have more coherent MDIO and XPCS setup/cleanup procedures, let's move the DW XPCS destruction to the dedicated stmmac_pcs_clean() method. This method will also be used to cleanup PCS hardware using the pcs_exit() callback that will be introduced to stmmac in a subsequent patch. Signed-off-by: Serge Semin <[email protected]> Co-developed-by: Romain Gantois <[email protected]> Signed-off-by: Romain Gantois <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Reviewed-by: Hariprasad Kelam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ab55887 commit d5c5093

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ int stmmac_mdio_unregister(struct net_device *ndev);
361361
int stmmac_mdio_register(struct net_device *ndev);
362362
int stmmac_mdio_reset(struct mii_bus *mii);
363363
int stmmac_xpcs_setup(struct mii_bus *mii);
364+
void stmmac_pcs_clean(struct net_device *ndev);
364365
void stmmac_set_ethtool_ops(struct net_device *netdev);
365366

366367
int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags);

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7789,8 +7789,9 @@ int stmmac_dvr_probe(struct device *device,
77897789

77907790
error_netdev_register:
77917791
phylink_destroy(priv->phylink);
7792-
error_xpcs_setup:
77937792
error_phy_setup:
7793+
stmmac_pcs_clean(ndev);
7794+
error_xpcs_setup:
77947795
if (priv->hw->pcs != STMMAC_PCS_TBI &&
77957796
priv->hw->pcs != STMMAC_PCS_RTBI)
77967797
stmmac_mdio_unregister(ndev);
@@ -7832,6 +7833,9 @@ void stmmac_dvr_remove(struct device *dev)
78327833
if (priv->plat->stmmac_rst)
78337834
reset_control_assert(priv->plat->stmmac_rst);
78347835
reset_control_assert(priv->plat->stmmac_ahb_rst);
7836+
7837+
stmmac_pcs_clean(ndev);
7838+
78357839
if (priv->hw->pcs != STMMAC_PCS_TBI &&
78367840
priv->hw->pcs != STMMAC_PCS_RTBI)
78377841
stmmac_mdio_unregister(ndev);

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,17 @@ int stmmac_xpcs_setup(struct mii_bus *bus)
523523
return 0;
524524
}
525525

526+
void stmmac_pcs_clean(struct net_device *ndev)
527+
{
528+
struct stmmac_priv *priv = netdev_priv(ndev);
529+
530+
if (!priv->hw->xpcs)
531+
return;
532+
533+
xpcs_destroy(priv->hw->xpcs);
534+
priv->hw->xpcs = NULL;
535+
}
536+
526537
/**
527538
* stmmac_mdio_register
528539
* @ndev: net device structure
@@ -679,9 +690,6 @@ int stmmac_mdio_unregister(struct net_device *ndev)
679690
if (!priv->mii)
680691
return 0;
681692

682-
if (priv->hw->xpcs)
683-
xpcs_destroy(priv->hw->xpcs);
684-
685693
mdiobus_unregister(priv->mii);
686694
priv->mii->priv = NULL;
687695
mdiobus_free(priv->mii);

0 commit comments

Comments
 (0)