aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmit Kumar Salecha <amit.salecha@qlogic.com>2009-12-05 07:23:54 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-08 23:37:45 -0500
commit6f7714196b4e01d7462df31d705c3ca53ecbdfc1 (patch)
tree54dc8ba18ba5d1db10eaa5f79b6a002a9b9acdfb /drivers
parenta29ec08a1b649436248c140a3bc389bc11434c94 (diff)
netxen: protect device reset by rtnl_lock
o To prevent race conditions with other reset events. During suspend/resume and firmware recovery, acquire rtnl_lock, while changing interface state. Acked-by: Dhananjay Phadke <dhananjay.phadke@qlogic.com> Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/netxen/netxen_nic_main.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index e5d187fce51b..8ffb30bc798f 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -946,8 +946,9 @@ netxen_nic_init_coalesce_defaults(struct netxen_adapter *adapter)
946 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS; 946 NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS;
947} 947}
948 948
949/* with rtnl_lock */
949static int 950static int
950netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) 951__netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
951{ 952{
952 int err; 953 int err;
953 954
@@ -988,8 +989,24 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
988 return 0; 989 return 0;
989} 990}
990 991
992/* Usage: During resume and firmware recovery module.*/
993
994static inline int
995netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
996{
997 int err = 0;
998
999 rtnl_lock();
1000 if (netif_running(netdev))
1001 err = __netxen_nic_up(adapter, netdev);
1002 rtnl_unlock();
1003
1004 return err;
1005}
1006
1007/* with rtnl_lock */
991static void 1008static void
992netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) 1009__netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
993{ 1010{
994 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) 1011 if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
995 return; 1012 return;
@@ -1014,6 +1031,17 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1014 spin_unlock(&adapter->tx_clean_lock); 1031 spin_unlock(&adapter->tx_clean_lock);
1015} 1032}
1016 1033
1034/* Usage: During suspend and firmware recovery module */
1035
1036static inline void
1037netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
1038{
1039 rtnl_lock();
1040 if (netif_running(netdev))
1041 __netxen_nic_down(adapter, netdev);
1042 rtnl_unlock();
1043
1044}
1017 1045
1018static int 1046static int
1019netxen_nic_attach(struct netxen_adapter *adapter) 1047netxen_nic_attach(struct netxen_adapter *adapter)
@@ -1122,14 +1150,14 @@ netxen_nic_reset_context(struct netxen_adapter *adapter)
1122 netif_device_detach(netdev); 1150 netif_device_detach(netdev);
1123 1151
1124 if (netif_running(netdev)) 1152 if (netif_running(netdev))
1125 netxen_nic_down(adapter, netdev); 1153 __netxen_nic_down(adapter, netdev);
1126 1154
1127 netxen_nic_detach(adapter); 1155 netxen_nic_detach(adapter);
1128 1156
1129 if (netif_running(netdev)) { 1157 if (netif_running(netdev)) {
1130 err = netxen_nic_attach(adapter); 1158 err = netxen_nic_attach(adapter);
1131 if (!err) 1159 if (!err)
1132 err = netxen_nic_up(adapter, netdev); 1160 err = __netxen_nic_up(adapter, netdev);
1133 1161
1134 if (err) 1162 if (err)
1135 goto done; 1163 goto done;
@@ -1499,7 +1527,7 @@ static int netxen_nic_open(struct net_device *netdev)
1499 if (err) 1527 if (err)
1500 return err; 1528 return err;
1501 1529
1502 err = netxen_nic_up(adapter, netdev); 1530 err = __netxen_nic_up(adapter, netdev);
1503 if (err) 1531 if (err)
1504 goto err_out; 1532 goto err_out;
1505 1533
@@ -1519,7 +1547,7 @@ static int netxen_nic_close(struct net_device *netdev)
1519{ 1547{
1520 struct netxen_adapter *adapter = netdev_priv(netdev); 1548 struct netxen_adapter *adapter = netdev_priv(netdev);
1521 1549
1522 netxen_nic_down(adapter, netdev); 1550 __netxen_nic_down(adapter, netdev);
1523 return 0; 1551 return 0;
1524} 1552}
1525 1553
@@ -2210,8 +2238,7 @@ netxen_detach_work(struct work_struct *work)
2210 2238
2211 netif_device_detach(netdev); 2239 netif_device_detach(netdev);
2212 2240
2213 if (netif_running(netdev)) 2241 netxen_nic_down(adapter, netdev);
2214 netxen_nic_down(adapter, netdev);
2215 2242
2216 netxen_nic_detach(adapter); 2243 netxen_nic_detach(adapter);
2217 2244