diff options
author | Quentin Schulz <quentin.schulz@bootlin.com> | 2018-11-23 13:01:51 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-11-24 01:34:40 -0500 |
commit | 3fa528b7682e73e906266bcd43728b8f923bf9b2 (patch) | |
tree | 57494784e7f165aa9f445ecef2d202cb2f04e662 | |
parent | e7b9fb4f545b1f7885e7c642643828f93d3d79c9 (diff) |
net: phy: mscc: fix deadlock in vsc85xx_default_config
The vsc85xx_default_config function called in the vsc85xx_config_init
function which is used by VSC8530, VSC8531, VSC8540 and VSC8541 PHYs
mistakenly calls phy_read and phy_write in-between phy_select_page and
phy_restore_page.
phy_select_page and phy_restore_page actually take and release the MDIO
bus lock and phy_write and phy_read take and release the lock to write
or read to a PHY register.
Let's fix this deadlock by using phy_modify_paged which handles
correctly a read followed by a write in a non-standard page.
Fixes: 6a0bfbbe20b0 ("net: phy: mscc: migrate to phy_select/restore_page functions")
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/phy/mscc.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index a2e59f4f6f01..7cae17517744 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c | |||
@@ -810,17 +810,13 @@ static int vsc85xx_default_config(struct phy_device *phydev) | |||
810 | 810 | ||
811 | phydev->mdix_ctrl = ETH_TP_MDI_AUTO; | 811 | phydev->mdix_ctrl = ETH_TP_MDI_AUTO; |
812 | mutex_lock(&phydev->lock); | 812 | mutex_lock(&phydev->lock); |
813 | rc = phy_select_page(phydev, MSCC_PHY_PAGE_EXTENDED_2); | ||
814 | if (rc < 0) | ||
815 | goto out_unlock; | ||
816 | 813 | ||
817 | reg_val = phy_read(phydev, MSCC_PHY_RGMII_CNTL); | 814 | reg_val = RGMII_RX_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS; |
818 | reg_val &= ~(RGMII_RX_CLK_DELAY_MASK); | 815 | |
819 | reg_val |= (RGMII_RX_CLK_DELAY_1_1_NS << RGMII_RX_CLK_DELAY_POS); | 816 | rc = phy_modify_paged(phydev, MSCC_PHY_PAGE_EXTENDED_2, |
820 | phy_write(phydev, MSCC_PHY_RGMII_CNTL, reg_val); | 817 | MSCC_PHY_RGMII_CNTL, RGMII_RX_CLK_DELAY_MASK, |
818 | reg_val); | ||
821 | 819 | ||
822 | out_unlock: | ||
823 | rc = phy_restore_page(phydev, rc, rc > 0 ? 0 : rc); | ||
824 | mutex_unlock(&phydev->lock); | 820 | mutex_unlock(&phydev->lock); |
825 | 821 | ||
826 | return rc; | 822 | return rc; |