diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2016-11-22 22:55:31 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-24 22:02:32 +0100 |
commit | 4b65246b427152fc7e8e1f673d3f0dc7582a89af (patch) | |
tree | 28220d54e14d9ea7026adcdf13628d4815aa93ce /drivers/net/phy | |
parent | Merge branch 'mlx5-next' (diff) | |
download | linux-4b65246b427152fc7e8e1f673d3f0dc7582a89af.tar.xz linux-4b65246b427152fc7e8e1f673d3f0dc7582a89af.zip |
ethtool: Protect {get, set}_phy_tunable with PHY device mutex
PHY drivers should be able to rely on the caller of {get,set}_tunable to
have acquired the PHY device mutex, in order to both serialize against
concurrent calls of these functions, but also against PHY state machine
changes. All ethtool PHY-level functions do this, except
{get,set}_tunable, so we make them consistent here as well.
We need to update the Microsemi PHY driver in the same commit to avoid
introducing either deadlocks, or lack of proper locking.
Fixes: 968ad9da7e0e ("ethtool: Implements ETHTOOL_PHY_GTUNABLE/ETHTOOL_PHY_STUNABLE")
Fixes: 310d9ad57ae0 ("net: phy: Add downshift get/set support in Microsemi PHYs driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Allan W. Nielsen <allan.nielsen@microsemi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy')
-rw-r--r-- | drivers/net/phy/mscc.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/net/phy/mscc.c b/drivers/net/phy/mscc.c index 92018ba6209e..7a3740c7bf6d 100644 --- a/drivers/net/phy/mscc.c +++ b/drivers/net/phy/mscc.c @@ -115,10 +115,9 @@ static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count) int rc; u16 reg_val; - mutex_lock(&phydev->lock); rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED); if (rc != 0) - goto out_unlock; + goto out; reg_val = phy_read(phydev, MSCC_PHY_ACTIPHY_CNTL); reg_val &= DOWNSHIFT_CNTL_MASK; @@ -128,9 +127,7 @@ static int vsc85xx_downshift_get(struct phy_device *phydev, u8 *count) *count = ((reg_val & ~DOWNSHIFT_EN) >> DOWNSHIFT_CNTL_POS) + 2; rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD); -out_unlock: - mutex_unlock(&phydev->lock); - +out: return rc; } @@ -150,23 +147,20 @@ static int vsc85xx_downshift_set(struct phy_device *phydev, u8 count) count = (((count - 2) << DOWNSHIFT_CNTL_POS) | DOWNSHIFT_EN); } - mutex_lock(&phydev->lock); rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_EXTENDED); if (rc != 0) - goto out_unlock; + goto out; reg_val = phy_read(phydev, MSCC_PHY_ACTIPHY_CNTL); reg_val &= ~(DOWNSHIFT_CNTL_MASK); reg_val |= count; rc = phy_write(phydev, MSCC_PHY_ACTIPHY_CNTL, reg_val); if (rc != 0) - goto out_unlock; + goto out; rc = vsc85xx_phy_page_set(phydev, MSCC_PHY_PAGE_STANDARD); -out_unlock: - mutex_unlock(&phydev->lock); - +out: return rc; } |