diff options
author | Lennert Buytenhek <buytenh@wantstofly.org> | 2008-08-23 23:41:09 -0400 |
---|---|---|
committer | Lennert Buytenhek <buytenh@marvell.com> | 2008-09-05 00:33:57 -0400 |
commit | 2b3ba0e3ea3aa9383d38cf95fabd24ca35483784 (patch) | |
tree | eebac8125ec4b2d088c179ee211e6cd96a1036fa /drivers | |
parent | 9da7874575468ad3b126d1b9197b6ae387950bb4 (diff) |
mv643xx_eth: switch ->phy_lock from a spinlock to a mutex
Since commit 81600eea98789da09a32de69ca9d3be8b9503c54 ("mv643xx_eth:
use auto phy polling for configuring (R)(G)MII interface"),
mv643xx_eth no longer does SMI accesses from interrupt context. The
only other callers that do SMI accesses all do them from process
context, which means we can switch the PHY lock from a spinlock to a
mutex, and get rid of the extra locking in some ethtool methods.
Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/mv643xx_eth.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index 2f6cec4e8499..2d434017a670 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c | |||
@@ -251,7 +251,7 @@ struct mv643xx_eth_shared_private { | |||
251 | /* | 251 | /* |
252 | * Protects access to SMI_REG, which is shared between ports. | 252 | * Protects access to SMI_REG, which is shared between ports. |
253 | */ | 253 | */ |
254 | spinlock_t phy_lock; | 254 | struct mutex phy_lock; |
255 | 255 | ||
256 | /* | 256 | /* |
257 | * Per-port MBUS window access register value. | 257 | * Per-port MBUS window access register value. |
@@ -988,11 +988,10 @@ static void smi_reg_read(struct mv643xx_eth_private *mp, unsigned int addr, | |||
988 | unsigned int reg, unsigned int *value) | 988 | unsigned int reg, unsigned int *value) |
989 | { | 989 | { |
990 | void __iomem *smi_reg = mp->shared_smi->base + SMI_REG; | 990 | void __iomem *smi_reg = mp->shared_smi->base + SMI_REG; |
991 | unsigned long flags; | ||
992 | int i; | 991 | int i; |
993 | 992 | ||
994 | /* the SMI register is a shared resource */ | 993 | /* the SMI register is a shared resource */ |
995 | spin_lock_irqsave(&mp->shared_smi->phy_lock, flags); | 994 | mutex_lock(&mp->shared_smi->phy_lock); |
996 | 995 | ||
997 | /* wait for the SMI register to become available */ | 996 | /* wait for the SMI register to become available */ |
998 | for (i = 0; readl(smi_reg) & SMI_BUSY; i++) { | 997 | for (i = 0; readl(smi_reg) & SMI_BUSY; i++) { |
@@ -1016,7 +1015,7 @@ static void smi_reg_read(struct mv643xx_eth_private *mp, unsigned int addr, | |||
1016 | 1015 | ||
1017 | *value = readl(smi_reg) & 0xffff; | 1016 | *value = readl(smi_reg) & 0xffff; |
1018 | out: | 1017 | out: |
1019 | spin_unlock_irqrestore(&mp->shared_smi->phy_lock, flags); | 1018 | mutex_unlock(&mp->shared_smi->phy_lock); |
1020 | } | 1019 | } |
1021 | 1020 | ||
1022 | static void smi_reg_write(struct mv643xx_eth_private *mp, | 1021 | static void smi_reg_write(struct mv643xx_eth_private *mp, |
@@ -1024,11 +1023,10 @@ static void smi_reg_write(struct mv643xx_eth_private *mp, | |||
1024 | unsigned int reg, unsigned int value) | 1023 | unsigned int reg, unsigned int value) |
1025 | { | 1024 | { |
1026 | void __iomem *smi_reg = mp->shared_smi->base + SMI_REG; | 1025 | void __iomem *smi_reg = mp->shared_smi->base + SMI_REG; |
1027 | unsigned long flags; | ||
1028 | int i; | 1026 | int i; |
1029 | 1027 | ||
1030 | /* the SMI register is a shared resource */ | 1028 | /* the SMI register is a shared resource */ |
1031 | spin_lock_irqsave(&mp->shared_smi->phy_lock, flags); | 1029 | mutex_lock(&mp->shared_smi->phy_lock); |
1032 | 1030 | ||
1033 | /* wait for the SMI register to become available */ | 1031 | /* wait for the SMI register to become available */ |
1034 | for (i = 0; readl(smi_reg) & SMI_BUSY; i++) { | 1032 | for (i = 0; readl(smi_reg) & SMI_BUSY; i++) { |
@@ -1042,7 +1040,7 @@ static void smi_reg_write(struct mv643xx_eth_private *mp, | |||
1042 | writel(SMI_OPCODE_WRITE | (reg << 21) | | 1040 | writel(SMI_OPCODE_WRITE | (reg << 21) | |
1043 | (addr << 16) | (value & 0xffff), smi_reg); | 1041 | (addr << 16) | (value & 0xffff), smi_reg); |
1044 | out: | 1042 | out: |
1045 | spin_unlock_irqrestore(&mp->shared_smi->phy_lock, flags); | 1043 | mutex_unlock(&mp->shared_smi->phy_lock); |
1046 | } | 1044 | } |
1047 | 1045 | ||
1048 | 1046 | ||
@@ -1161,9 +1159,7 @@ static int mv643xx_eth_get_settings(struct net_device *dev, struct ethtool_cmd * | |||
1161 | struct mv643xx_eth_private *mp = netdev_priv(dev); | 1159 | struct mv643xx_eth_private *mp = netdev_priv(dev); |
1162 | int err; | 1160 | int err; |
1163 | 1161 | ||
1164 | spin_lock_irq(&mp->lock); | ||
1165 | err = mii_ethtool_gset(&mp->mii, cmd); | 1162 | err = mii_ethtool_gset(&mp->mii, cmd); |
1166 | spin_unlock_irq(&mp->lock); | ||
1167 | 1163 | ||
1168 | /* | 1164 | /* |
1169 | * The MAC does not support 1000baseT_Half. | 1165 | * The MAC does not support 1000baseT_Half. |
@@ -1211,18 +1207,13 @@ static int mv643xx_eth_get_settings_phyless(struct net_device *dev, struct ethto | |||
1211 | static int mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1207 | static int mv643xx_eth_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
1212 | { | 1208 | { |
1213 | struct mv643xx_eth_private *mp = netdev_priv(dev); | 1209 | struct mv643xx_eth_private *mp = netdev_priv(dev); |
1214 | int err; | ||
1215 | 1210 | ||
1216 | /* | 1211 | /* |
1217 | * The MAC does not support 1000baseT_Half. | 1212 | * The MAC does not support 1000baseT_Half. |
1218 | */ | 1213 | */ |
1219 | cmd->advertising &= ~ADVERTISED_1000baseT_Half; | 1214 | cmd->advertising &= ~ADVERTISED_1000baseT_Half; |
1220 | 1215 | ||
1221 | spin_lock_irq(&mp->lock); | 1216 | return mii_ethtool_sset(&mp->mii, cmd); |
1222 | err = mii_ethtool_sset(&mp->mii, cmd); | ||
1223 | spin_unlock_irq(&mp->lock); | ||
1224 | |||
1225 | return err; | ||
1226 | } | 1217 | } |
1227 | 1218 | ||
1228 | static int mv643xx_eth_set_settings_phyless(struct net_device *dev, struct ethtool_cmd *cmd) | 1219 | static int mv643xx_eth_set_settings_phyless(struct net_device *dev, struct ethtool_cmd *cmd) |
@@ -2324,7 +2315,7 @@ static int mv643xx_eth_shared_probe(struct platform_device *pdev) | |||
2324 | if (msp->base == NULL) | 2315 | if (msp->base == NULL) |
2325 | goto out_free; | 2316 | goto out_free; |
2326 | 2317 | ||
2327 | spin_lock_init(&msp->phy_lock); | 2318 | mutex_init(&msp->phy_lock); |
2328 | 2319 | ||
2329 | /* | 2320 | /* |
2330 | * (Re-)program MBUS remapping windows if we are asked to. | 2321 | * (Re-)program MBUS remapping windows if we are asked to. |