Commit 0ae57bb3 authored by Sathya Perla's avatar Sathya Perla Committed by David S. Miller

be2net: fix tx completion cleanup

As a part of be_close(), instead of waiting for a max of 200ms for each TXQ,
wait for a total of 200ms for completions from all TXQs to arrive.
Signed-off-by: default avatarSathya Perla <sathya.perla@emulex.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 191eb756
...@@ -1563,51 +1563,62 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo) ...@@ -1563,51 +1563,62 @@ static void be_rx_cq_clean(struct be_rx_obj *rxo)
rxq->tail = rxq->head = 0; rxq->tail = rxq->head = 0;
} }
static void be_tx_compl_clean(struct be_adapter *adapter, static void be_tx_compl_clean(struct be_adapter *adapter)
struct be_tx_obj *txo)
{ {
struct be_queue_info *tx_cq = &txo->cq; struct be_tx_obj *txo;
struct be_queue_info *txq = &txo->q; struct be_queue_info *txq;
struct be_eth_tx_compl *txcp; struct be_eth_tx_compl *txcp;
u16 end_idx, cmpl = 0, timeo = 0, num_wrbs = 0; u16 end_idx, cmpl = 0, timeo = 0, num_wrbs = 0;
struct sk_buff **sent_skbs = txo->sent_skb_list;
struct sk_buff *sent_skb; struct sk_buff *sent_skb;
bool dummy_wrb; bool dummy_wrb;
int i, pending_txqs;
/* Wait for a max of 200ms for all the tx-completions to arrive. */ /* Wait for a max of 200ms for all the tx-completions to arrive. */
do { do {
while ((txcp = be_tx_compl_get(tx_cq))) { pending_txqs = adapter->num_tx_qs;
end_idx = AMAP_GET_BITS(struct amap_eth_tx_compl,
wrb_index, txcp); for_all_tx_queues(adapter, txo, i) {
num_wrbs += be_tx_compl_process(adapter, txo, end_idx); txq = &txo->q;
cmpl++; while ((txcp = be_tx_compl_get(&txo->cq))) {
} end_idx =
if (cmpl) { AMAP_GET_BITS(struct amap_eth_tx_compl,
be_cq_notify(adapter, tx_cq->id, false, cmpl); wrb_index, txcp);
atomic_sub(num_wrbs, &txq->used); num_wrbs += be_tx_compl_process(adapter, txo,
cmpl = 0; end_idx);
num_wrbs = 0; cmpl++;
}
if (cmpl) {
be_cq_notify(adapter, txo->cq.id, false, cmpl);
atomic_sub(num_wrbs, &txq->used);
cmpl = 0;
num_wrbs = 0;
}
if (atomic_read(&txq->used) == 0)
pending_txqs--;
} }
if (atomic_read(&txq->used) == 0 || ++timeo > 200) if (pending_txqs == 0 || ++timeo > 200)
break; break;
mdelay(1); mdelay(1);
} while (true); } while (true);
if (atomic_read(&txq->used)) for_all_tx_queues(adapter, txo, i) {
dev_err(&adapter->pdev->dev, "%d pending tx-completions\n", txq = &txo->q;
atomic_read(&txq->used)); if (atomic_read(&txq->used))
dev_err(&adapter->pdev->dev, "%d pending tx-compls\n",
/* free posted tx for which compls will never arrive */ atomic_read(&txq->used));
while (atomic_read(&txq->used)) {
sent_skb = sent_skbs[txq->tail]; /* free posted tx for which compls will never arrive */
end_idx = txq->tail; while (atomic_read(&txq->used)) {
index_adv(&end_idx, sent_skb = txo->sent_skb_list[txq->tail];
wrb_cnt_for_skb(adapter, sent_skb, &dummy_wrb) - 1, end_idx = txq->tail;
txq->len); num_wrbs = wrb_cnt_for_skb(adapter, sent_skb,
num_wrbs = be_tx_compl_process(adapter, txo, end_idx); &dummy_wrb);
atomic_sub(num_wrbs, &txq->used); index_adv(&end_idx, num_wrbs - 1, txq->len);
num_wrbs = be_tx_compl_process(adapter, txo, end_idx);
atomic_sub(num_wrbs, &txq->used);
}
} }
} }
...@@ -2236,7 +2247,6 @@ static void be_rx_qs_destroy(struct be_adapter *adapter) ...@@ -2236,7 +2247,6 @@ static void be_rx_qs_destroy(struct be_adapter *adapter)
static int be_close(struct net_device *netdev) static int be_close(struct net_device *netdev)
{ {
struct be_adapter *adapter = netdev_priv(netdev); struct be_adapter *adapter = netdev_priv(netdev);
struct be_tx_obj *txo;
struct be_eq_obj *eqo; struct be_eq_obj *eqo;
int i; int i;
...@@ -2259,8 +2269,7 @@ static int be_close(struct net_device *netdev) ...@@ -2259,8 +2269,7 @@ static int be_close(struct net_device *netdev)
/* Wait for all pending tx completions to arrive so that /* Wait for all pending tx completions to arrive so that
* all tx skbs are freed. * all tx skbs are freed.
*/ */
for_all_tx_queues(adapter, txo, i) be_tx_compl_clean(adapter);
be_tx_compl_clean(adapter, txo);
be_rx_qs_destroy(adapter); be_rx_qs_destroy(adapter);
return 0; return 0;
......
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