Skip to content

Commit 1373889

Browse files
IoanaCiorneichombourger
authored andcommitted
dpaa2-eth: fix race condition with bql frame accounting
It might happen that Tx conf acknowledges a frame before it was subscribed in bql, as subscribing was previously done after the enqueue operation. This patch moves the netdev_tx_sent_queue call before the actual frame enqueue, so that this can never happen. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
1 parent 26fc3d1 commit 1373889

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,13 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
878878
/* Tracing point */
879879
trace_dpaa2_tx_fd(net_dev, &fd);
880880

881+
fd_len = dpaa2_fd_get_len(&fd);
882+
nq = netdev_get_tx_queue(net_dev, queue_mapping);
883+
netdev_tx_sent_queue(nq, fd_len);
884+
885+
/* Everything that happens after this enqueues might race with
886+
* the Tx confirmation callback for this frame
887+
*/
881888
for (i = 0; i < DPAA2_ETH_ENQUEUE_RETRIES; i++) {
882889
err = priv->enqueue(priv, fq, &fd, prio);
883890
if (err != -EBUSY)
@@ -888,13 +895,10 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev)
888895
percpu_stats->tx_errors++;
889896
/* Clean up everything, including freeing the skb */
890897
free_tx_fd(priv, fq, &fd, false);
898+
netdev_tx_completed_queue(nq, 1, fd_len);
891899
} else {
892-
fd_len = dpaa2_fd_get_len(&fd);
893900
percpu_stats->tx_packets++;
894901
percpu_stats->tx_bytes += fd_len;
895-
896-
nq = netdev_get_tx_queue(net_dev, queue_mapping);
897-
netdev_tx_sent_queue(nq, fd_len);
898902
}
899903

900904
return NETDEV_TX_OK;

0 commit comments

Comments
 (0)