Skip to content

Commit

Permalink
Merge branch 'net-phy-Eliminate-unnecessary-soft'
Browse files Browse the repository at this point in the history
Florian Fainelli says:

====================
net: phy: Eliminate unnecessary soft

This patch series eliminates unnecessary software resets of the PHY.
This should hopefully not break anybody's hardware; but I would
appreciate testing to make sure this is is the case.

Sorry for this long email list, I wanted to make sure I reached out to
all people who made changes to the Marvell PHY driver.

Thank you!

Changes since RFT:

- added Tested-by tags from Wang, Dongsheng, Andrew, Chris and Clemens
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 26, 2018
2 parents 71f9b61 + d6ab933 commit 921f432
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 44 deletions.
63 changes: 21 additions & 42 deletions drivers/net/phy/marvell.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static int marvell_set_polarity(struct phy_device *phydev, int polarity)
return err;
}

return 0;
return val != reg;
}

static int marvell_set_downshift(struct phy_device *phydev, bool enable,
Expand All @@ -287,12 +287,15 @@ static int marvell_set_downshift(struct phy_device *phydev, bool enable,

static int marvell_config_aneg(struct phy_device *phydev)
{
int changed = 0;
int err;

err = marvell_set_polarity(phydev, phydev->mdix_ctrl);
if (err < 0)
return err;

changed = err;

err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
MII_M1111_PHY_LED_DIRECT);
if (err < 0)
Expand All @@ -302,7 +305,7 @@ static int marvell_config_aneg(struct phy_device *phydev)
if (err < 0)
return err;

if (phydev->autoneg != AUTONEG_ENABLE) {
if (phydev->autoneg != AUTONEG_ENABLE || changed) {
/* A write to speed/duplex bits (that is performed by
* genphy_config_aneg() call above) must be followed by
* a software reset. Otherwise, the write has no effect.
Expand Down Expand Up @@ -350,42 +353,6 @@ static int m88e1101_config_aneg(struct phy_device *phydev)
return marvell_config_aneg(phydev);
}

static int m88e1111_config_aneg(struct phy_device *phydev)
{
int err;

/* The Marvell PHY has an errata which requires
* that certain registers get written in order
* to restart autonegotiation
*/
err = genphy_soft_reset(phydev);

err = marvell_set_polarity(phydev, phydev->mdix_ctrl);
if (err < 0)
return err;

err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
MII_M1111_PHY_LED_DIRECT);
if (err < 0)
return err;

err = genphy_config_aneg(phydev);
if (err < 0)
return err;

if (phydev->autoneg != AUTONEG_ENABLE) {
/* A write to speed/duplex bits (that is performed by
* genphy_config_aneg() call above) must be followed by
* a software reset. Otherwise, the write has no effect.
*/
err = genphy_soft_reset(phydev);
if (err < 0)
return err;
}

return 0;
}

#ifdef CONFIG_OF_MDIO
/* Set and/or override some configuration registers based on the
* marvell,reg-init property stored in the of_node for the phydev.
Expand Down Expand Up @@ -479,6 +446,7 @@ static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev)

static int m88e1121_config_aneg(struct phy_device *phydev)
{
int changed = 0;
int err = 0;

if (phy_interface_is_rgmii(phydev)) {
Expand All @@ -487,15 +455,26 @@ static int m88e1121_config_aneg(struct phy_device *phydev)
return err;
}

err = genphy_soft_reset(phydev);
err = marvell_set_polarity(phydev, phydev->mdix_ctrl);
if (err < 0)
return err;

err = marvell_set_polarity(phydev, phydev->mdix_ctrl);
changed = err;

err = genphy_config_aneg(phydev);
if (err < 0)
return err;

return genphy_config_aneg(phydev);
if (phydev->autoneg != autoneg || changed) {
/* A software reset is used to ensure a "commit" of the
* changes is done.
*/
err = genphy_soft_reset(phydev);
if (err < 0)
return err;
}

return 0;
}

static int m88e1318_config_aneg(struct phy_device *phydev)
Expand Down Expand Up @@ -2067,7 +2046,7 @@ static struct phy_driver marvell_drivers[] = {
.flags = PHY_HAS_INTERRUPT,
.probe = marvell_probe,
.config_init = &m88e1111_config_init,
.config_aneg = &m88e1111_config_aneg,
.config_aneg = &marvell_config_aneg,
.read_status = &marvell_read_status,
.ack_interrupt = &marvell_ack_interrupt,
.config_intr = &marvell_config_intr,
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,8 +880,6 @@ int phy_init_hw(struct phy_device *phydev)

if (phydev->drv->soft_reset)
ret = phydev->drv->soft_reset(phydev);
else
ret = genphy_soft_reset(phydev);

if (ret < 0)
return ret;
Expand Down

0 comments on commit 921f432

Please sign in to comment.