net: stmmac: introduce rtnl_lock|unlock() on configuring real_num_rx|tx_queues
Subsystems (4)
PATCH 1/1 net: stmmac: introduce rtnl_lock|unlock() on configuring real_num_rx|tx_queues
From: "Tan, Tee Min" <[email protected]>
For driver open(), rtnl_lock is acquired by network stack but not in the resume(). Therefore, we introduce lock_acquired boolean to control when to use rtnl_lock|unlock() within stmmac_hw_setup().
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10 -3
@@ -2607,7 +2607,8 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)* 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ -static int stmmac_hw_setup (struct net_device *dev,bool init_ptp) +static int stmmac_hw_setup (struct net_device *dev,bool init_ptp, +bool lock_acquired) {struct stmmac_priv *priv =netdev_priv (dev);u32 rx_cnt = priv->plat->rx_queues_to_use;
@@ -2715,9 +2716,15 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) }/* Configure real RX and TX queues */ +if (!lock_acquired) +rtnl_lock (); +netif_set_real_num_rx_queues (dev, priv->plat->rx_queues_to_use);netif_set_real_num_tx_queues (dev, priv->plat->tx_queues_to_use); +if (!lock_acquired) +rtnl_unlock (); +/* Start the ball rolling... */ stmmac_start_all_dma (priv);
@@ -2804,7 +2811,7 @@ static int stmmac_open(struct net_device *dev) goto init_error; } - ret =stmmac_hw_setup (dev, true); + ret =stmmac_hw_setup (dev, true, true);if (ret <0 ) {netdev_err (priv->dev,"%s: Hw setup failed\n" , __func__); goto init_error;
@@ -5238,7 +5245,7 @@ int stmmac_resume(struct device *dev)stmmac_clear_descriptors (priv); -stmmac_hw_setup (ndev, false); +stmmac_hw_setup (ndev, false, false);stmmac_init_coalesce (priv);stmmac_set_rx_mode (ndev);
Signature · 7 lines
2.17.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 5 lines · Wong Vee Khee
From: "Tan, Tee Min" <[email protected]>
For driver
open(),rtnl_lockis acquired by network stack but not in theresume(). Therefore, we introducelock_acquiredboolean to control when to use rtnl_lock|unlock() withinstmmac_hw_setup().
Doesn't really make sense, if function needs to have lock acquired, the caller is supposed to take it and function should have proper lockdep annotation inside and not this conditional lock/unlock.
Thanks
Quoted 3 lines
Fixes 686cff3d7022 ("net: stmmac: Fix incorrect location to set real_num_rx|tx_queues")
Extra line.
Quoted 56 lines
Signed-off-by Tan, Tee Min <[email protected]>--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +10
-4@@ -2607,7 +2607,8 @@ static void stmmac_safety_feat_configuration(struct stmmac_priv *priv)* 0 on success and an appropriate (-)ve integer as defined in errno.h * file on failure. */ -static int stmmac_hw_setup (struct net_device *dev,bool init_ptp) +static int stmmac_hw_setup (struct net_device *dev,bool init_ptp, +bool lock_acquired) {struct stmmac_priv *priv =netdev_priv (dev);u32 rx_cnt = priv->plat->rx_queues_to_use;@@ -2715,9 +2716,15 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) }/* Configure real RX and TX queues */ +if (!lock_acquired) +rtnl_lock (); +netif_set_real_num_rx_queues (dev, priv->plat->rx_queues_to_use);netif_set_real_num_tx_queues (dev, priv->plat->tx_queues_to_use); +if (!lock_acquired) +rtnl_unlock (); +/* Start the ball rolling... */ stmmac_start_all_dma (priv);@@ -2804,7 +2811,7 @@ static int stmmac_open(struct net_device *dev) goto init_error; } - ret =stmmac_hw_setup (dev, true); + ret =stmmac_hw_setup (dev, true, true);if (ret <0 ) {netdev_err (priv->dev,"%s: Hw setup failed\n" , __func__); goto init_error;@@ -5238,7 +5245,7 @@ int stmmac_resume(struct device *dev)stmmac_clear_descriptors (priv); -stmmac_hw_setup (ndev, false); +stmmac_hw_setup (ndev, false, false);stmmac_init_coalesce (priv);stmmac_set_rx_mode (ndev); --2.17.0