Commit 6f7714196b4e01d7462df31d705c3ca53ecbdfc1
Committed by
David S. Miller
1 parent
a29ec08a1b
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 35 additions and 8 deletions Side-by-side Diff
drivers/net/netxen/netxen_nic_main.c
... | ... | @@ -946,8 +946,9 @@ |
946 | 946 | NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS; |
947 | 947 | } |
948 | 948 | |
949 | +/* with rtnl_lock */ | |
949 | 950 | static int |
950 | -netxen_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 | 953 | int err; |
953 | 954 | |
954 | 955 | |
... | ... | @@ -988,8 +989,24 @@ |
988 | 989 | return 0; |
989 | 990 | } |
990 | 991 | |
992 | +/* Usage: During resume and firmware recovery module.*/ | |
993 | + | |
994 | +static inline int | |
995 | +netxen_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 */ | |
991 | 1008 | static void |
992 | -netxen_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 | 1011 | if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) |
995 | 1012 | return; |
996 | 1013 | |
... | ... | @@ -1014,7 +1031,18 @@ |
1014 | 1031 | spin_unlock(&adapter->tx_clean_lock); |
1015 | 1032 | } |
1016 | 1033 | |
1034 | +/* Usage: During suspend and firmware recovery module */ | |
1017 | 1035 | |
1036 | +static inline void | |
1037 | +netxen_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 | +} | |
1045 | + | |
1018 | 1046 | static int |
1019 | 1047 | netxen_nic_attach(struct netxen_adapter *adapter) |
1020 | 1048 | { |
1021 | 1049 | |
... | ... | @@ -1122,14 +1150,14 @@ |
1122 | 1150 | netif_device_detach(netdev); |
1123 | 1151 | |
1124 | 1152 | if (netif_running(netdev)) |
1125 | - netxen_nic_down(adapter, netdev); | |
1153 | + __netxen_nic_down(adapter, netdev); | |
1126 | 1154 | |
1127 | 1155 | netxen_nic_detach(adapter); |
1128 | 1156 | |
1129 | 1157 | if (netif_running(netdev)) { |
1130 | 1158 | err = netxen_nic_attach(adapter); |
1131 | 1159 | if (!err) |
1132 | - err = netxen_nic_up(adapter, netdev); | |
1160 | + err = __netxen_nic_up(adapter, netdev); | |
1133 | 1161 | |
1134 | 1162 | if (err) |
1135 | 1163 | goto done; |
... | ... | @@ -1499,7 +1527,7 @@ |
1499 | 1527 | if (err) |
1500 | 1528 | return err; |
1501 | 1529 | |
1502 | - err = netxen_nic_up(adapter, netdev); | |
1530 | + err = __netxen_nic_up(adapter, netdev); | |
1503 | 1531 | if (err) |
1504 | 1532 | goto err_out; |
1505 | 1533 | |
... | ... | @@ -1519,7 +1547,7 @@ |
1519 | 1547 | { |
1520 | 1548 | struct netxen_adapter *adapter = netdev_priv(netdev); |
1521 | 1549 | |
1522 | - netxen_nic_down(adapter, netdev); | |
1550 | + __netxen_nic_down(adapter, netdev); | |
1523 | 1551 | return 0; |
1524 | 1552 | } |
1525 | 1553 | |
... | ... | @@ -2210,8 +2238,7 @@ |
2210 | 2238 | |
2211 | 2239 | netif_device_detach(netdev); |
2212 | 2240 | |
2213 | - if (netif_running(netdev)) | |
2214 | - netxen_nic_down(adapter, netdev); | |
2241 | + netxen_nic_down(adapter, netdev); | |
2215 | 2242 | |
2216 | 2243 | netxen_nic_detach(adapter); |
2217 | 2244 |