diff options
author | Rajesh Borundia <rajesh.borundia@qlogic.com> | 2010-10-17 22:03:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-18 10:22:51 -0400 |
commit | 7a9905e64272c8021a8cfaf6015dd0fb8eeeb378 (patch) | |
tree | 085ccb214fcc14dd2589516bba768a7c23fcef0a /drivers/net/netxen | |
parent | 3666e0b04f092f9d9da8a6d6a3820de6c870407c (diff) |
netxen: fix race in tx stop queue
There is race between netif_stop_queue and netif_stopped_queue
check.So check once again if buffers are available to avoid race.
With above logic we can also get rid of tx lock in process_cmd_ring.
Signed-off-by: Rajesh Borundia <rajesh.borundia@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/net/netxen')
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 5 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 10 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 10 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 15 |
4 files changed, 22 insertions, 18 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 6dca3574e355..92f89af0720e 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -175,7 +175,10 @@ | |||
175 | #define MAX_NUM_CARDS 4 | 175 | #define MAX_NUM_CARDS 4 |
176 | 176 | ||
177 | #define MAX_BUFFERS_PER_CMD 32 | 177 | #define MAX_BUFFERS_PER_CMD 32 |
178 | #define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + 4) | 178 | #define MAX_TSO_HEADER_DESC 2 |
179 | #define MGMT_CMD_DESC_RESV 4 | ||
180 | #define TX_STOP_THRESH ((MAX_SKB_FRAGS >> 2) + MAX_TSO_HEADER_DESC \ | ||
181 | + MGMT_CMD_DESC_RESV) | ||
179 | #define NX_MAX_TX_TIMEOUTS 2 | 182 | #define NX_MAX_TX_TIMEOUTS 2 |
180 | 183 | ||
181 | /* | 184 | /* |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 29d7b93d0493..10e2f13d8903 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -598,8 +598,14 @@ netxen_send_cmd_descs(struct netxen_adapter *adapter, | |||
598 | 598 | ||
599 | if (nr_desc >= netxen_tx_avail(tx_ring)) { | 599 | if (nr_desc >= netxen_tx_avail(tx_ring)) { |
600 | netif_tx_stop_queue(tx_ring->txq); | 600 | netif_tx_stop_queue(tx_ring->txq); |
601 | __netif_tx_unlock_bh(tx_ring->txq); | 601 | smp_mb(); |
602 | return -EBUSY; | 602 | if (netxen_tx_avail(tx_ring) > nr_desc) { |
603 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) | ||
604 | netif_tx_wake_queue(tx_ring->txq); | ||
605 | } else { | ||
606 | __netif_tx_unlock_bh(tx_ring->txq); | ||
607 | return -EBUSY; | ||
608 | } | ||
603 | } | 609 | } |
604 | 610 | ||
605 | do { | 611 | do { |
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index a2d805aa75cd..95fe552aa279 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -1763,14 +1763,10 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter) | |||
1763 | 1763 | ||
1764 | smp_mb(); | 1764 | smp_mb(); |
1765 | 1765 | ||
1766 | if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) { | 1766 | if (netif_queue_stopped(netdev) && netif_carrier_ok(netdev)) |
1767 | __netif_tx_lock(tx_ring->txq, smp_processor_id()); | 1767 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) |
1768 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) { | ||
1769 | netif_wake_queue(netdev); | 1768 | netif_wake_queue(netdev); |
1770 | adapter->tx_timeo_cnt = 0; | 1769 | adapter->tx_timeo_cnt = 0; |
1771 | } | ||
1772 | __netif_tx_unlock(tx_ring->txq); | ||
1773 | } | ||
1774 | } | 1770 | } |
1775 | /* | 1771 | /* |
1776 | * If everything is freed up to consumer then check if the ring is full | 1772 | * If everything is freed up to consumer then check if the ring is full |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 2c6ceeb592b3..83ee5544aced 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -125,11 +125,6 @@ netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, | |||
125 | struct nx_host_tx_ring *tx_ring) | 125 | struct nx_host_tx_ring *tx_ring) |
126 | { | 126 | { |
127 | NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer); | 127 | NXWRIO(adapter, tx_ring->crb_cmd_producer, tx_ring->producer); |
128 | |||
129 | if (netxen_tx_avail(tx_ring) <= TX_STOP_THRESH) { | ||
130 | netif_stop_queue(adapter->netdev); | ||
131 | smp_mb(); | ||
132 | } | ||
133 | } | 128 | } |
134 | 129 | ||
135 | static uint32_t crb_cmd_consumer[4] = { | 130 | static uint32_t crb_cmd_consumer[4] = { |
@@ -1209,7 +1204,7 @@ netxen_setup_netdev(struct netxen_adapter *adapter, | |||
1209 | adapter->max_mc_count = 16; | 1204 | adapter->max_mc_count = 16; |
1210 | 1205 | ||
1211 | netdev->netdev_ops = &netxen_netdev_ops; | 1206 | netdev->netdev_ops = &netxen_netdev_ops; |
1212 | netdev->watchdog_timeo = 2*HZ; | 1207 | netdev->watchdog_timeo = 5*HZ; |
1213 | 1208 | ||
1214 | netxen_nic_change_mtu(netdev, netdev->mtu); | 1209 | netxen_nic_change_mtu(netdev, netdev->mtu); |
1215 | 1210 | ||
@@ -1825,9 +1820,13 @@ netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1825 | /* 4 fragments per cmd des */ | 1820 | /* 4 fragments per cmd des */ |
1826 | no_of_desc = (frag_count + 3) >> 2; | 1821 | no_of_desc = (frag_count + 3) >> 2; |
1827 | 1822 | ||
1828 | if (unlikely(no_of_desc + 2 > netxen_tx_avail(tx_ring))) { | 1823 | if (unlikely(netxen_tx_avail(tx_ring) <= TX_STOP_THRESH)) { |
1829 | netif_stop_queue(netdev); | 1824 | netif_stop_queue(netdev); |
1830 | return NETDEV_TX_BUSY; | 1825 | smp_mb(); |
1826 | if (netxen_tx_avail(tx_ring) > TX_STOP_THRESH) | ||
1827 | netif_start_queue(netdev); | ||
1828 | else | ||
1829 | return NETDEV_TX_BUSY; | ||
1831 | } | 1830 | } |
1832 | 1831 | ||
1833 | producer = tx_ring->producer; | 1832 | producer = tx_ring->producer; |