[OpenWrt-Devel] [PATCH 3/5] ramips: ethernet: Use lightweight locking in two places

Rosen Penev rosenp at gmail.com
Wed Jul 4 19:20:06 EDT 2018


Slightly more efficient.

Backport of: e3e9652a43207561eaec6085a8272fe11b283286

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 .../drivers/net/ethernet/mediatek/mtk_eth_soc.c       | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 6999635ad7..76ad00136d 100644
--- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -156,13 +156,11 @@ static inline void fe_int_enable(u32 mask)
 
 static inline void fe_hw_set_macaddr(struct fe_priv *priv, unsigned char *mac)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&priv->page_lock, flags);
+	spin_lock_bh(&priv->page_lock);
 	fe_w32((mac[0] << 8) | mac[1], FE_GDMA1_MAC_ADRH);
 	fe_w32((mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | mac[5],
 	       FE_GDMA1_MAC_ADRL);
-	spin_unlock_irqrestore(&priv->page_lock, flags);
+	spin_unlock_bh(&priv->page_lock);
 }
 
 static int fe_set_mac_address(struct net_device *dev, void *p)
@@ -1273,7 +1271,6 @@ static int fe_open(struct net_device *dev)
 static int fe_stop(struct net_device *dev)
 {
 	struct fe_priv *priv = netdev_priv(dev);
-	unsigned long flags;
 	int i;
 
 	netif_tx_disable(dev);
@@ -1283,12 +1280,12 @@ static int fe_stop(struct net_device *dev)
 	if (priv->phy)
 		priv->phy->stop(priv);
 
-	spin_lock_irqsave(&priv->page_lock, flags);
+	spin_lock_bh(&priv->page_lock);
 
 	fe_reg_w32(fe_reg_r32(FE_REG_PDMA_GLO_CFG) &
 		     ~(FE_TX_WB_DDONE | FE_RX_DMA_EN | FE_TX_DMA_EN),
 		     FE_REG_PDMA_GLO_CFG);
-	spin_unlock_irqrestore(&priv->page_lock, flags);
+	spin_unlock_bh(&priv->page_lock);
 
 	/* wait dma stop */
 	for (i = 0; i < 10; i++) {
-- 
2.17.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list