Skip to content

Commit

Permalink
netxen: fix deadlock on dev close
Browse files Browse the repository at this point in the history
netxen: fix deadlock on dev close

The tx ring accounting fix in commit cb2107b
("netxen: fix tx ring accounting") introduced intermittent
deadlock when inteface is going down.

This was possibly combined effect of speculative tx pause,
calling netif_tx_lock instead of queue lock and unclean
synchronization with napi which could end up unmasking
interrupt.

Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dhananjay Phadke authored and David S. Miller committed Jul 20, 2009
1 parent cf981ff commit b2af9cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions drivers/net/netxen/netxen_nic.h
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,8 @@ struct nx_host_tx_ring {
u32 crb_cmd_consumer;
u32 num_desc;

struct netdev_queue *txq;

struct netxen_cmd_buffer *cmd_buf_arr;
struct cmd_desc_type0 *desc_head;
dma_addr_t phys_addr;
Expand Down
9 changes: 5 additions & 4 deletions drivers/net/netxen/netxen_nic_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,14 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,
i = 0;

tx_ring = adapter->tx_ring;
netif_tx_lock_bh(adapter->netdev);
__netif_tx_lock_bh(tx_ring->txq);

producer = tx_ring->producer;
consumer = tx_ring->sw_consumer;

if (nr_desc >= find_diff_among(producer, consumer, tx_ring->num_desc)) {
netif_tx_unlock_bh(adapter->netdev);
if (nr_desc >= netxen_tx_avail(tx_ring)) {
netif_tx_stop_queue(tx_ring->txq);
__netif_tx_unlock_bh(tx_ring->txq);
return -EBUSY;
}

Expand All @@ -490,7 +491,7 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter,

netxen_nic_update_cmd_producer(adapter, tx_ring);

netif_tx_unlock_bh(adapter->netdev);
__netif_tx_unlock_bh(tx_ring->txq);

return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions drivers/net/netxen/netxen_nic_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
adapter->tx_ring = tx_ring;

tx_ring->num_desc = adapter->num_txd;
tx_ring->txq = netdev_get_tx_queue(netdev, 0);

cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring));
if (cmd_buf_arr == NULL) {
Expand Down Expand Up @@ -1400,10 +1401,10 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
smp_mb();

if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) {
netif_tx_lock(netdev);
__netif_tx_lock(tx_ring->txq, smp_processor_id());
if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH)
netif_wake_queue(netdev);
netif_tx_unlock(netdev);
__netif_tx_unlock(tx_ring->txq);
}
}
/*
Expand Down
20 changes: 13 additions & 7 deletions drivers/net/netxen/netxen_nic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ netxen_napi_disable(struct netxen_adapter *adapter)

for (ring = 0; ring < adapter->max_sds_rings; ring++) {
sds_ring = &recv_ctx->sds_rings[ring];
napi_disable(&sds_ring->napi);
netxen_nic_disable_int(sds_ring);
synchronize_irq(sds_ring->irq);
napi_synchronize(&sds_ring->napi);
napi_disable(&sds_ring->napi);
}
}

Expand Down Expand Up @@ -833,11 +833,11 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)

adapter->ahw.linkup = 0;

netxen_napi_enable(adapter);

if (adapter->max_sds_rings > 1)
netxen_config_rss(adapter, 1);

netxen_napi_enable(adapter);

if (adapter->capabilities & NX_FW_CAPABILITY_LINK_NOTIFICATION)
netxen_linkevent_request(adapter, 1);
else
Expand All @@ -851,8 +851,9 @@ netxen_nic_up(struct netxen_adapter *adapter, struct net_device *netdev)
static void
netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
{
spin_lock(&adapter->tx_clean_lock);
netif_carrier_off(netdev);
netif_stop_queue(netdev);
netif_tx_disable(netdev);

if (adapter->stop_port)
adapter->stop_port(adapter);
Expand All @@ -863,9 +864,10 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
netxen_napi_disable(adapter);

netxen_release_tx_buffers(adapter);
spin_unlock(&adapter->tx_clean_lock);

FLUSH_SCHEDULED_WORK();
del_timer_sync(&adapter->watchdog_timer);
FLUSH_SCHEDULED_WORK();
}


Expand Down Expand Up @@ -1645,6 +1647,9 @@ static void netxen_tx_timeout_task(struct work_struct *work)
struct netxen_adapter *adapter =
container_of(work, struct netxen_adapter, tx_timeout_task);

if (!netif_running(adapter->netdev))
return;

printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
netxen_nic_driver_name, adapter->netdev->name);

Expand Down Expand Up @@ -1757,7 +1762,8 @@ static int netxen_nic_poll(struct napi_struct *napi, int budget)

if ((work_done < budget) && tx_complete) {
napi_complete(&sds_ring->napi);
netxen_nic_enable_int(sds_ring);
if (netif_running(adapter->netdev))
netxen_nic_enable_int(sds_ring);
}

return work_done;
Expand Down

0 comments on commit b2af9cb

Please sign in to comment.