Commit 6f771419 authored by Amit Kumar Salecha's avatar Amit Kumar Salecha Committed by David S. Miller

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: default avatarDhananjay Phadke <dhananjay.phadke@qlogic.com>
Signed-off-by: default avatarAmit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a29ec08a
...@@ -946,8 +946,9 @@ netxen_nic_init_coalesce_defaults(struct netxen_adapter *adapter) ...@@ -946,8 +946,9 @@ netxen_nic_init_coalesce_defaults(struct netxen_adapter *adapter)
NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS; NETXEN_DEFAULT_INTR_COALESCE_TX_PACKETS;
} }
/* with rtnl_lock */
static int static int
netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) __netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
{ {
int err; int err;
...@@ -988,8 +989,24 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev) ...@@ -988,8 +989,24 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
return 0; return 0;
} }
/* Usage: During resume and firmware recovery module.*/
static inline int
netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
{
int err = 0;
rtnl_lock();
if (netif_running(netdev))
err = __netxen_nic_up(adapter, netdev);
rtnl_unlock();
return err;
}
/* with rtnl_lock */
static void static void
netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) __netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
{ {
if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC) if (adapter->is_up != NETXEN_ADAPTER_UP_MAGIC)
return; return;
...@@ -1014,6 +1031,17 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev) ...@@ -1014,6 +1031,17 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
spin_unlock(&adapter->tx_clean_lock); spin_unlock(&adapter->tx_clean_lock);
} }
/* Usage: During suspend and firmware recovery module */
static inline void
netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
{
rtnl_lock();
if (netif_running(netdev))
__netxen_nic_down(adapter, netdev);
rtnl_unlock();
}
static int static int
netxen_nic_attach(struct netxen_adapter *adapter) netxen_nic_attach(struct netxen_adapter *adapter)
...@@ -1122,14 +1150,14 @@ netxen_nic_reset_context(struct netxen_adapter *adapter) ...@@ -1122,14 +1150,14 @@ netxen_nic_reset_context(struct netxen_adapter *adapter)
netif_device_detach(netdev); netif_device_detach(netdev);
if (netif_running(netdev)) if (netif_running(netdev))
netxen_nic_down(adapter, netdev); __netxen_nic_down(adapter, netdev);
netxen_nic_detach(adapter); netxen_nic_detach(adapter);
if (netif_running(netdev)) { if (netif_running(netdev)) {
err = netxen_nic_attach(adapter); err = netxen_nic_attach(adapter);
if (!err) if (!err)
err = netxen_nic_up(adapter, netdev); err = __netxen_nic_up(adapter, netdev);
if (err) if (err)
goto done; goto done;
...@@ -1499,7 +1527,7 @@ static int netxen_nic_open(struct net_device *netdev) ...@@ -1499,7 +1527,7 @@ static int netxen_nic_open(struct net_device *netdev)
if (err) if (err)
return err; return err;
err = netxen_nic_up(adapter, netdev); err = __netxen_nic_up(adapter, netdev);
if (err) if (err)
goto err_out; goto err_out;
...@@ -1519,7 +1547,7 @@ static int netxen_nic_close(struct net_device *netdev) ...@@ -1519,7 +1547,7 @@ static int netxen_nic_close(struct net_device *netdev)
{ {
struct netxen_adapter *adapter = netdev_priv(netdev); struct netxen_adapter *adapter = netdev_priv(netdev);
netxen_nic_down(adapter, netdev); __netxen_nic_down(adapter, netdev);
return 0; return 0;
} }
...@@ -2210,8 +2238,7 @@ netxen_detach_work(struct work_struct *work) ...@@ -2210,8 +2238,7 @@ netxen_detach_work(struct work_struct *work)
netif_device_detach(netdev); netif_device_detach(netdev);
if (netif_running(netdev)) netxen_nic_down(adapter, netdev);
netxen_nic_down(adapter, netdev);
netxen_nic_detach(adapter); netxen_nic_detach(adapter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment